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

Commit 5213fbce authored by Jason Chang's avatar Jason Chang Committed by Android (Google) Code Review
Browse files

Merge changes from topic "OHM-newUI-Sys-Gesture" into sc-dev

* changes:
  Update key visual changes for one handed mode settings
  Remove redundant swipe down notification and one handed sub settings
parents 38df9ce8 76d6d663
Loading
Loading
Loading
Loading
+14 −1
Original line number Original line Diff line number Diff line
@@ -11676,7 +11676,7 @@
    <string name="swipe_bottom_to_notifications_summary">Swipe down on the bottom edge of the screen to show your notifications.\nYou can\'t use one-handed mode when this feature is turned on.</string>
    <string name="swipe_bottom_to_notifications_summary">Swipe down on the bottom edge of the screen to show your notifications.\nYou can\'t use one-handed mode when this feature is turned on.</string>
    <!-- Preference and settings suggestion title text for one handed [CHAR LIMIT=60] -->
    <!-- Preference and settings suggestion title text for one handed [CHAR LIMIT=60] -->
    <string name="one_handed_title">One-Handed mode</string>
    <string name="one_handed_title">One-handed mode</string>
    <!-- Preference Switch for enabling one handed [CHAR LIMIT=60] -->
    <!-- Preference Switch for enabling one handed [CHAR LIMIT=60] -->
    <string name="one_handed_mode_enabled">Use one-handed mode</string>
    <string name="one_handed_mode_enabled">Use one-handed mode</string>
    <!-- Preference Switch for app taps to exit one handed [CHAR LIMIT=60] -->
    <!-- Preference Switch for app taps to exit one handed [CHAR LIMIT=60] -->
@@ -11691,6 +11691,19 @@
    <string name="one_handed_timeout_long">12 seconds</string>
    <string name="one_handed_timeout_long">12 seconds</string>
    <!-- Search keywords for "One-Handed" settings [CHAR_LIMIT=NONE] -->
    <!-- Search keywords for "One-Handed" settings [CHAR_LIMIT=NONE] -->
    <string name="keywords_one_handed">reachability</string>
    <string name="keywords_one_handed">reachability</string>
    <!-- Category title for one handed swipe down [CHAR_LIMIT=60] -->
    <string name="one_handed_mode_swipe_down_category">Swipe down to</string>
    <!-- One-handed mode Intro Text [CHAR_LIMIT=NONE] -->
    <string name="one_handed_mode_intro_text">To use one handed mode, swipe down from the bottom edge of the screen. To use this feature, make sure gesture navigation is turned on in system navigation settings.</string>
    <!-- One-handed mode pull down screen into reach action title [CHAR_LIMIT=60] -->
    <string name="one_handed_action_pull_down_screen_title">Pull screen into reach</string>
    <!-- One-handed mode pull down screen into reach action title [CHAR_LIMIT=NONE] -->
    <string name="one_handed_action_pull_down_screen_summary">The top of the screen will move into reach of your thumb.</string>
    <!-- One-handed mode show notification action [CHAR_LIMIT=60] -->
    <string name="one_handed_action_show_notification_title">Show notifications</string>
    <!-- One-handed mode show notification action [CHAR_LIMIT=NONE] -->
    <string name="one_handed_action_show_notification_summary">Notification and settings will appear.</string>
    <!-- One-handed mode Intro text for gesture navigation [CHAR_LIMIT=NONE] -->
    <!-- Summary text for ambient display double tap [CHAR LIMIT=NONE]-->
    <!-- Summary text for ambient display double tap [CHAR LIMIT=NONE]-->
    <string name="ambient_display_summary">To check time, notifications, and other info, double-tap your screen.</string>
    <string name="ambient_display_summary">To check time, notifications, and other info, double-tap your screen.</string>
+0 −7
Original line number Original line Diff line number Diff line
@@ -33,13 +33,6 @@
        settings:searchable="false"
        settings:searchable="false"
        settings:controller="com.android.settings.gestures.SwipeToNotificationPreferenceController" />
        settings:controller="com.android.settings.gestures.SwipeToNotificationPreferenceController" />


    <Preference
        android:key="gesture_swipe_bottom_to_notification"
        android:title="@string/swipe_bottom_to_notifications_title"
        android:fragment="com.android.settings.gestures.SwipeBottomToNotificationSettings"
        settings:searchable="false"
        settings:controller="com.android.settings.gestures.SwipeBottomToNotificationPreferenceController" />

    <Preference
    <Preference
        android:key="gesture_double_tap_power_input_summary"
        android:key="gesture_double_tap_power_input_summary"
        android:title="@string/double_tap_power_for_camera_title"
        android:title="@string/double_tap_power_for_camera_title"
