Search in sources :

Example 1 with FreeformHackHelper

use of com.farmerbb.taskbar.helper.FreeformHackHelper in project Taskbar by farmerbb.

the class InvisibleActivityFreeform method cleanup.

private void cleanup() {
    if (!finish) {
        FreeformHackHelper helper = FreeformHackHelper.getInstance();
        helper.setFreeformHackActive(false);
        helper.setInFreeformWorkspace(false);
        finish = true;
    }
}
Also used : FreeformHackHelper(com.farmerbb.taskbar.helper.FreeformHackHelper)

Example 2 with FreeformHackHelper

use of com.farmerbb.taskbar.helper.FreeformHackHelper in project Taskbar by farmerbb.

the class U method stopFreeformHack.

public static void stopFreeformHack(Context context) {
    sendBroadcast(context, ACTION_FINISH_FREEFORM_ACTIVITY);
    if (isOverridingFreeformHack(context, false)) {
        FreeformHackHelper helper = FreeformHackHelper.getInstance();
        helper.setFreeformHackActive(false);
        helper.setInFreeformWorkspace(false);
    }
}
Also used : FreeformHackHelper(com.farmerbb.taskbar.helper.FreeformHackHelper)

Example 3 with FreeformHackHelper

use of com.farmerbb.taskbar.helper.FreeformHackHelper in project Taskbar by farmerbb.

the class U method launchApp.

private static void launchApp(Context context, boolean launchedFromTaskbar, boolean isPersistentShortcut, Runnable runnable) {
    SharedPreferences pref = getSharedPreferences(context);
    FreeformHackHelper helper = FreeformHackHelper.getInstance();
    boolean specialLaunch = hasBrokenSetLaunchBoundsApi() && helper.isInFreeformWorkspace() && MenuHelper.getInstance().isContextMenuOpen();
    boolean noAnimation = pref.getBoolean(PREF_DISABLE_ANIMATIONS, false);
    boolean isAndroidR = getCurrentApiVersion() > 29.0;
    if (hasFreeformSupport(context) && (isFreeformModeEnabled(context) || isPersistentShortcut) && (!helper.isInFreeformWorkspace() || specialLaunch)) {
        newHandler().postDelayed(() -> {
            startFreeformHack(context, true);
            newHandler().postDelayed(runnable, helper.isFreeformHackActive() ? 0 : isAndroidR ? 300 : 100);
        }, launchedFromTaskbar ? 0 : 100);
    } else
        newHandler().postDelayed(runnable, !launchedFromTaskbar && noAnimation ? 100 : isAndroidR ? 100 : 0);
}
Also used : SharedPreferences(android.content.SharedPreferences) FreeformHackHelper(com.farmerbb.taskbar.helper.FreeformHackHelper)

Example 4 with FreeformHackHelper

use of com.farmerbb.taskbar.helper.FreeformHackHelper in project Taskbar by farmerbb.

the class InvisibleActivityFreeform method onCreate.

@SuppressLint("HardwareIds")
@TargetApi(Build.VERSION_CODES.N)
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    FreeformHackHelper helper = FreeformHackHelper.getInstance();
    if (helper.isFreeformHackActive()) {
        proceedWithOnCreate = false;
        super.finish();
    }
    if (getIntent().hasExtra("check_multiwindow")) {
        showTaskbar = false;
        if (!isInMultiWindowMode()) {
            proceedWithOnCreate = false;
            super.finish();
        }
    }
    if (U.isOverridingFreeformHack(this)) {
        helper.setFreeformHackActive(true);
        helper.setInFreeformWorkspace(true);
        proceedWithOnCreate = false;
        super.finish();
        overridePendingTransition(0, 0);
    }
    if (!proceedWithOnCreate)
        return;
    // Detect outside touches, and pass them through to the underlying activity
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH);
    U.registerReceiver(this, appearingReceiver, ACTION_START_MENU_APPEARING, ACTION_CONTEXT_MENU_APPEARING, ACTION_DASHBOARD_APPEARING);
    U.registerReceiver(this, disappearingReceiver, ACTION_START_MENU_DISAPPEARING, ACTION_CONTEXT_MENU_DISAPPEARING, ACTION_DASHBOARD_DISAPPEARING);
    U.registerReceiver(this, finishReceiver, ACTION_FINISH_FREEFORM_ACTIVITY);
    helper.setFreeformHackActive(true);
    // Show power button warning on CyanogenMod / LineageOS devices
    if (getPackageManager().hasSystemFeature("com.cyanogenmod.android")) {
        SharedPreferences pref = U.getSharedPreferences(this);
        if (!pref.getString(PREF_POWER_BUTTON_WARNING, "null").equals(Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID))) {
            U.newHandler().postDelayed(() -> {
                if (helper.isInFreeformWorkspace()) {
                    Intent intent = U.getThemedIntent(this, InvisibleActivityAlt.class);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    intent.putExtra("power_button_warning", true);
                    U.startActivityMaximized(U.getDisplayContext(this), intent);
                }
            }, 100);
        }
    }
    showTaskbar = true;
}
Also used : SharedPreferences(android.content.SharedPreferences) Intent(android.content.Intent) FreeformHackHelper(com.farmerbb.taskbar.helper.FreeformHackHelper) SuppressLint(android.annotation.SuppressLint) TargetApi(android.annotation.TargetApi)

Aggregations

FreeformHackHelper (com.farmerbb.taskbar.helper.FreeformHackHelper)4 SharedPreferences (android.content.SharedPreferences)2 SuppressLint (android.annotation.SuppressLint)1 TargetApi (android.annotation.TargetApi)1 Intent (android.content.Intent)1