mirror of https://github.com/M66B/FairEmail.git
Added MIUI notification sound workaround
This commit is contained in:
parent
0205df9274
commit
20581f5ce1
|
@ -888,6 +888,9 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
|
|||
if ("biometrics".equals(key) && !Helper.canAuthenticate(context))
|
||||
continue;
|
||||
|
||||
if ("alert_once".equals(key))
|
||||
continue;
|
||||
|
||||
Object value = jsetting.get("value");
|
||||
if (value instanceof Boolean)
|
||||
editor.putBoolean(key, (Boolean) value);
|
||||
|
|
|
@ -2114,6 +2114,7 @@ class Core {
|
|||
boolean notify_seen = (prefs.getBoolean("notify_seen", true) || !pro);
|
||||
boolean light = prefs.getBoolean("light", false);
|
||||
String sound = prefs.getString("sound", null);
|
||||
boolean alert_once = prefs.getBoolean("alert_once", true);
|
||||
|
||||
// Get contact info
|
||||
Map<TupleMessageEx, ContactInfo> messageContact = new HashMap<>();
|
||||
|
@ -2235,7 +2236,7 @@ class Core {
|
|||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
.setCategory(NotificationCompat.CATEGORY_EMAIL)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PRIVATE)
|
||||
.setOnlyAlertOnce(true);
|
||||
.setOnlyAlertOnce(alert_once);
|
||||
|
||||
// TODO: setAllowSystemGeneratedContextualActions
|
||||
|
||||
|
|
|
@ -67,13 +67,14 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
|||
private ImageButton ibManage;
|
||||
private SwitchCompat swLight;
|
||||
private Button btnSound;
|
||||
private SwitchCompat swAlertOnce;
|
||||
|
||||
private Group grpNotification;
|
||||
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"badge", "unseen_ignored",
|
||||
"notify_preview", "notify_trash", "notify_archive", "notify_reply", "notify_reply_direct", "notify_flag", "notify_seen", "biometrics_notify",
|
||||
"light", "sound"
|
||||
"light", "sound", "alert_once"
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -102,6 +103,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
|||
ibManage = view.findViewById(R.id.ibManage);
|
||||
swLight = view.findViewById(R.id.swLight);
|
||||
btnSound = view.findViewById(R.id.btnSound);
|
||||
swAlertOnce = view.findViewById(R.id.swAlertOnce);
|
||||
|
||||
grpNotification = view.findViewById(R.id.grpNotification);
|
||||
|
||||
|
@ -230,6 +232,16 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
|||
}
|
||||
});
|
||||
|
||||
swAlertOnce.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("alert_once", !checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swAlertOnce.setVisibility(Log.isXiaomi() || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||
grpNotification.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.O || BuildConfig.DEBUG ? View.VISIBLE : View.GONE);
|
||||
|
||||
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
return view;
|
||||
|
@ -297,8 +309,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
|||
swBiometricsNotify.setChecked(prefs.getBoolean("biometrics_notify", false));
|
||||
|
||||
swLight.setChecked(prefs.getBoolean("light", false));
|
||||
|
||||
grpNotification.setVisibility(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE);
|
||||
swAlertOnce.setChecked(!prefs.getBoolean("alert_once", true));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -837,4 +837,8 @@ public class Log {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
static boolean isXiaomi() {
|
||||
return "Xiaomi".equalsIgnoreCase(Build.MANUFACTURER);
|
||||
}
|
||||
}
|
|
@ -235,6 +235,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swLight" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAlertOnce"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_alert_once"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/btnSound"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/grpNotification"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -288,6 +288,7 @@
|
|||
<string name="title_advanced_biometrics_notify">Show notification content when using biometric authentication</string>
|
||||
<string name="title_advanced_light">Use notification light</string>
|
||||
<string name="title_advanced_sound">Select notification sound</string>
|
||||
<string name="title_advanced_alert_once" translatable="false">MIUI notification sound workaround</string>
|
||||
|
||||
<string name="title_advanced_badge_hint">Only available on supported launchers</string>
|
||||
<string name="title_advanced_notify_action_hint">At most three actions will be shown</string>
|
||||
|
|
Loading…
Reference in New Issue