diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2018-08-09 19:49:20 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2018-08-09 19:49:20 +0000 |
commit | 431ec79c99fb0258d77dff2ca23e820e7b030d21 (patch) | |
tree | a3b2bc96a99bcac6a61ebae68b1b8780393d1cf6 /quickstep | |
parent | 86944e9d7eea7887c31644cef9807573e14ee607 (diff) | |
parent | b02bcd4c76e4a11e99851e9d98a1d5a04021700b (diff) | |
download | android_packages_apps_Trebuchet-431ec79c99fb0258d77dff2ca23e820e7b030d21.tar.gz android_packages_apps_Trebuchet-431ec79c99fb0258d77dff2ca23e820e7b030d21.tar.bz2 android_packages_apps_Trebuchet-431ec79c99fb0258d77dff2ca23e820e7b030d21.zip |
Merge "Removing code duplication for getting swipe-up setting" into ub-launcher3-master
Diffstat (limited to 'quickstep')
-rw-r--r-- | quickstep/src/com/android/quickstep/OverviewInteractionState.java | 23 | ||||
-rw-r--r-- | quickstep/src/com/android/quickstep/SwipeUpSetting.java | 50 |
2 files changed, 53 insertions, 20 deletions
diff --git a/quickstep/src/com/android/quickstep/OverviewInteractionState.java b/quickstep/src/com/android/quickstep/OverviewInteractionState.java index 99fffd8ff..a5ff68113 100644 --- a/quickstep/src/com/android/quickstep/OverviewInteractionState.java +++ b/quickstep/src/com/android/quickstep/OverviewInteractionState.java @@ -22,7 +22,6 @@ import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING import android.content.ContentResolver; import android.content.Context; -import android.content.res.Resources; import android.database.ContentObserver; import android.os.Handler; import android.os.Message; @@ -51,10 +50,6 @@ public class OverviewInteractionState { private static final String TAG = "OverviewFlags"; private static final String HAS_ENABLED_QUICKSTEP_ONCE = "launcher.has_enabled_quickstep_once"; - private static final String SWIPE_UP_SETTING_AVAILABLE_RES_NAME = - "config_swipe_up_gesture_setting_available"; - private static final String SWIPE_UP_ENABLED_DEFAULT_RES_NAME = - "config_swipe_up_gesture_default"; // We do not need any synchronization for this variable as its only written on UI thread. public static final MainThreadInitializedObject<OverviewInteractionState> INSTANCE = @@ -88,13 +83,13 @@ public class OverviewInteractionState { mUiHandler = new Handler(this::handleUiMessage); mBgHandler = new Handler(UiThreadHelper.getBackgroundLooper(), this::handleBgMessage); - if (getSystemBooleanRes(SWIPE_UP_SETTING_AVAILABLE_RES_NAME)) { + if (SwipeUpSetting.isSwipeUpSettingAvailable()) { mSwipeUpSettingObserver = new SwipeUpGestureEnabledSettingObserver(mUiHandler, context.getContentResolver()); mSwipeUpSettingObserver.register(); } else { mSwipeUpSettingObserver = null; - mSwipeUpEnabled = getSystemBooleanRes(SWIPE_UP_ENABLED_DEFAULT_RES_NAME); + mSwipeUpEnabled = SwipeUpSetting.isSwipeUpEnabledDefaultValue(); } } @@ -199,7 +194,7 @@ public class OverviewInteractionState { super(handler); mHandler = handler; mResolver = resolver; - defaultValue = getSystemBooleanRes(SWIPE_UP_ENABLED_DEFAULT_RES_NAME) ? 1 : 0; + defaultValue = SwipeUpSetting.isSwipeUpEnabledDefaultValue() ? 1 : 0; } public void register() { @@ -221,18 +216,6 @@ public class OverviewInteractionState { } } - private boolean getSystemBooleanRes(String resName) { - Resources res = Resources.getSystem(); - int resId = res.getIdentifier(resName, "bool", "android"); - - if (resId != 0) { - return res.getBoolean(resId); - } else { - Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?"); - return false; - } - } - private void resetHomeBounceSeenOnQuickstepEnabledFirstTime() { if (mSwipeUpEnabled && !Utilities.getPrefs(mContext).getBoolean( HAS_ENABLED_QUICKSTEP_ONCE, true)) { diff --git a/quickstep/src/com/android/quickstep/SwipeUpSetting.java b/quickstep/src/com/android/quickstep/SwipeUpSetting.java new file mode 100644 index 000000000..0f91f9775 --- /dev/null +++ b/quickstep/src/com/android/quickstep/SwipeUpSetting.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.quickstep; + +import android.content.res.Resources; +import android.util.Log; + +public final class SwipeUpSetting { + private static final String TAG = "SwipeUpSetting"; + + private static final String SWIPE_UP_SETTING_AVAILABLE_RES_NAME = + "config_swipe_up_gesture_setting_available"; + + private static final String SWIPE_UP_ENABLED_DEFAULT_RES_NAME = + "config_swipe_up_gesture_default"; + + private static boolean getSystemBooleanRes(String resName) { + Resources res = Resources.getSystem(); + int resId = res.getIdentifier(resName, "bool", "android"); + + if (resId != 0) { + return res.getBoolean(resId); + } else { + Log.e(TAG, "Failed to get system resource ID. Incompatible framework version?"); + return false; + } + } + + public static boolean isSwipeUpSettingAvailable() { + return getSystemBooleanRes(SWIPE_UP_SETTING_AVAILABLE_RES_NAME); + } + + public static boolean isSwipeUpEnabledDefaultValue() { + return getSystemBooleanRes(SWIPE_UP_ENABLED_DEFAULT_RES_NAME); + } +} |