Added option to disable shortcut badger

pull/153/head
M66B 6 years ago
parent 7c83525122
commit d34a366a7e

@ -1398,12 +1398,14 @@ class Core {
static void notifyMessages(Context context, List<TupleMessageEx> messages) {
Log.i("Notify messages=" + messages.size());
Widget.update(context, messages.size());
ShortcutBadger.applyCount(context, messages.size());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences.Editor editor = prefs.edit();
boolean badge = prefs.getBoolean("badge", true);
Widget.update(context, messages.size());
ShortcutBadger.applyCount(context, badge ? messages.size() : 0);
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Map<String, List<Long>> groupNotifying = new HashMap<>();

@ -100,6 +100,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
private SwitchCompat swSender;
private SwitchCompat swAutoSend;
private SwitchCompat swBadge;
private SwitchCompat swNotifyPreview;
private SwitchCompat swSearchLocal;
private SwitchCompat swLight;
@ -178,6 +179,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swSender = view.findViewById(R.id.swSender);
swAutoSend = view.findViewById(R.id.swAutoSend);
swBadge = view.findViewById(R.id.swBadge);
swNotifyPreview = view.findViewById(R.id.swNotifyPreview);
swSearchLocal = view.findViewById(R.id.swSearchLocal);
swLight = view.findViewById(R.id.swLight);
@ -486,6 +488,14 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
}
});
swBadge.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("badge", checked).apply();
ServiceSynchronize.reload(getContext(), "badge");
}
});
swNotifyPreview.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -644,6 +654,7 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swSender.setChecked(prefs.getBoolean("sender", false));
swAutoSend.setChecked(!prefs.getBoolean("autosend", false));
swBadge.setChecked(prefs.getBoolean("badge", true));
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
swNotifyPreview.setEnabled(Helper.isPro(getContext()));
swSearchLocal.setChecked(prefs.getBoolean("search_local", false));

@ -712,6 +712,31 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSectionMisc" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swBadge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_badge"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorMisc"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvBadgeHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="60dp"
android:text="@string/title_advanced_badge_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swBadge" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swNotifyPreview"
android:layout_width="match_parent"
@ -721,7 +746,7 @@
android:layout_marginEnd="12dp"
android:text="@string/title_advanced_notify_preview"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorMisc"
app:layout_constraintTop_toBottomOf="@id/tvBadgeHint"
app:switchPadding="12dp" />
<TextView

@ -184,6 +184,7 @@
<string name="title_advanced_sender">Allow editing sender address</string>
<string name="title_advanced_autosend">Confirm sending messages</string>
<string name="title_advanced_badge">Show launcher icon with number of new messages</string>
<string name="title_advanced_notify_preview">Show message preview in notifications</string>
<string name="title_advanced_search_local">External search on device</string>
<string name="title_advanced_light">Use notification light</string>
@ -203,6 +204,8 @@
<string name="title_advanced_autocollapse_hint">Multiple expanded messages will always be closed on \'back\'</string>
<string name="title_advanced_autoclose_hint">Automatically close conversations when all messages are archived, sent or trashed</string>
<string name="title_advanced_sender_hint">Most providers do not allow modified sender addresses</string>
<string name="title_advanced_badge_hint">Only available on supported devices</string>
<string name="title_advanced_preview_hint">Only available when message text was downloaded</string>
<string name="title_advanced_search_local_hint">Instead of searching in the primary archive folder on the server</string>
<string name="title_advanced_english_hint">This will restart the app</string>

Loading…
Cancel
Save