diff --git a/res/values/strings.xml b/res/values/strings.xml
index fb95aa3bd39..7e363e6f238 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -9762,8 +9762,10 @@
Open by default
Open supported links
+ In the app
+ In your browser
- Allow web links to open in this app
+ Choose how to open web links for this app
Links to open in this app
diff --git a/res/xml/installed_app_launch_settings.xml b/res/xml/installed_app_launch_settings.xml
index 2268d5c9d98..ffd73bc78c8 100644
--- a/res/xml/installed_app_launch_settings.xml
+++ b/res/xml/installed_app_launch_settings.xml
@@ -19,9 +19,15 @@
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:title="@string/launch_by_default">
-
+
+
+
+
+
0);
}
+ private void setOpenByDefaultPreference(boolean openInApp) {
+ if (mOpenInBrowserSelector == null || mOpenInAppSelector == null) return;
+ mOpenInAppSelector.setChecked(openInApp);
+ mOpenInBrowserSelector.setChecked(!openInApp);
+ }
+
private void showVerifiedLinksDialog() {
final int linksNo = getLinksNumber(DOMAIN_STATE_VERIFIED);
if (linksNo == 0) {
@@ -360,9 +372,12 @@ public class AppLaunchSettings extends AppInfoBase implements
}
private void disabledPreference() {
- mMainSwitchPreference.updateStatus(false);
- mMainSwitchPreference.setSelectable(false);
- mMainSwitchPreference.setEnabled(false);
+ if (mOpenInAppSelector == null ||mOpenInBrowserSelector == null) return;
+ setOpenByDefaultPreference(false /* openInApp */);
+ mOpenInAppSelector.setSelectable(false);
+ mOpenInAppSelector.setEnabled(false);
+ mOpenInBrowserSelector.setSelectable(false);
+ mOpenInBrowserSelector.setEnabled(false);
mMainPreferenceCategory.setVisible(false);
}
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFragmentTest.java
index e9e20a4c9f6..e40f21c702e 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonFragmentTest.java
@@ -28,6 +28,10 @@ import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
+import android.provider.Flags;
import androidx.fragment.app.FragmentActivity;
import androidx.preference.PreferenceManager;
@@ -56,6 +60,8 @@ import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class AccessibilityButtonFragmentTest {
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Rule
public MockitoRule mMockitoRule = MockitoJUnit.rule();
@Spy
@@ -84,6 +90,7 @@ public class AccessibilityButtonFragmentTest {
}
@Test
+ @DisableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
public void onCreate_navigationGestureEnabled_setCorrectTitle() {
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
.thenReturn(NAV_BAR_MODE_GESTURAL);
@@ -96,7 +103,20 @@ public class AccessibilityButtonFragmentTest {
}
@Test
- public void onCreate_navigationGestureDisabled_setCorrectTitle() {
+ @EnableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void onCreate_navigationGestureEnabled_gestureFlag_setCorrectTitle() {
+ when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
+ .thenReturn(NAV_BAR_MODE_GESTURAL);
+
+ mFragment.onAttach(mContext);
+ mFragment.onCreate(Bundle.EMPTY);
+
+ assertThat(mFragment.getActivity().getTitle().toString()).isEqualTo(
+ mContext.getString(R.string.accessibility_button_title));
+ }
+
+ @Test
+ public void onCreate_navigationBarEnabled_setCorrectTitle() {
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
.thenReturn(NAV_BAR_MODE_2BUTTON);
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonGesturePreferenceControllerTest.java
index 39760566188..83517c302ce 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityButtonGesturePreferenceControllerTest.java
@@ -30,6 +30,10 @@ import static org.mockito.Mockito.when;
import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
+import android.platform.test.annotations.DisableFlags;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
+import android.provider.Flags;
import android.provider.Settings;
import androidx.preference.ListPreference;
@@ -48,6 +52,8 @@ import org.robolectric.RobolectricTestRunner;
@RunWith(RobolectricTestRunner.class)
public class AccessibilityButtonGesturePreferenceControllerTest {
+ @Rule
+ public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
@Rule
public final MockitoRule mockito = MockitoJUnit.rule();
@@ -67,6 +73,7 @@ public class AccessibilityButtonGesturePreferenceControllerTest {
}
@Test
+ @DisableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
public void getAvailabilityStatus_navigationGestureEnabled_returnAvailable() {
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
.thenReturn(NAV_BAR_MODE_GESTURAL);
@@ -74,6 +81,16 @@ public class AccessibilityButtonGesturePreferenceControllerTest {
assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
}
+ @Test
+ @EnableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void
+ getAvailabilityStatus_navigationGestureEnabled_gestureFlag_conditionallyUnavailable() {
+ when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
+ .thenReturn(NAV_BAR_MODE_GESTURAL);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(CONDITIONALLY_UNAVAILABLE);
+ }
+
@Test
public void getAvailabilityStatus_navigationGestureDisabled_returnConditionallyUnavailable() {
when(mResources.getInteger(com.android.internal.R.integer.config_navBarInteractionMode))
diff --git a/tests/robotests/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragmentTest.java
index b461cab3d04..414fe6333f5 100644
--- a/tests/robotests/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/shortcuts/EditShortcutsPreferenceFragmentTest.java
@@ -18,6 +18,7 @@ package com.android.settings.accessibility.shortcuts;
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_COMPONENT_NAME;
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
import static com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment.SHORTCUT_SETTINGS;
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_DEFERRED_SETUP;
@@ -36,6 +37,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
+import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings;
@@ -240,6 +242,7 @@ public class EditShortcutsPreferenceFragmentTest {
}
@Test
+ @DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
public void onSoftwareShortcutSettingChanged_softwareControllersUpdated() {
mFragmentScenario = createFragScenario(/* isInSuw= */ false, TARGET);
mFragmentScenario.moveToState(Lifecycle.State.CREATED);
@@ -256,6 +259,27 @@ public class EditShortcutsPreferenceFragmentTest {
}
@Test
+ @EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void onSoftwareShortcutSettingsChanged_softwareControllersUpdated() {
+ mFragmentScenario = createFragScenario(/* isInSuw= */ false, TARGET);
+ mFragmentScenario.moveToState(Lifecycle.State.CREATED);
+
+ ShortcutUtils.optInValueToSettings(
+ mContext, ShortcutConstants.UserShortcutType.SOFTWARE, TARGET);
+ ShadowLooper.runUiThreadTasksIncludingDelayedTasks();
+
+ mFragmentScenario.onFragment(fragment -> {
+ TwoStatePreference preference = fragment.findPreference(
+ mContext.getString(R.string.accessibility_shortcut_fab_pref));
+ assertThat(preference.isChecked()).isTrue();
+ preference = fragment.findPreference(
+ mContext.getString(R.string.accessibility_shortcut_gesture_pref));
+ assertThat(preference.isChecked()).isFalse();
+ });
+ }
+
+ @Test
+ @DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
public void onSoftwareShortcutModeChanged_softwareControllersUpdated() {
mFragmentScenario = createFragScenario(/* isInSuw= */ false, TARGET);
mFragmentScenario.moveToState(Lifecycle.State.CREATED);
@@ -309,6 +333,7 @@ public class EditShortcutsPreferenceFragmentTest {
}
@Test
+ @DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
public void fragmentResumed_enableTouchExploration_gestureShortcutOptionSummaryUpdated() {
String expectedSummary = StringUtil.getIcuPluralsString(mContext, 3,
R.string.accessibility_shortcut_edit_dialog_summary_gesture)
@@ -330,6 +355,26 @@ public class EditShortcutsPreferenceFragmentTest {
}
@Test
+ @EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void fragmentResumed_enableTouchExploration_gestureFlag_gestureSummaryUpdated() {
+ String expectedSummary = StringUtil.getIcuPluralsString(mContext, 3,
+ R.string.accessibility_shortcut_edit_dialog_summary_gesture);
+ mFragmentScenario = createFragScenario(/* isInSuw= */ false, TARGET);
+ mFragmentScenario.moveToState(Lifecycle.State.RESUMED);
+
+ ShadowAccessibilityManager am = shadowOf(
+ mContext.getSystemService(AccessibilityManager.class));
+ am.setTouchExplorationEnabled(true);
+
+ mFragmentScenario.onFragment(fragment -> {
+ Preference preference = fragment.findPreference(
+ mContext.getString(R.string.accessibility_shortcut_gesture_pref));
+ assertThat(preference.getSummary().toString()).isEqualTo(expectedSummary);
+ });
+ }
+
+ @Test
+ @DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
public void fragmentPaused_enableTouchExploration_gestureShortcutOptionSummaryNotUpdated() {
String expectedSummary = StringUtil.getIcuPluralsString(mContext, 2,
R.string.accessibility_shortcut_edit_dialog_summary_gesture)
@@ -350,6 +395,25 @@ public class EditShortcutsPreferenceFragmentTest {
});
}
+ @Test
+ @EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void fragmentPaused_enableTouchExploration_gestureFlag_gestureSummaryNotUpdated() {
+ String expectedSummary = StringUtil.getIcuPluralsString(mContext, 2,
+ R.string.accessibility_shortcut_edit_dialog_summary_gesture);
+ mFragmentScenario = createFragScenario(/* isInSuw= */ false, TARGET);
+ mFragmentScenario.moveToState(Lifecycle.State.RESUMED).moveToState(Lifecycle.State.STARTED);
+
+ ShadowAccessibilityManager am = shadowOf(
+ mContext.getSystemService(AccessibilityManager.class));
+ am.setTouchExplorationEnabled(true);
+
+ mFragmentScenario.onFragment(fragment -> {
+ Preference preference = fragment.findPreference(
+ mContext.getString(R.string.accessibility_shortcut_gesture_pref));
+ assertThat(preference.getSummary().toString()).isEqualTo(expectedSummary);
+ });
+ }
+
@Test
@EnableFlags(Flags.FLAG_A11Y_QS_SHORTCUT)
public void fragmentResumed_enableTouchExploration_qsShortcutOptionSummaryUpdated() {
@@ -441,7 +505,7 @@ public class EditShortcutsPreferenceFragmentTest {
assertThat(
PreferredShortcuts.retrieveUserShortcutType(
mContext, TARGET)
- ).isEqualTo(ShortcutConstants.UserShortcutType.SOFTWARE);
+ ).isEqualTo(SOFTWARE);
// Update the chosen shortcut type to Volume keys while the fragment is in the background
ShortcutUtils.optInValueToSettings(
mContext, ShortcutConstants.UserShortcutType.HARDWARE, TARGET);
@@ -461,7 +525,7 @@ public class EditShortcutsPreferenceFragmentTest {
assertThat(
PreferredShortcuts.retrieveUserShortcutType(
mContext, TARGET)
- ).isEqualTo(ShortcutConstants.UserShortcutType.SOFTWARE);
+ ).isEqualTo(SOFTWARE);
ShortcutUtils.optInValueToSettings(
mContext, ShortcutConstants.UserShortcutType.HARDWARE, TARGET);
diff --git a/tests/robotests/src/com/android/settings/accessibility/shortcuts/GestureShortcutOptionControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/shortcuts/GestureShortcutOptionControllerTest.java
index 1d46caef087..39535cb139a 100644
--- a/tests/robotests/src/com/android/settings/accessibility/shortcuts/GestureShortcutOptionControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/shortcuts/GestureShortcutOptionControllerTest.java
@@ -119,6 +119,7 @@ public class GestureShortcutOptionControllerTest {
}
@Test
+ @DisableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
public void getSummary_touchExplorationEnabled_notInSuw_verifySummary() {
enableTouchExploration(true);
mController.setInSetupWizard(false);
@@ -133,6 +134,19 @@ public class GestureShortcutOptionControllerTest {
assertThat(mController.getSummary().toString()).isEqualTo(expected);
}
+ @Test
+ @EnableFlags(Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void getSummary_touchExplorationEnabled_notInSuw_gestureFlag_verifySummary() {
+ enableTouchExploration(true);
+ mController.setInSetupWizard(false);
+ String expected = StringUtil.getIcuPluralsString(
+ mContext,
+ /* count= */ 3,
+ R.string.accessibility_shortcut_edit_dialog_summary_gesture);
+
+ assertThat(mController.getSummary().toString()).isEqualTo(expected);
+ }
+
@Test
public void getSummary_touchExplorationEnabled_inSuw_verifySummary() {
enableTouchExploration(true);