@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if(U.relaunchActivityIfNeeded(this)) return;
+
setContentView(new View(this));
if(getIntent().hasExtra("finish_on_pause"))
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if(U.relaunchActivityIfNeeded(this)) return;
U.registerReceiver(this, switchReceiver, ACTION_UPDATE_SWITCH);
final SharedPreferences pref = U.getSharedPreferences(this);
SharedPreferences.Editor editor = pref.edit();
- if(!U.isLibrary(this))
- setTheme(U.isDarkTheme(this) ? R.style.Taskbar_Dark : R.style.Taskbar);
- else {
+ if(!U.isLibrary(this)) {
+ boolean isRelaunched = getIntent().hasExtra("is_relaunched");
+ int lightTheme = isRelaunched ? R.style.Taskbar_Floating : R.style.Taskbar;
+ int darkTheme = isRelaunched ? R.style.Taskbar_Dark_Floating : R.style.Taskbar_Dark;
+
+ setTheme(U.isDarkTheme(this) ? darkTheme : lightTheme);
+ } else {
int theme = getIntent().getIntExtra("theme", -1);
if(theme != -1)
setTheme(theme);
return canEnableFreeform(context, true);
}
- public static boolean canEnableFreeform(Context context, boolean checkPref) {
+ public static boolean canEnableFreeform(Context context, boolean allowOverride) {
if(getCurrentApiVersion() == 31.0f && !displayDefaultsToFreeform(context, getExternalDisplay(context))) {
- if(!checkPref) return false;
+ if(!allowOverride) return false;
SharedPreferences pref = getSharedPreferences(context);
return pref.getBoolean(PREF_OVERRIDE_FREEFORM_UNSUPPORTED, false);
return configString;
}
+
+ public static boolean relaunchActivityIfNeeded(Activity activity) {
+ if(isLibrary(activity)) return false;
+
+ Intent intent = activity.getIntent();
+ if(getCurrentApiVersion() != 30.0f
+ || !displayDefaultsToFreeform(activity, getExternalDisplay(activity))
+ || intent.hasExtra("is_relaunched")) {
+ return false;
+ }
+
+ intent.putExtra("is_relaunched", true);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
+ newHandler().post(() -> startActivityMaximized(activity, intent));
+ activity.finish();
+ return true;
+ }
}
<style name="Taskbar.Dark" parent="TaskbarBase.Dark" />
+ <style name="Taskbar.Floating">
+ <item name="android:windowIsFloating">true</item>
+ </style>
+
+ <style name="Taskbar.Dark.Floating">
+ <item name="android:windowIsFloating">true</item>
+ </style>
+
<style name="Taskbar.HomeActivity" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowShowWallpaper">true</item>
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:elevation="4dp"
- android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
+ android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<include layout="@layout/tb_switch_layout" />