Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dfd07389 authored by Mehdi Alizadeh's avatar Mehdi Alizadeh Committed by Android (Google) Code Review
Browse files

Merge "Enforce Swipe Up gesture to be enabled based on the shipped SDK...

Merge "Enforce Swipe Up gesture to be enabled based on the shipped SDK version" into ub-launcher3-edmonton
parents 639b0717 2a8f265a
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -21,9 +21,12 @@ import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_HIDE_B
import static com.android.systemui.shared.system.NavigationBarCompat.FLAG_SHOW_OVERVIEW_BUTTON;
import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING_NAME;

import static com.android.launcher3.Utilities.getSystemProperty;

import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -91,10 +94,15 @@ public class OverviewInteractionState {
        mUiHandler = new Handler(this::handleUiMessage);
        mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage);

        if (shouldIgnoreSwipeUpEnabledSettings()) {
            mSwipeUpSettingObserver = null;
            mSwipeUpEnabled = true;
        } else {
            mSwipeUpSettingObserver = new SwipeUpGestureEnabledSettingObserver(mUiHandler,
                    context.getContentResolver());
            mSwipeUpSettingObserver.register();
        }
    }

    public boolean isSwipeUpGestureEnabled() {
        return mSwipeUpEnabled;
@@ -184,4 +192,13 @@ public class OverviewInteractionState {
            return Settings.Secure.getInt(mResolver, SWIPE_UP_SETTING_NAME, 0) == 1;
        }
    }

    private boolean shouldIgnoreSwipeUpEnabledSettings() {
        String sdkInt = getSystemProperty("ro.product.first_api_level", "0");
        try {
            return Integer.parseInt(sdkInt) >= Build.VERSION_CODES.P;
        } catch (Exception e) {
            return false;
        }
    }
}