private int startDragIndex;
private int endDragIndex;
+ private boolean dcvRemoved;
+
private GestureDetector detector;
private BroadcastReceiver killReceiver = new BroadcastReceiver() {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- if(this instanceof SecondaryHomeActivity)
+ if(this instanceof SecondaryHomeActivity) {
+ if(!U.isDesktopModeActive(this)) {
+ finish();
+ return;
+ }
+
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
+ }
shouldDelayFreeformHack = true;
hits = 0;
|| U.isLauncherPermanentlyEnabled(this))
&& !U.isChromeOs(this)) {
setContentView(layout);
+
+ if(this instanceof SecondaryHomeActivity) {
+ dcvRemoved = false;
+ traverseAndRemoveDecorCaption(getWindow().getDecorView());
+ }
+
pref.edit().putBoolean("launcher", !(this instanceof SecondaryHomeActivity)).apply();
} else
killHomeActivity();
} else
helper.setOnPrimaryHomeScreen(value);
}
+
+ @SuppressWarnings("rawtypes")
+ @SuppressLint("PrivateApi")
+ private void traverseAndRemoveDecorCaption(View view) {
+ if(dcvRemoved || !(view instanceof ViewGroup))
+ return;
+
+ Class dcvClass;
+ try {
+ dcvClass = Class.forName("com.android.internal.widget.DecorCaptionView");
+ } catch (ClassNotFoundException e) {
+ return;
+ }
+
+ ViewGroup viewGroup = (ViewGroup) view;
+ int position = -1;
+
+ for(int i = 0; i < viewGroup.getChildCount(); i++) {
+ View child = viewGroup.getChildAt(i);
+
+ if(dcvClass.isInstance(child)) {
+ position = i;
+ break;
+ } else
+ traverseAndRemoveDecorCaption(child);
+ }
+
+ if(position >= 0) {
+ viewGroup.removeViewAt(position);
+ dcvRemoved = true;
+ }
+ }
}
package com.farmerbb.taskbar.fragment;
+import android.annotation.TargetApi;
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.preference.Preference;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
// Add preferences
addPreferencesFromResource(R.xml.tb_pref_desktop_mode);
+ // Set OnClickListeners for certain preferences
+ findPreference("set_as_default").setOnPreferenceClickListener(this);
+
SharedPreferences pref = U.getSharedPreferences(getActivity());
if(pref.getBoolean("launcher", false))
findPreference("desktop_mode").setEnabled(false);
if(actionBar != null)
actionBar.setDisplayHomeAsUpEnabled(true);
}
+
+ @TargetApi(29)
+ @Override
+ public boolean onPreferenceClick(final Preference p) {
+ final SharedPreferences pref = U.getSharedPreferences(getActivity());
+
+ switch(p.getKey()) {
+ case "set_as_default":
+ Intent intent = new Intent();
+ intent.setAction(Intent.ACTION_MAIN);
+ intent.addCategory(Intent.CATEGORY_SECONDARY_HOME);
+
+ try {
+ startActivity(intent);
+ } catch (Exception e) { /* Gracefully fail */ }
+
+ break;
+ }
+
+ return super.onPreferenceClick(p);
+ }
}
\ No newline at end of file
Intent intent = new Intent(this, SecondaryHomeActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- startActivity(intent, U.getActivityOptions(this, ApplicationType.GAME, null).toBundle());
+ startActivity(intent, U.getActivityOptions(this, ApplicationType.APP_FULLSCREEN, null).toBundle());
};
if(shouldDelay)
package com.farmerbb.taskbar.util;
-public enum ApplicationType { APP_PORTRAIT, APP_LANDSCAPE, GAME, FREEFORM_HACK, CONTEXT_MENU }
\ No newline at end of file
+public enum ApplicationType { APP_PORTRAIT, APP_LANDSCAPE, APP_FULLSCREEN, FREEFORM_HACK, CONTEXT_MENU }
\ No newline at end of file
else
stackId = getFullscreenWindowModeId();
break;
- case GAME:
+ case APP_FULLSCREEN:
stackId = getFullscreenWindowModeId();
break;
case FREEFORM_HACK:
@SuppressLint("SwitchIntDef")
private static ApplicationType getApplicationType(Context context, AppEntry entry) {
if(isGame(context, entry.getPackageName()))
- return ApplicationType.GAME;
+ return ApplicationType.APP_FULLSCREEN;
try {
ActivityInfo info = context.getPackageManager().getActivityInfo(
android:key="desktop_mode"
android:title="@string/tb_pref_header_desktop_mode"/>
+ <Preference
+ android:key="set_as_default"
+ android:title="Set as default"/>
+
<PreferenceCategory android:key="dummy" android:title="\n\n" />
</PreferenceScreen>