Add support for hiding the icon in the status bar and the notification on the lockscreen.

This adds proper settings to toggle GB behavior and closes #460.
here
Daniele Gobbetti 2017-01-08 15:51:56 +01:00
parent 5c8f02d054
commit c1abaaa4e0
4 changed files with 17 additions and 1 deletions

View File

@ -171,6 +171,10 @@ public class GBApplication extends Application {
return prefs.getBoolean("log_to_file", false);
}
public static boolean minimizeNotification() {
return prefs.getBoolean("minimize_priority", false);
}
static void setupDatabase(Context context) {
DBOpenHelper helper = new DBOpenHelper(context, DATABASE_NAME, null);
SQLiteDatabase db = helper.getWritableDatabase();

View File

@ -61,11 +61,13 @@ public class GB {
.setContentText(text)
.setSmallIcon(connected ? R.drawable.ic_notification : R.drawable.ic_notification_disconnected)
.setContentIntent(pendingIntent)
.setPriority(Notification.PRIORITY_MIN)
.setOngoing(true);
if (GBApplication.isRunningLollipopOrLater()) {
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
}
if (GBApplication.minimizeNotification()) {
builder.setPriority(Notification.PRIORITY_MIN);
}
return builder.build();
}

View File

@ -65,6 +65,10 @@
<string name="pref_title_language">Language</string>
<string name="pref_title_minimize_priority">Hide the gadgetbridge notification</string>
<string name="pref_summary_minimize_priority_off">The icon in the status bar and the notification in the lockscreen are shown</string>
<string name="pref_summary_minimize_priority_on">The icon in the status bar and the notification in the lockscreen are hidden</string>
<string name="pref_header_notifications">Notifications</string>
<string name="pref_title_notifications_repetitions">Repetitions</string>
<string name="pref_title_notifications_call">Phone Calls</string>

View File

@ -30,6 +30,12 @@
android:entryValues="@array/pref_language_values"
android:defaultValue="default"
android:summary="%s" />
<CheckBoxPreference
android:defaultValue="false"
android:key="minimize_priority"
android:summaryOff="@string/pref_summary_minimize_priority_off"
android:summaryOn="@string/pref_summary_minimize_priority_on"
android:title="@string/pref_title_minimize_priority" />
</PreferenceCategory>
<PreferenceCategory
android:key="pref_key_datetime"