+26 −17
Original line number Original line Diff line number Diff line
@@ -21,12 +21,6 @@
    android:persistent="false"
    android:persistent="false"
    android:title="@string/one_handed_title">
    android:title="@string/one_handed_title">


    <com.android.settingslib.widget.MainSwitchPreference
        android:key="gesture_one_handed_mode_enabled"
        android:title="@string/one_handed_mode_enabled"
        settings:keywords="@string/keywords_one_handed"
        settings:controller="com.android.settings.gestures.OneHandedEnablePreferenceController"/>

    <com.android.settingslib.widget.LayoutPreference
    <com.android.settingslib.widget.LayoutPreference
        android:key="one_handed_header"
        android:key="one_handed_header"
        android:layout="@layout/one_handed_header"
        android:layout="@layout/one_handed_header"
@@ -35,16 +29,31 @@
        settings:allowDividerBelow="false"
        settings:allowDividerBelow="false"
        settings:searchable="false"/>
        settings:searchable="false"/>


    <SwitchPreference
    <com.android.settingslib.widget.MainSwitchPreference
        android:key="gesture_app_taps_to_exit"
        android:key="gesture_one_handed_mode_enabled_main_switch"
        android:title="@string/one_handed_app_taps_to_exit"
        android:title="@string/one_handed_mode_enabled"
        settings:controller="com.android.settings.gestures.OneHandedAppTapsExitPreferenceController"/>
        settings:keywords="@string/keywords_one_handed"
        settings:controller="com.android.settings.gestures.OneHandedMainSwitchPreferenceController"/>

    <com.android.settingslib.widget.TopIntroPreference
        android:key="gesture_one_handed_mode_intro_text"
        android:title="@string/one_handed_mode_intro_text"/>


    <ListPreference
    <PreferenceCategory
        android:key="gesture_one_handed_timeout"
        android:key="gesture_one_handed_mode_swipe_down"
        android:entries="@array/one_handed_timeout_title"
        android:title="@string/one_handed_mode_swipe_down_category">
        android:entryValues="@array/one_handed_timeout_values"

        android:persistent="false"
        <com.android.settingslib.widget.RadioButtonPreference
        android:title="@string/one_handed_timeout_title"
            android:key="gesture_one_handed_action_pull_screen_down"
        settings:controller="com.android.settings.gestures.OneHandedTimeoutPreferenceController"/>
            android:title="@string/one_handed_action_pull_down_screen_title"
            android:summary="@string/one_handed_action_pull_down_screen_summary"
            settings:controller="com.android.settings.gestures.OneHandedActionPullDownPrefController"/>

        <com.android.settingslib.widget.RadioButtonPreference
            android:key="gesture_one_handed_action_show_notification"
            android:title="@string/one_handed_action_show_notification_title"
            android:summary="@string/one_handed_action_show_notification_summary"
            settings:controller="com.android.settings.gestures.OneHandedActionShowNotificationPrefController"/>

    </PreferenceCategory>
</PreferenceScreen>
</PreferenceScreen>
+0 −38
Original line number Original line Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2020 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/swipe_bottom_to_notifications_title">

    <com.android.settingslib.widget.LayoutPreference
        android:key="one_handed_header"
        android:layout="@layout/one_handed_header"
        android:persistent="false"
        android:selectable="false"
        settings:allowDividerBelow="false"
        settings:searchable="false"/>

    <SwitchPreference
        android:key="gesture_swipe_bottom_to_notification"
        android:title="@string/swipe_bottom_to_notifications_title"
        android:summary="@string/swipe_bottom_to_notifications_summary"
        settings:controller="com.android.settings.gestures.SwipeBottomToNotificationPreferenceController"
        settings:allowDividerAbove="true" />

