Merge "Remove demo button from animation and move to gesture navigation settings fragment" into main
This commit is contained in:
@@ -11540,6 +11540,9 @@ Data usage charges may apply.</string>
|
||||
<!-- Title for the screen to show all the gesture navigation settings [CHAR LIMIT=80] -->
|
||||
<string name="gesture_settings_activity_title">Gesture Navigation</string>
|
||||
|
||||
<!-- Title for the screen to show the gesture navigation tutorial [CHAR LIMIT=80] -->
|
||||
<string name="gesture_navigation_tutorial_title">Try a demo</string>
|
||||
|
||||
<!-- Title for the screen to show all the 2- and 3-button navigation settings. [CHAR LIMIT=80] -->
|
||||
<string name="button_navigation_settings_activity_title">Button navigation</string>
|
||||
|
||||
|
@@ -23,6 +23,17 @@
|
||||
android:title="@string/gesture_settings_activity_title"
|
||||
settings:keywords="@string/keywords_gesture_navigation_settings">
|
||||
|
||||
<PreferenceCategory
|
||||
android:persistent="false">
|
||||
|
||||
<com.android.settingslib.widget.ButtonPreference
|
||||
android:key="assistant_gesture_navigation_tutorial"
|
||||
android:title="@string/gesture_navigation_tutorial_title"
|
||||
android:icon="@drawable/tile_icon_show_taps"
|
||||
settings:buttonPreferenceSize="normal"
|
||||
settings:buttonPreferenceType="filled" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="assistant_gesture_category"
|
||||
android:persistent="false"
|
||||
|
@@ -18,6 +18,7 @@ package com.android.settings.gestures;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
@@ -30,6 +31,7 @@ import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.widget.LabeledSeekBarPreference;
|
||||
import com.android.settings.widget.SeekBarPreference;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.widget.ButtonPreference;
|
||||
|
||||
/**
|
||||
* A fragment to include all the settings related to Gesture Navigation mode.
|
||||
@@ -41,9 +43,14 @@ public class GestureNavigationSettingsFragment extends DashboardFragment {
|
||||
|
||||
public static final String GESTURE_NAVIGATION_SETTINGS =
|
||||
"com.android.settings.GESTURE_NAVIGATION_SETTINGS";
|
||||
static final String ACTION_GESTURE_SANDBOX = "com.android.quickstep.action.GESTURE_SANDBOX";
|
||||
|
||||
private static final String LEFT_EDGE_SEEKBAR_KEY = "gesture_left_back_sensitivity";
|
||||
private static final String RIGHT_EDGE_SEEKBAR_KEY = "gesture_right_back_sensitivity";
|
||||
private static final String GESTURE_TUTORIAL_KEY = "assistant_gesture_navigation_tutorial";
|
||||
final Intent mLaunchTutorialIntent = new Intent(ACTION_GESTURE_SANDBOX)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra("use_tutorial_menu", true);
|
||||
|
||||
private WindowManager mWindowManager;
|
||||
private BackGestureIndicatorView mIndicatorView;
|
||||
@@ -75,6 +82,7 @@ public class GestureNavigationSettingsFragment extends DashboardFragment {
|
||||
|
||||
initSeekBarPreference(LEFT_EDGE_SEEKBAR_KEY);
|
||||
initSeekBarPreference(RIGHT_EDGE_SEEKBAR_KEY);
|
||||
initTutorialButton();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,6 +121,26 @@ public class GestureNavigationSettingsFragment extends DashboardFragment {
|
||||
return SettingsEnums.SETTINGS_GESTURE_NAV_BACK_SENSITIVITY_DLG;
|
||||
}
|
||||
|
||||
private void initTutorialButton() {
|
||||
final ButtonPreference pref = getPreferenceScreen().findPreference(GESTURE_TUTORIAL_KEY);
|
||||
if (pref == null) {
|
||||
return;
|
||||
}
|
||||
if (!isGestureTutorialAvailable()) {
|
||||
pref.setVisible(false);
|
||||
return;
|
||||
}
|
||||
pref.setOnClickListener(preference -> {
|
||||
startActivity(mLaunchTutorialIntent);
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isGestureTutorialAvailable() {
|
||||
Context context = getContext();
|
||||
return context != null
|
||||
&& mLaunchTutorialIntent.resolveActivity(context.getPackageManager()) != null;
|
||||
}
|
||||
|
||||
private void initSeekBarPreference(final String key) {
|
||||
final LabeledSeekBarPreference pref = getPreferenceScreen().findPreference(key);
|
||||
pref.setContinuousUpdates(true);
|
||||
|
@@ -78,15 +78,6 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
||||
|
||||
private static final String KEY_SHOW_A11Y_TUTORIAL_DIALOG = "show_a11y_tutorial_dialog_bool";
|
||||
|
||||
static final String LAUNCHER_PACKAGE_NAME = "com.google.android.apps.nexuslauncher";
|
||||
|
||||
static final String ACTION_GESTURE_SANDBOX = "com.android.quickstep.action.GESTURE_SANDBOX";
|
||||
|
||||
final Intent mLaunchSandboxIntent = new Intent(ACTION_GESTURE_SANDBOX)
|
||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra("use_tutorial_menu", true)
|
||||
.setPackage(LAUNCHER_PACKAGE_NAME);
|
||||
|
||||
private static final int MIN_LARGESCREEN_WIDTH_DP = 600;
|
||||
|
||||
private boolean mA11yTutorialDialogShown = false;
|
||||
@@ -133,7 +124,6 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
||||
mVideoPreference.applyDynamicColor();
|
||||
}
|
||||
setIllustrationVideo(mVideoPreference, getDefaultKey());
|
||||
setIllustrationClickListener(mVideoPreference, getDefaultKey());
|
||||
|
||||
migrateOverlaySensitivityToSettings(context, mOverlayManager);
|
||||
}
|
||||
@@ -150,6 +140,7 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
screen.removeAll();
|
||||
screen.addPreference(mVideoPreference);
|
||||
|
||||
addPreferencesFromResource(getPreferenceScreenResId());
|
||||
final List<BasePreferenceController> preferenceControllers = PreferenceControllerListHelper
|
||||
.getPreferenceControllersFromXml(getContext(), getPreferenceScreenResId());
|
||||
@@ -246,40 +237,9 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
||||
if (!android.provider.Flags.a11yStandaloneGestureEnabled()) {
|
||||
setGestureNavigationTutorialDialog(key);
|
||||
}
|
||||
setIllustrationClickListener(mVideoPreference, key);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isGestureTutorialAvailable() {
|
||||
Context context = getContext();
|
||||
return context != null
|
||||
&& mLaunchSandboxIntent.resolveActivity(context.getPackageManager()) != null;
|
||||
}
|
||||
|
||||
private void setIllustrationClickListener(IllustrationPreference videoPref,
|
||||
String systemNavKey) {
|
||||
|
||||
switch (systemNavKey) {
|
||||
case KEY_SYSTEM_NAV_GESTURAL:
|
||||
if (isGestureTutorialAvailable()){
|
||||
videoPref.setContentDescription(R.string.nav_tutorial_button_description);
|
||||
videoPref.setOnPreferenceClickListener(preference -> {
|
||||
startActivity(mLaunchSandboxIntent);
|
||||
return true;
|
||||
});
|
||||
} else {
|
||||
videoPref.setOnPreferenceClickListener(null);
|
||||
}
|
||||
|
||||
break;
|
||||
case KEY_SYSTEM_NAV_2BUTTONS:
|
||||
case KEY_SYSTEM_NAV_3BUTTONS:
|
||||
default:
|
||||
videoPref.setOnPreferenceClickListener(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void migrateOverlaySensitivityToSettings(Context context,
|
||||
IOverlayManager overlayManager) {
|
||||
if (!SystemNavigationPreferenceController.isGestureNavigationEnabled(context)) {
|
||||
@@ -338,12 +298,7 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
||||
String systemNavKey) {
|
||||
switch (systemNavKey) {
|
||||
case KEY_SYSTEM_NAV_GESTURAL:
|
||||
if (isGestureTutorialAvailable()) {
|
||||
videoPref.setLottieAnimationResId(
|
||||
R.raw.lottie_system_nav_fully_gestural_with_nav);
|
||||
} else {
|
||||
videoPref.setLottieAnimationResId(R.raw.lottie_system_nav_fully_gestural);
|
||||
}
|
||||
videoPref.setLottieAnimationResId(R.raw.lottie_system_nav_fully_gestural);
|
||||
break;
|
||||
case KEY_SYSTEM_NAV_2BUTTONS:
|
||||
videoPref.setLottieAnimationResId(R.raw.lottie_system_nav_2_button);
|
||||
|
Reference in New Issue
Block a user