Merge "(2/n) Stop user from enabling OHM setting if user is using 3-button mode" into sc-dev am: 2cc1c91601
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14235150 Change-Id: I3161025c6c61529213cf99b38306ca287f657a51
This commit is contained in:
@@ -19,7 +19,6 @@ package com.android.settings.gestures;
|
||||
import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreferenceController;
|
||||
|
||||
/**
|
||||
@@ -33,9 +32,8 @@ public class OneHandedEnablePreferenceController extends SettingsMainSwitchPrefe
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return OneHandedSettingsUtils.isSupportOneHandedMode()
|
||||
? BasePreferenceController.AVAILABLE
|
||||
: BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
return OneHandedSettingsUtils.isFeatureAvailable(mContext)
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -176,6 +176,28 @@ public class OneHandedSettingsUtils {
|
||||
sCurrentUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get NavigationBar mode flag from Settings provider.
|
||||
* @param context App context
|
||||
* @return Navigation bar mode:
|
||||
* 0 = 3 button
|
||||
* 1 = 2 button
|
||||
* 2 = fully gestural
|
||||
*/
|
||||
public static int getNavigationBarMode(Context context) {
|
||||
return Settings.Secure.getIntForUser(context.getContentResolver(),
|
||||
Settings.Secure.NAVIGATION_MODE, 2 /* fully gestural */, sCurrentUserId);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param context App context
|
||||
* @return Support One-Handed mode feature or not.
|
||||
*/
|
||||
public static boolean isFeatureAvailable(Context context) {
|
||||
return isSupportOneHandedMode() && getNavigationBarMode(context) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers callback for observing Settings.Secure.ONE_HANDED_MODE_ENABLED state.
|
||||
* @param callback for state changes
|
||||
|
||||
@@ -33,7 +33,8 @@ public class SwipeBottomToNotificationPreferenceController extends TogglePrefere
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return OneHandedSettingsUtils.isSupportOneHandedMode() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
return OneHandedSettingsUtils.isFeatureAvailable(mContext)
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user