mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
make LED blinking for notifications configurable
This commit is contained in:
@@ -72,7 +72,7 @@ class AndroidNotificationTray
|
|||||||
.addAction(checkAction)
|
.addAction(checkAction)
|
||||||
.addAction(snoozeAction)
|
.addAction(snoozeAction)
|
||||||
|
|
||||||
val notification = NotificationCompat.Builder(context)
|
val builder = NotificationCompat.Builder(context)
|
||||||
.setSmallIcon(R.drawable.ic_notification)
|
.setSmallIcon(R.drawable.ic_notification)
|
||||||
.setContentTitle(habit.name)
|
.setContentTitle(habit.name)
|
||||||
.setContentText(habit.description)
|
.setContentText(habit.description)
|
||||||
@@ -85,8 +85,9 @@ class AndroidNotificationTray
|
|||||||
.setWhen(reminderTime)
|
.setWhen(reminderTime)
|
||||||
.setShowWhen(true)
|
.setShowWhen(true)
|
||||||
.setOngoing(preferences.shouldMakeNotificationsSticky())
|
.setOngoing(preferences.shouldMakeNotificationsSticky())
|
||||||
.setLights(Color.RED, 1000, 1000)
|
if (preferences.shouldMakeNotificationsLed())
|
||||||
.build()
|
builder.setLights(Color.RED, 1000, 1000)
|
||||||
|
val notification = builder.build()
|
||||||
|
|
||||||
val notificationManager = context.getSystemService(
|
val notificationManager = context.getSystemService(
|
||||||
Activity.NOTIFICATION_SERVICE) as NotificationManager
|
Activity.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
|||||||
@@ -85,6 +85,8 @@ class SharedPreferencesStorage
|
|||||||
preferences.isCheckmarkSequenceReversed = getBoolean(key, false)
|
preferences.isCheckmarkSequenceReversed = getBoolean(key, false)
|
||||||
"pref_sticky_notifications" ->
|
"pref_sticky_notifications" ->
|
||||||
preferences.setNotificationsSticky(getBoolean(key, false))
|
preferences.setNotificationsSticky(getBoolean(key, false))
|
||||||
|
"pref_led_notifications" ->
|
||||||
|
preferences.setNotificationsLed(getBoolean(key, false))
|
||||||
"pref_feature_sync" ->
|
"pref_feature_sync" ->
|
||||||
preferences.isSyncEnabled = getBoolean(key, false)
|
preferences.isSyncEnabled = getBoolean(key, false)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,6 +188,8 @@
|
|||||||
|
|
||||||
<string name="sticky_notifications">Make notifications sticky</string>
|
<string name="sticky_notifications">Make notifications sticky</string>
|
||||||
<string name="sticky_notifications_description">Prevents notifications from being swiped away.</string>
|
<string name="sticky_notifications_description">Prevents notifications from being swiped away.</string>
|
||||||
|
<string name="led_notifications">LED</string>
|
||||||
|
<string name="led_notifications_description">Notifications blinking light.</string>
|
||||||
<string name="repair_database">Repair database</string>
|
<string name="repair_database">Repair database</string>
|
||||||
<string name="database_repaired">Database repaired.</string>
|
<string name="database_repaired">Database repaired.</string>
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,12 @@
|
|||||||
android:title="@string/sticky_notifications"
|
android:title="@string/sticky_notifications"
|
||||||
android:summary="@string/sticky_notifications_description"/>
|
android:summary="@string/sticky_notifications_description"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="pref_led_notifications"
|
||||||
|
android:title="@string/led_notifications"
|
||||||
|
android:summary="@string/led_notifications_description"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
|||||||
@@ -263,6 +263,12 @@ public class Preferences
|
|||||||
for (Listener l : listeners) l.onNotificationsChanged();
|
for (Listener l : listeners) l.onNotificationsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setNotificationsLed(boolean enabled)
|
||||||
|
{
|
||||||
|
storage.putBoolean("pref_led_notifications", enabled);
|
||||||
|
for (Listener l : listeners) l.onNotificationsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
public void setCheckmarkSequenceReversed(boolean reverse)
|
public void setCheckmarkSequenceReversed(boolean reverse)
|
||||||
{
|
{
|
||||||
shouldReverseCheckmarks = reverse;
|
shouldReverseCheckmarks = reverse;
|
||||||
@@ -281,6 +287,11 @@ public class Preferences
|
|||||||
return storage.getBoolean("pref_sticky_notifications", false);
|
return storage.getBoolean("pref_sticky_notifications", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean shouldMakeNotificationsLed()
|
||||||
|
{
|
||||||
|
return storage.getBoolean("pref_led_notifications", false);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCheckmarkSequenceReversed()
|
public boolean isCheckmarkSequenceReversed()
|
||||||
{
|
{
|
||||||
if (shouldReverseCheckmarks == null) shouldReverseCheckmarks =
|
if (shouldReverseCheckmarks == null) shouldReverseCheckmarks =
|
||||||
|
|||||||
@@ -159,6 +159,10 @@ public class PreferencesTest extends BaseUnitTest
|
|||||||
prefs.setNotificationsSticky(true);
|
prefs.setNotificationsSticky(true);
|
||||||
assertTrue(prefs.shouldMakeNotificationsSticky());
|
assertTrue(prefs.shouldMakeNotificationsSticky());
|
||||||
|
|
||||||
|
assertFalse(prefs.shouldMakeNotificationsLed());
|
||||||
|
prefs.setNotificationsLed(true);
|
||||||
|
assertTrue(prefs.shouldMakeNotificationsLed());
|
||||||
|
|
||||||
assertThat(prefs.getSnoozeInterval(), equalTo(15L));
|
assertThat(prefs.getSnoozeInterval(), equalTo(15L));
|
||||||
prefs.setSnoozeInterval(30);
|
prefs.setSnoozeInterval(30);
|
||||||
assertThat(prefs.getSnoozeInterval(), equalTo(30L));
|
assertThat(prefs.getSnoozeInterval(), equalTo(30L));
|
||||||
|
|||||||
Reference in New Issue
Block a user