Support wallet launch in Double Tap Power Gesture Settings
Modify Double Tap Power Gesture Settings screen to be able to set the
gesture to launch the wallet.
If the feature flag is disabled, the
Double Tap Power Gesture Settings screen defaults to the current
screen ("Quickly open camera"), which only provides the option to open the camera upon detecting the
gesture.
If the feature flag is enabled, the Double Tap Power Gesture Settings
screen defaults to the new "Double Tap Power Button" screen, which
provides the option to open the camera, the wallet, or neither upon
detecting the gesture.
Android Settings Feature Request: b/380287172
Bug: 378131008
Test: manual tested screen alternates based on feature flag
Test: atest DoubleTapPowerSettingsTest
Test: atest DoubleTapPowerPreferenceControllerTest
Test: atest DoubleTapPowerToOpenCameraPreferenceControllerTest
FLAG: android.service.quickaccesswallet.launch_wallet_option_on_power_double_tap
Change-Id: I1fc05ab3cfee2e86a80a1756655c368aae16747c
This commit is contained in:
@@ -23,6 +23,8 @@ import android.content.SharedPreferences;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.BasePreferenceController;
|
||||
@@ -39,8 +41,12 @@ public class DoubleTapPowerPreferenceController extends BasePreferenceController
|
||||
}
|
||||
|
||||
private static boolean isGestureAvailable(@NonNull Context context) {
|
||||
return context.getResources()
|
||||
.getBoolean(com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled);
|
||||
if (!android.service.quickaccesswallet.Flags.launchWalletOptionOnPowerDoubleTap()) {
|
||||
return context.getResources()
|
||||
.getBoolean(
|
||||
com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled);
|
||||
}
|
||||
return DoubleTapPowerSettingsUtils.isDoubleTapPowerButtonGestureAvailable(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,18 +54,42 @@ public class DoubleTapPowerPreferenceController extends BasePreferenceController
|
||||
return isGestureAvailable(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(@NonNull PreferenceScreen screen) {
|
||||
if (!android.service.quickaccesswallet.Flags.launchWalletOptionOnPowerDoubleTap()) {
|
||||
final Preference preference = screen.findPreference(getPreferenceKey());
|
||||
if (preference != null) {
|
||||
preference.setTitle(R.string.double_tap_power_for_camera_title);
|
||||
}
|
||||
}
|
||||
super.displayPreference(screen);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public CharSequence getSummary() {
|
||||
final boolean isCameraDoubleTapPowerGestureEnabled =
|
||||
Settings.Secure.getInt(
|
||||
mContext.getContentResolver(),
|
||||
CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
|
||||
DoubleTapPowerToOpenCameraPreferenceController.ON)
|
||||
== DoubleTapPowerToOpenCameraPreferenceController.ON;
|
||||
return mContext.getText(
|
||||
isCameraDoubleTapPowerGestureEnabled
|
||||
? R.string.gesture_setting_on
|
||||
: R.string.gesture_setting_off);
|
||||
if (!android.service.quickaccesswallet.Flags.launchWalletOptionOnPowerDoubleTap()) {
|
||||
final boolean isCameraDoubleTapPowerGestureEnabled =
|
||||
Settings.Secure.getInt(
|
||||
mContext.getContentResolver(),
|
||||
CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED,
|
||||
DoubleTapPowerToOpenCameraPreferenceController.ON)
|
||||
== DoubleTapPowerToOpenCameraPreferenceController.ON;
|
||||
return mContext.getText(
|
||||
isCameraDoubleTapPowerGestureEnabled
|
||||
? R.string.gesture_setting_on
|
||||
: R.string.gesture_setting_off);
|
||||
}
|
||||
if (DoubleTapPowerSettingsUtils.isDoubleTapPowerButtonGestureEnabled(mContext)) {
|
||||
final CharSequence onString =
|
||||
mContext.getText(com.android.settings.R.string.gesture_setting_on);
|
||||
final CharSequence actionString =
|
||||
DoubleTapPowerSettingsUtils.isDoubleTapPowerButtonGestureForCameraLaunchEnabled(
|
||||
mContext)
|
||||
? mContext.getText(R.string.double_tap_power_camera_action_summary)
|
||||
: mContext.getText(R.string.double_tap_power_wallet_action_summary);
|
||||
return mContext.getString(R.string.double_tap_power_summary, onString, actionString);
|
||||
}
|
||||
return mContext.getText(com.android.settings.R.string.gesture_setting_off);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user