registerReceiver(userBackgroundReceiver, new IntentFilter(Intent.ACTION_USER_BACKGROUND));
}
- if(U.isDesktopModeSupported(this)) {
+ if(U.shouldStartDesktopMode(this)) {
startDesktopMode(U.getExternalDisplayID(this), false);
DisplayManager manager = (DisplayManager) getSystemService(DISPLAY_SERVICE);
unregisterReceiver(userBackgroundReceiver);
}
- if(U.isDesktopModeSupported(this)) {
+ if(U.shouldStartDesktopMode(this)) {
DisplayManager manager = (DisplayManager) getSystemService(DISPLAY_SERVICE);
manager.unregisterDisplayListener(listener);
}
public static boolean isDesktopModeSupported(Context context) {
+ if(isLauncherPermanentlyEnabled(context)) return false;
+
return Build.VERSION.SDK_INT > Build.VERSION_CODES.P
&& context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS);
}
return desktopModePrefEnabled && getExternalDisplayID(context) != Display.DEFAULT_DISPLAY;
}
+ public static boolean shouldStartDesktopMode(Context context) {
+ SharedPreferences pref = getSharedPreferences(context);
+
+ return isDesktopModeSupported(context)
+ && pref.getBoolean("desktop_mode", false)
+ && !pref.getBoolean("launcher", false);
+ }
+
public static int getExternalDisplayID(Context context) {
DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
Display[] displays = dm.getDisplays();