mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-03 10:16:45 +00:00
Added auto car mode
This commit is contained in:
parent
12479b7603
commit
b96e9d8a89
4 changed files with 31 additions and 0 deletions
|
@ -4,6 +4,10 @@
|
|||
|
||||
### [Adratiklit](https://en.wikipedia.org/wiki/Adratiklit)
|
||||
|
||||
### Next version
|
||||
|
||||
* Improved Android Auto support
|
||||
|
||||
### 1.1746
|
||||
|
||||
* Enabled Android auto support (see the FAQ for details)
|
||||
|
|
|
@ -4520,6 +4520,9 @@ class Core {
|
|||
String sound = prefs.getString("sound", null);
|
||||
boolean alert_once = prefs.getBoolean("alert_once", true);
|
||||
|
||||
if (Helper.inCar(context))
|
||||
notify_messaging = true;
|
||||
|
||||
// Get contact info
|
||||
Map<Long, Address[]> messageFrom = new HashMap<>();
|
||||
Map<Long, ContactInfo[]> messageInfo = new HashMap<>();
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.Manifest;
|
|||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.KeyguardManager;
|
||||
import android.app.UiModeManager;
|
||||
import android.app.usage.UsageStatsManager;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.ComponentName;
|
||||
|
@ -1041,6 +1042,17 @@ public class Helper {
|
|||
return (Build.VERSION.SDK_INT > Build.VERSION_CODES.R && false);
|
||||
}
|
||||
|
||||
static boolean inCar(Context context) {
|
||||
try {
|
||||
UiModeManager uimm =
|
||||
(UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
|
||||
return (uimm.getCurrentModeType() == Configuration.UI_MODE_TYPE_CAR);
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void reportNoViewer(Context context, Uri uri) {
|
||||
reportNoViewer(context, new Intent().setData(uri));
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import android.app.Dialog;
|
|||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.UiModeManager;
|
||||
import android.app.usage.UsageStatsManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
|
@ -1761,6 +1762,17 @@ public class Log {
|
|||
.append(" night=").append(Helper.isNight(context))
|
||||
.append("\r\n");
|
||||
|
||||
int mode;
|
||||
try {
|
||||
UiModeManager uimm =
|
||||
(UiModeManager) context.getSystemService(Context.UI_MODE_SERVICE);
|
||||
mode = uimm.getCurrentModeType();
|
||||
} catch (Throwable ex) {
|
||||
mode = -1;
|
||||
Log.w(ex);
|
||||
}
|
||||
sb.append(String.format("In car=%b mode=%d\r\n", Helper.inCar(context), mode));
|
||||
|
||||
sb.append("ExactAlarms")
|
||||
.append(" can=")
|
||||
.append(AlarmManagerCompatEx.canScheduleExactAlarms(context))
|
||||
|
|
Loading…
Reference in a new issue