Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to show/hide timestamps on the 3x2 widget #373

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added option to display/hide timestamps on widget
  • Loading branch information
Marcel de Sena Dall'Agnol committed Jun 1, 2017
commit 0f825f657bd36f692074177aee6af91fc209fdeb
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ private void initViewFooter() {
.PREF_PRETTIFIED_DATES, true));
lastModificationTextView.append(lastModification.length() > 0 ? getString(R.string.last_update) + " " +
lastModification : "");
lastModificationTextView.append("blablabla");
if (lastModificationTextView.getText().length() == 0)
lastModificationTextView.setVisibility(View.GONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,16 @@ public void onResume() {
});
}

// Update widget when last modification display for widget is toggled
final SwitchPreference widgetLastModification = (SwitchPreference) findPreference("settings_display_last_modified");
if (widgetLastModification != null) {
widgetLastModification.setOnPreferenceChangeListener((preference, newValue) -> {
widgetLastModification.setChecked((Boolean) newValue);
MainActivity.notifyAppWidgets(OmniNotes.getAppContext());
return false;
});
}


// Notification snooze delay
final EditTextPreference snoozeDelay = (EditTextPreference) findPreference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public interface ConstantsBase {
String PREF_ENABLE_SWIPE = "settings_enable_swipe";
String PREF_SEND_ANALYTICS = "settings_send_analytics";
String PREF_PRETTIFIED_DATES = "settings_prettified_dates";
String PREF_DISPLAY_LAST_MODIFICATION = "settings_display_last_modified";

String MIME_TYPE_IMAGE = "image/jpeg";
String MIME_TYPE_AUDIO = "audio/amr";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.appwidget.AppWidgetManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
Expand Down Expand Up @@ -53,6 +54,7 @@ public class ListRemoteViewsFactory implements RemoteViewsFactory {
private OmniNotes app;
private int appWidgetId;
private List<Note> notes;
private boolean show_last_modified;
private int navigation;


Expand All @@ -65,11 +67,12 @@ public ListRemoteViewsFactory(Application app, Intent intent) {
@Override
public void onCreate() {
Log.d(Constants.TAG, "Created widget " + appWidgetId);
String condition = app.getSharedPreferences(Constants.PREFS_NAME, Context.MODE_MULTI_PROCESS)
.getString(
Constants.PREF_WIDGET_PREFIX
+ String.valueOf(appWidgetId), "");
notes = DbHelper.getInstance().getNotes(condition, true);

SharedPreferences prefs = app.getSharedPreferences(Constants.PREFS_NAME, Context.MODE_MULTI_PROCESS);
notes = DbHelper.getInstance().getNotes(
prefs.getString(Constants.PREF_WIDGET_PREFIX
+ String.valueOf(appWidgetId), ""), true);
show_last_modified = prefs.getBoolean(Constants.PREF_DISPLAY_LAST_MODIFICATION, true);
}


Expand All @@ -78,11 +81,11 @@ public void onDataSetChanged() {
Log.d(Constants.TAG, "onDataSetChanged widget " + appWidgetId);
navigation = Navigation.getNavigation();

String condition = app.getSharedPreferences(Constants.PREFS_NAME, Context.MODE_MULTI_PROCESS)
.getString(
Constants.PREF_WIDGET_PREFIX
+ String.valueOf(appWidgetId), "");
notes = DbHelper.getInstance().getNotes(condition, true);
SharedPreferences prefs = app.getSharedPreferences(Constants.PREFS_NAME, Context.MODE_MULTI_PROCESS);
notes = DbHelper.getInstance().getNotes(
prefs.getString(Constants.PREF_WIDGET_PREFIX
+ String.valueOf(appWidgetId), ""), true);
show_last_modified = prefs.getBoolean(Constants.PREF_DISPLAY_LAST_MODIFICATION, true);
}


Expand Down Expand Up @@ -122,8 +125,10 @@ public RemoteViews getViewAt(int position) {
} else {
row.setInt(R.id.attachmentThumbnail, "setVisibility", View.GONE);
}

row.setTextViewText(R.id.note_date, TextHelper.getDateText(app, note, navigation));
if(show_last_modified)
row.setTextViewText(R.id.note_date, TextHelper.getDateText(app, note, navigation));
else
row.setTextViewText(R.id.note_date, "");

// Next, set a fill-intent, which will be used to fill in the pending intent template
// that is set on the collection view in StackWidgetProvider.
Expand Down
3 changes: 3 additions & 0 deletions omniNotes/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,9 @@
<string name="settings_prettified_dates">Prettified dates</string>
<string name="settings_prettified_dates_summary_on">Dates are shown in a simplier format</string>
<string name="settings_prettified_dates_summary_off">Dates are shown in a more detailed format</string>
<string name="settings_display_last_modified">Last modification on widget</string>
<string name="settings_display_last_modified_summary_on">Last modified timestamp shown on notes</string>
<string name="settings_display_last_modified_summary_off">Last modified timestamp hidden</string>
<string name="settings_screen_privacy">Privacy</string>
<string name="settings_error_reporting">Error reporting</string>
<string name="settings_error_reporting_summary_on">When app crashes developer will be informed to help you</string>
Expand Down
7 changes: 7 additions & 0 deletions omniNotes/src/main/res/xml/settings_interface.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,11 @@
android:title="@string/settings_prettified_dates"
android:defaultValue="true"/>

<SwitchPreference
android:key="settings_display_last_modified"
android:summaryOn="@string/settings_display_last_modified_summary_on"
android:summaryOff="@string/settings_display_last_modified_summary_off"
android:title="@string/settings_display_last_modified"
android:defaultValue="true"/>

</PreferenceScreen>