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

Commit d3af1933 authored by Lorenzo Lucena Maguire's avatar Lorenzo Lucena Maguire
Browse files

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
parent 406a01df
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -11158,6 +11158,23 @@
    <!-- Summary text for double tap power for camera [CHAR LIMIT=160]-->
    <string name="double_tap_power_for_camera_summary">To quickly open camera, press the power button twice. Works from any screen.</string>
    <!-- Title text for double tap power gesture [CHAR LIMIT=80]-->
    <string name="double_tap_power_title">Double tap power button</string>
    <!-- Summary for double tap power settings [DO NOT TRANSLATE] -->
    <string name="double_tap_power_summary" translatable="false"><xliff:g id="double_tap_power_on_off" example="On">%1$s</xliff:g> / <xliff:g id="double_tap_power_actions" example="Access Wallet">%2$s</xliff:g></string>
    <!-- Switch label to enable/disable double tap power button gesture [CHAR LIMIT=60] -->
    <string name="double_tap_power_enabled">Use double tap</string>
    <!-- Category title for double tap power gesture [CHAR_LIMIT=80] -->
    <string name="double_tap_power_target_action_category">Double Tap Power Button</string>
    <!-- Double Tap Power Gesture camera launch action title [CHAR_LIMIT=60] -->
    <string name="double_tap_power_camera_action_title">Open Camera</string>
    <!-- Setting summary to describe double tap power button will open camera. [CHAR LIMIT=NONE] -->
    <string name="double_tap_power_camera_action_summary">Access Camera</string>
    <!-- Double Tap Power Gesture wallet launch action title [CHAR_LIMIT=60] -->
    <string name="double_tap_power_wallet_action_title">Open Wallet</string>
    <!-- Setting summary to describe double tap power button will open wallet. [CHAR LIMIT=NONE] -->
    <string name="double_tap_power_wallet_action_summary">Access Wallet</string>
    <!-- Title text for double twist for camera mode [CHAR LIMIT=60]-->
    <string name="double_twist_for_camera_mode_title">Flip camera for selfie</string>
+44 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2024 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.
  -->

<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:settings="http://schemas.android.com/apk/res-auto"
    android:title="@string/double_tap_power_title">
    <com.android.settingslib.widget.IllustrationPreference
        android:key="gesture_double_tap_power_video"
        settings:searchable="false"
        settings:lottie_rawRes="@drawable/quickly_open_camera"/>

    <com.android.settingslib.widget.MainSwitchPreference
        android:key="gesture_double_tap_power_enabled_main_switch"
        android:title="@string/double_tap_power_enabled"
        settings:keywords="@string/keywords_gesture"
        settings:controller="com.android.settings.gestures.DoubleTapPowerMainSwitchPreferenceController"/>
    <PreferenceCategory
        android:key="gesture_double_tap_power_actions"
        android:title="@string/double_tap_power_target_action_category">
        <com.android.settingslib.widget.SelectorWithWidgetPreference
            android:key="gesture_double_power_tap_camera"
            android:title="@string/double_tap_power_camera_action_title"
            settings:controller="com.android.settings.gestures.DoubleTapPowerForCameraPreferenceController"/>
        <com.android.settingslib.widget.SelectorWithWidgetPreference
            android:key="gesture_double_power_tap_wallet"
            android:title="@string/double_tap_power_wallet_action_title"
            settings:controller="com.android.settings.gestures.DoubleTapPowerForWalletPreferenceController"/>
    </PreferenceCategory>
</PreferenceScreen>
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@

    <Preference
        android:key="gesture_double_tap_power_input_summary"
        android:title="@string/double_tap_power_for_camera_title"
        android:title="@string/double_tap_power_title"
        android:fragment="com.android.settings.gestures.DoubleTapPowerSettings"
        settings:searchable="false"
        settings:controller="com.android.settings.gestures.DoubleTapPowerPreferenceController" />
+42 −12
Original line number Diff line number Diff line
@@ -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) {
        if (!android.service.quickaccesswallet.Flags.launchWalletOptionOnPowerDoubleTap()) {
            return context.getResources()
                .getBoolean(com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled);
                    .getBoolean(
                            com.android.internal.R.bool.config_cameraDoubleTapPowerGestureEnabled);
        }
        return DoubleTapPowerSettingsUtils.isDoubleTapPowerButtonGestureAvailable(context);
    }

    @Override
@@ -48,9 +54,21 @@ 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() {
        if (!android.service.quickaccesswallet.Flags.launchWalletOptionOnPowerDoubleTap()) {
            final boolean isCameraDoubleTapPowerGestureEnabled =
                    Settings.Secure.getInt(
                                    mContext.getContentResolver(),
@@ -62,4 +80,16 @@ public class DoubleTapPowerPreferenceController extends BasePreferenceController
                            ? 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);
    }
}
+22 −2
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ package com.android.settings.gestures;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.SearchIndexableResource;

import androidx.annotation.NonNull;

import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
@@ -27,6 +30,8 @@ import com.android.settings.overlay.FeatureFactory;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;

import java.util.List;

@SearchIndexable
public class DoubleTapPowerSettings extends DashboardFragment {

@@ -56,9 +61,24 @@ public class DoubleTapPowerSettings extends DashboardFragment {

    @Override
    protected int getPreferenceScreenResId() {
        return R.xml.double_tap_power_to_open_camera_settings;
        return android.service.quickaccesswallet.Flags.launchWalletOptionOnPowerDoubleTap()
                ? R.xml.double_tap_power_settings
                : R.xml.double_tap_power_to_open_camera_settings;
    }

    public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
            new BaseSearchIndexProvider(R.xml.double_tap_power_to_open_camera_settings);
            new BaseSearchIndexProvider() {
                @Override
                @NonNull
                public List<SearchIndexableResource> getXmlResourcesToIndex(
                        @NonNull Context context, boolean enabled) {
                    final SearchIndexableResource sir = new SearchIndexableResource(context);
                    sir.xmlResId =
                            android.service.quickaccesswallet.Flags
                                            .launchWalletOptionOnPowerDoubleTap()
                                    ? R.xml.double_tap_power_settings
                                    : R.xml.double_tap_power_to_open_camera_settings;
                    return List.of(sir);
                }
            };
}
Loading