</PreferenceScreen>
+38 −31
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (C) 2020 The Android Open Source Project
 * Copyright (C) 2021 The Android Open Source Project
 *
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * you may not use this file except in compliance with the License.
@@ -22,59 +22,59 @@ import android.net.Uri;
import androidx.preference.Preference;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.PreferenceScreen;


import com.android.settings.core.TogglePreferenceController;
import com.android.settings.core.BasePreferenceController;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;
import com.android.settingslib.core.lifecycle.events.OnStop;
import com.android.settingslib.widget.RadioButtonPreference;


/**
/**
 * The Controller to handle app taps to exit of one-handed mode
 * The controller to handle one-handed mode pull screen into reach preference.
 */
 **/
public class OneHandedAppTapsExitPreferenceController extends TogglePreferenceController implements
public class OneHandedActionPullDownPrefController extends BasePreferenceController
        LifecycleObserver, OnStart, OnStop, OneHandedSettingsUtils.TogglesCallback {
        implements OneHandedSettingsUtils.TogglesCallback, LifecycleObserver, OnStart, OnStop {


    private final OneHandedSettingsUtils mUtils;
    private final OneHandedSettingsUtils mUtils;


    private Preference mPreference;
    private Preference mPreference;


    public OneHandedAppTapsExitPreferenceController(Context context, String key) {
    public OneHandedActionPullDownPrefController(Context context, String key) {
        super(context, key);
        super(context, key);

        mUtils = new OneHandedSettingsUtils(context);
        mUtils = new OneHandedSettingsUtils(context);
    }


        // By default, app taps to stop one-handed is enabled, this will get default value once.
    @Override
        OneHandedSettingsUtils.setTapsAppToExitEnabled(mContext, isChecked());
    public void updateState(Preference preference) {
        super.updateState(preference);
        if (preference instanceof RadioButtonPreference) {
            ((RadioButtonPreference) preference).setChecked(
                    !OneHandedSettingsUtils.isSwipeDownNotificationEnabled(mContext));
        }
    }
    }


    @Override
    @Override
    public int getAvailabilityStatus() {
    public int getAvailabilityStatus() {
        return OneHandedSettingsUtils.isOneHandedModeEnabled(mContext)
        return  (OneHandedSettingsUtils.isSupportOneHandedMode()
                && OneHandedSettingsUtils.canEnableController(mContext))
                ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
                ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
    }
    }


    @Override
    @Override
    public void displayPreference(PreferenceScreen screen) {
    public boolean handlePreferenceTreeClick(Preference preference) {
        super.displayPreference(screen);
        if (!getPreferenceKey().equals(preference.getKey())) {
        mPreference = screen.findPreference(getPreferenceKey());
            return false;
        }
        }

        OneHandedSettingsUtils.setSwipeDownNotificationEnabled(mContext, false);
    @Override
        if (preference instanceof RadioButtonPreference) {
    public void updateState(Preference preference) {
            ((RadioButtonPreference) preference).setChecked(true);
        super.updateState(preference);

        final int availabilityStatus = getAvailabilityStatus();
        preference.setEnabled(
                availabilityStatus == AVAILABLE || availabilityStatus == AVAILABLE_UNSEARCHABLE);
        }
        }

        return true;
    @Override
    public boolean setChecked(boolean isChecked) {
        return OneHandedSettingsUtils.setTapsAppToExitEnabled(mContext, isChecked);
    }
    }


    @Override
    @Override
    public boolean isChecked() {
    public void displayPreference(PreferenceScreen screen) {
        return OneHandedSettingsUtils.isTapsAppToExitEnabled(mContext);
        super.displayPreference(screen);
        mPreference = screen.findPreference(getPreferenceKey());
    }
    }


    @Override
    @Override
@@ -89,6 +89,13 @@ public class OneHandedAppTapsExitPreferenceController extends TogglePreferenceCo


    @Override
    @Override
    public void onChange(Uri uri) {
    public void onChange(Uri uri) {
        if (mPreference == null) {
            return;
        }
        if (uri.equals(OneHandedSettingsUtils.ONE_HANDED_MODE_ENABLED_URI)) {
            mPreference.setEnabled(OneHandedSettingsUtils.canEnableController(mContext));
        } else if (uri.equals(OneHandedSettingsUtils.SHOW_NOTIFICATION_ENABLED_URI)) {
            updateState(mPreference);
            updateState(mPreference);
        }
        }
    }
    }
}
Loading