mirror of https://github.com/M66B/FairEmail.git
Added option to turn screen on for new message notifications
This commit is contained in:
parent
9dc426b9fb
commit
b00331886b
|
@ -32,6 +32,7 @@ import android.net.Uri;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.OperationCanceledException;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
import android.text.Html;
|
||||
|
@ -137,6 +138,7 @@ import static javax.mail.Folder.READ_WRITE;
|
|||
class Core {
|
||||
private static final int MAX_NOTIFICATION_DISPLAY = 10; // per group
|
||||
private static final int MAX_NOTIFICATION_COUNT = 100; // per group
|
||||
private static final long SCREEN_ON_DURATION = 3000L; // milliseconds
|
||||
private static final int SYNC_CHUNCK_SIZE = 200;
|
||||
private static final int SYNC_BATCH_SIZE = 20;
|
||||
private static final int DOWNLOAD_BATCH_SIZE = 20;
|
||||
|
@ -3888,6 +3890,7 @@ class Core {
|
|||
boolean notify_summary = prefs.getBoolean("notify_summary", false);
|
||||
boolean notify_preview = prefs.getBoolean("notify_preview", true);
|
||||
boolean notify_preview_only = prefs.getBoolean("notify_preview_only", false);
|
||||
boolean notify_screen_on = prefs.getBoolean("notify_screen_on", false);
|
||||
boolean wearable_preview = prefs.getBoolean("wearable_preview", false);
|
||||
boolean biometrics = prefs.getBoolean("biometrics", false);
|
||||
String pin = prefs.getString("pin", null);
|
||||
|
@ -4082,6 +4085,15 @@ class Core {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (notify_screen_on && notifications.size() > 0) {
|
||||
Log.i("Notify screen on");
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager.WakeLock wakeLock = pm.newWakeLock(
|
||||
PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP,
|
||||
BuildConfig.APPLICATION_ID + ":notification");
|
||||
wakeLock.acquire(SCREEN_ON_DURATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
|||
private TextView tvNotifyActionsPro;
|
||||
private SwitchCompat swLight;
|
||||
private Button btnSound;
|
||||
private SwitchCompat swNotifyScreenOn;
|
||||
|
||||
private SwitchCompat swBadge;
|
||||
private ImageButton ibBadge;
|
||||
|
@ -110,7 +111,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
|||
"notify_trash", "notify_junk", "notify_block_sender", "notify_archive", "notify_move",
|
||||
"notify_reply", "notify_reply_direct",
|
||||
"notify_flag", "notify_seen", "notify_hide", "notify_snooze",
|
||||
"light", "sound",
|
||||
"light", "sound", "notify_screen_on",
|
||||
"badge", "unseen_ignored",
|
||||
"notify_background_only", "notify_known", "notify_summary", "notify_remove", "notify_clear",
|
||||
"notify_subtext", "notify_preview", "notify_preview_all", "notify_preview_only", "notify_transliterate",
|
||||
|
@ -153,6 +154,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
|||
tvNotifyActionsPro = view.findViewById(R.id.tvNotifyActionsPro);
|
||||
swLight = view.findViewById(R.id.swLight);
|
||||
btnSound = view.findViewById(R.id.btnSound);
|
||||
swNotifyScreenOn = view.findViewById(R.id.swNotifyScreenOn);
|
||||
|
||||
swBadge = view.findViewById(R.id.swBadge);
|
||||
ibBadge = view.findViewById(R.id.ibBadge);
|
||||
|
@ -338,6 +340,13 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
|||
}
|
||||
});
|
||||
|
||||
swNotifyScreenOn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("notify_screen_on", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
btnSound.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -586,6 +595,7 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
|
|||
cbNotifyActionHide.setChecked(prefs.getBoolean("notify_hide", false) && pro);
|
||||
cbNotifyActionSnooze.setChecked(prefs.getBoolean("notify_snooze", false) && pro);
|
||||
swLight.setChecked(prefs.getBoolean("light", false));
|
||||
swNotifyScreenOn.setChecked(prefs.getBoolean("notify_screen_on", false));
|
||||
|
||||
swBadge.setChecked(prefs.getBoolean("badge", true));
|
||||
swUnseenIgnored.setChecked(prefs.getBoolean("unseen_ignored", false));
|
||||
|
|
|
@ -365,6 +365,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swLight" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swNotifyScreenOn"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_notify_screen_on"
|
||||
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/grpChannel"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
@ -499,6 +499,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_notify_screen_on">Briefly turn on the screen for new message notifications</string>
|
||||
<string name="title_advanced_alert_once" translatable="false">MIUI notification sound workaround</string>
|
||||
|
||||
<string name="title_advanced_caption_pgp" translatable="false">PGP</string>
|
||||
|
|
Loading…
Reference in New Issue