Merge "Rename panic gesture to emergency gesture in Settings"

This commit is contained in:
Fan Zhang
2020-10-28 17:02:21 +00:00
committed by Android (Google) Code Review
9 changed files with 76 additions and 75 deletions

View File

@@ -462,11 +462,11 @@
<!-- Whether to show Smooth Display feature in Settings Options -->
<bool name="config_show_smooth_display">false</bool>
<!-- Whether to show panic button gesture in Settings -->
<bool name="config_show_panic_gesture_settings">true</bool>
<!-- Whether to show emergency gesture in Settings -->
<bool name="config_show_emergency_gesture_settings">true</bool>
<!-- Optional package name if another 1p app wants to take over the panic settings UI -->
<string name="panic_gesture_settings_package"></string>
<!-- Optional package name if another 1p app wants to take over the emergency gesture settings UI -->
<string name="emergency_gesture_settings_package"></string>
<!-- Whether to show the Preference for Adaptive connectivity -->
<bool name="config_show_adaptive_connectivity">false</bool>

View File

@@ -11049,19 +11049,19 @@
<string name="ambient_display_tap_screen_summary">To check time, notifications, and other info, tap your screen.</string>
<!-- Preference title to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
<string name="panic_gesture_screen_title">Panic button</string>
<string name="emergency_gesture_screen_title">Emergency SOS</string>
<!-- Preference title to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
<string name="panic_gesture_entrypoint_summary">Managed by <xliff:g id="app_name" example="Emergency Info">%1$s</xliff:g></string>
<string name="emergency_gesture_entrypoint_summary">Managed by <xliff:g id="app_name" example="Emergency Info">%1$s</xliff:g></string>
<!-- Preference summary to enable feature for calling emergency services at panic/distress moments[CHAR_LIMIT=NONE]-->
<string name="panic_gesture_screen_summary">Start the emergency SOS actions by pressing the power button quickly 5 times.</string>
<string name="emergency_gesture_screen_summary">Start the emergency SOS actions by pressing the power button quickly 5 times.</string>
<!-- Preference title to enable generating noisy sound before calling emergency services at panic/distress moments[CHAR_LIMIT=60]-->
<string name="panic_gesture_sound_setting_title">Warning sound</string>
<string name="emergency_gesture_sound_setting_title">Warning sound</string>
<!-- Preference summary to enable generating noisy sound before calling emergency services at panic/distress moments[CHAR_LIMIT=NONE]-->
<string name="panic_gesture_sound_setting_summary">Alert before starting the actions</string>
<string name="emergency_gesture_sound_setting_summary">Alert before starting the actions</string>
<!-- Title text for swiping downwards on fingerprint sensor for notifications [CHAR LIMIT=80]-->
<string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string>

View File

@@ -18,29 +18,29 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:title="@string/panic_gesture_screen_title">
android:title="@string/emergency_gesture_screen_title">
<com.android.settings.widget.VideoPreference
android:key="panic_button_screen_video"
android:key="emergency_gesture_screen_video"
app:animation="@raw/gesture_double_tap"
app:preview="@drawable/gesture_double_tap"/>
<SwitchPreference
android:key="gesture_panic_button"
android:title="@string/panic_gesture_screen_title"
android:summary="@string/panic_gesture_screen_summary"
android:key="gesture_emergency_button"
android:title="@string/emergency_gesture_screen_title"
android:summary="@string/emergency_gesture_screen_summary"
android:icon="@drawable/ic_hand_gesture"
app:keywords="@string/keywords_gesture"
app:controller="com.android.settings.gestures.PanicGesturePreferenceController"
app:controller="com.android.settings.gestures.EmergencyGesturePreferenceController"
app:allowDividerAbove="true"/>
<SwitchPreference
android:key="panic_gesture_sound"
android:key="emergency_gesture_sound"
android:icon="@drawable/ic_hearing"
android:title="@string/panic_gesture_sound_setting_title"
android:summary="@string/panic_gesture_sound_setting_summary"
android:title="@string/emergency_gesture_sound_setting_title"
android:summary="@string/emergency_gesture_sound_setting_summary"
app:keywords="@string/keywords_gesture"
app:controller="com.android.settings.gestures.PanicGestureSoundPreferenceController"
app:controller="com.android.settings.gestures.EmergencyGestureSoundPreferenceController"
app:allowDividerAbove="true"/>
</PreferenceScreen>

View File

@@ -21,10 +21,10 @@
android:title="@string/gesture_preference_title">
<Preference
android:key="gesture_panic_button_summary"
android:title="@string/panic_gesture_screen_title"
android:fragment="com.android.settings.gestures.PanicGestureSettings"
settings:controller="com.android.settings.gestures.PanicGesturePreferenceController" />
android:key="gesture_emergency_summary"
android:title="@string/emergency_gesture_screen_title"
android:fragment="com.android.settings.gestures.EmergencyGestureSettings"
settings:controller="com.android.settings.gestures.EmergencyGesturePreferenceController" />
<Preference
android:key="gesture_assist_input_summary"

View File

@@ -31,36 +31,36 @@ import androidx.preference.Preference;
import com.android.settings.R;
/**
* Preference controller for emergency sos gesture setting
* Preference controller for emergency gesture setting
*/
public class PanicGesturePreferenceController extends GesturePreferenceController {
private static final String TAG = "PanicGesturePreferenceC";
public class EmergencyGesturePreferenceController extends GesturePreferenceController {
private static final String TAG = "EmergencyGesturePref";
@VisibleForTesting
static final int ON = 1;
@VisibleForTesting
static final int OFF = 0;
@VisibleForTesting
static final String ACTION_PANIC_SETTINGS =
"com.android.settings.action.panic_settings";
static final String ACTION_EMERGENCY_GESTURE_SETTINGS =
"com.android.settings.action.emergency_gesture_settings";
@VisibleForTesting
Intent mIntent;
private boolean mUseCustomIntent;
private static final String PREF_KEY_VIDEO = "panic_button_screen_video";
private static final String PREF_KEY_VIDEO = "emergency_gesture_screen_video";
private static final String SECURE_KEY = Settings.Secure.EMERGENCY_GESTURE_ENABLED;
public PanicGesturePreferenceController(Context context, String key) {
public EmergencyGesturePreferenceController(Context context, String key) {
super(context, key);
final String panicSettingsPackageName = context.getResources().getString(
R.string.panic_gesture_settings_package);
if (!TextUtils.isEmpty(panicSettingsPackageName)) {
final String emergencyGestureSettingsPackageName = context.getResources().getString(
R.string.emergency_gesture_settings_package);
if (!TextUtils.isEmpty(emergencyGestureSettingsPackageName)) {
mUseCustomIntent = true;
// Use custom intent if it's configured and system can resolve it.
final Intent intent = new Intent(ACTION_PANIC_SETTINGS)
.setPackage(panicSettingsPackageName);
final Intent intent = new Intent(ACTION_EMERGENCY_GESTURE_SETTINGS)
.setPackage(emergencyGestureSettingsPackageName);
if (canResolveIntent(intent)) {
mIntent = intent;
}
@@ -80,7 +80,7 @@ public class PanicGesturePreferenceController extends GesturePreferenceControlle
@Override
public int getAvailabilityStatus() {
final boolean isConfigEnabled = mContext.getResources()
.getBoolean(R.bool.config_show_panic_gesture_settings);
.getBoolean(R.bool.config_show_emergency_gesture_settings);
if (!isConfigEnabled) {
return UNSUPPORTED_ON_DEVICE;
@@ -90,7 +90,7 @@ public class PanicGesturePreferenceController extends GesturePreferenceControlle
@Override
public boolean isSliceable() {
return TextUtils.equals(getPreferenceKey(), "gesture_panic_button");
return TextUtils.equals(getPreferenceKey(), "gesture_emergency_button");
}
@Override
@@ -102,13 +102,13 @@ public class PanicGesturePreferenceController extends GesturePreferenceControlle
public CharSequence getSummary() {
if (mUseCustomIntent) {
final String packageName = mContext.getResources().getString(
R.string.panic_gesture_settings_package);
R.string.emergency_gesture_settings_package);
try {
final PackageManager pm = mContext.getPackageManager();
final ApplicationInfo appInfo = pm.getApplicationInfo(
packageName, PackageManager.MATCH_DISABLED_COMPONENTS
| PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS);
return mContext.getString(R.string.panic_gesture_entrypoint_summary,
return mContext.getString(R.string.emergency_gesture_entrypoint_summary,
appInfo.loadLabel(pm));
} catch (Exception e) {
Log.d(TAG, "Failed to get custom summary, falling back.");

View File

@@ -25,16 +25,16 @@ import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
/**
* Settings page for emergency sos gesture
* Settings page for emergency gesture
*/
@SearchIndexable
public class PanicGestureSettings extends DashboardFragment {
public class EmergencyGestureSettings extends DashboardFragment {
private static final String TAG = "PanicGestureSettings";
private static final String TAG = "EmergencyGestureSetting";
@Override
protected int getPreferenceScreenResId() {
return R.xml.panic_gesture_settings;
return R.xml.emergency_gesture_settings;
}
@Override
@@ -48,12 +48,12 @@ public class PanicGestureSettings extends DashboardFragment {
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.panic_gesture_settings) {
new BaseSearchIndexProvider(R.xml.emergency_gesture_settings) {
@Override
protected boolean isPageSearchEnabled(Context context) {
final PanicGesturePreferenceController controller =
new PanicGesturePreferenceController(context,
"dummy_panic_gesture_pref_key");
final EmergencyGesturePreferenceController controller =
new EmergencyGesturePreferenceController(context,
"dummy_emergency_gesture_pref_key");
return !controller.isAvailable()
|| controller.shouldSuppressFromSearch();
}

View File

@@ -27,7 +27,7 @@ import com.android.settings.core.TogglePreferenceController;
/**
* Preference controller for emergency sos gesture setting
*/
public class PanicGestureSoundPreferenceController extends TogglePreferenceController {
public class EmergencyGestureSoundPreferenceController extends TogglePreferenceController {
@VisibleForTesting
static final int ON = 1;
@@ -36,13 +36,13 @@ public class PanicGestureSoundPreferenceController extends TogglePreferenceContr
private static final String SECURE_KEY = Settings.Secure.EMERGENCY_GESTURE_SOUND_ENABLED;
public PanicGestureSoundPreferenceController(Context context, String key) {
public EmergencyGestureSoundPreferenceController(Context context, String key) {
super(context, key);
}
private static boolean isGestureAvailable(Context context) {
return context.getResources()
.getBoolean(R.bool.config_show_panic_gesture_settings);
.getBoolean(R.bool.config_show_emergency_gesture_settings);
}
@Override

View File

@@ -16,8 +16,9 @@
package com.android.settings.gestures;
import static com.android.settings.gestures.PanicGesturePreferenceController.OFF;
import static com.android.settings.gestures.PanicGesturePreferenceController.ON;
import static com.android.settings.gestures.EmergencyGesturePreferenceController.ACTION_EMERGENCY_GESTURE_SETTINGS;
import static com.android.settings.gestures.EmergencyGesturePreferenceController.OFF;
import static com.android.settings.gestures.EmergencyGesturePreferenceController.ON;
import static com.google.common.truth.Truth.assertThat;
@@ -44,25 +45,25 @@ import org.robolectric.shadows.ShadowPackageManager;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.class)
public class PanicGesturePreferenceControllerTest {
public class EmergencyGesturePreferenceControllerTest {
private static final String TEST_PKG_NAME = "test_pkg";
private static final String TEST_CLASS_NAME = "name";
private static final Intent SETTING_INTENT = new Intent(
PanicGesturePreferenceController.ACTION_PANIC_SETTINGS).setPackage(TEST_PKG_NAME);
private static final Intent SETTING_INTENT = new Intent(ACTION_EMERGENCY_GESTURE_SETTINGS)
.setPackage(TEST_PKG_NAME);
private Context mContext;
private ContentResolver mContentResolver;
private ShadowPackageManager mPackageManager;
private PanicGesturePreferenceController mController;
private static final String PREF_KEY = "gesture_panic_button";
private EmergencyGesturePreferenceController mController;
private static final String PREF_KEY = "gesture_emergency_button";
@Before
public void setUp() {
mContext = ApplicationProvider.getApplicationContext();
mContentResolver = mContext.getContentResolver();
mPackageManager = Shadows.shadowOf(mContext.getPackageManager());
mController = new PanicGesturePreferenceController(mContext, PREF_KEY);
mController = new EmergencyGesturePreferenceController(mContext, PREF_KEY);
}
@After
@@ -80,14 +81,14 @@ public class PanicGesturePreferenceControllerTest {
mPackageManager.addResolveInfoForIntent(SETTING_INTENT, info);
SettingsShadowResources.overrideResource(
R.bool.config_show_panic_gesture_settings,
R.bool.config_show_emergency_gesture_settings,
Boolean.TRUE);
SettingsShadowResources.overrideResource(
R.string.panic_gesture_settings_package,
R.string.emergency_gesture_settings_package,
TEST_PKG_NAME);
mController = new PanicGesturePreferenceController(mContext, PREF_KEY);
mController = new EmergencyGesturePreferenceController(mContext, PREF_KEY);
assertThat(mController.mIntent).isNotNull();
}
@@ -95,16 +96,16 @@ public class PanicGesturePreferenceControllerTest {
@Test
public void isAvailable_configIsTrue_shouldReturnTrue() {
SettingsShadowResources.overrideResource(
R.bool.config_show_panic_gesture_settings,
R.bool.config_show_emergency_gesture_settings,
Boolean.TRUE);
assertThat(mController.isAvailable()).isTrue();
}
@Test
public void isAvailable_configIsTrue_shouldReturnFalse() {
public void isAvailable_configIsFalse_shouldReturnFalse() {
SettingsShadowResources.overrideResource(
R.bool.config_show_panic_gesture_settings,
R.bool.config_show_emergency_gesture_settings,
Boolean.FALSE);
assertThat(mController.isAvailable()).isFalse();
@@ -114,7 +115,7 @@ public class PanicGesturePreferenceControllerTest {
public void isChecked_configIsNotSet_shouldReturnTrue() {
// Set the setting to be enabled.
Settings.Secure.putInt(mContentResolver, Settings.Secure.EMERGENCY_GESTURE_ENABLED, ON);
mController = new PanicGesturePreferenceController(mContext, PREF_KEY);
mController = new EmergencyGesturePreferenceController(mContext, PREF_KEY);
assertThat(mController.isChecked()).isTrue();
}
@@ -123,15 +124,15 @@ public class PanicGesturePreferenceControllerTest {
public void isChecked_configIsSet_shouldReturnFalse() {
// Set the setting to be disabled.
Settings.Secure.putInt(mContentResolver, Settings.Secure.EMERGENCY_GESTURE_ENABLED, OFF);
mController = new PanicGesturePreferenceController(mContext, PREF_KEY);
mController = new EmergencyGesturePreferenceController(mContext, PREF_KEY);
assertThat(mController.isChecked()).isFalse();
}
@Test
public void isSliceableCorrectKey_returnsTrue() {
final PanicGesturePreferenceController controller =
new PanicGesturePreferenceController(mContext, PREF_KEY);
final EmergencyGesturePreferenceController controller =
new EmergencyGesturePreferenceController(mContext, PREF_KEY);
assertThat(controller.isSliceable()).isTrue();
}

View File

@@ -16,8 +16,8 @@
package com.android.settings.gestures;
import static com.android.settings.gestures.PanicGesturePreferenceController.OFF;
import static com.android.settings.gestures.PanicGesturePreferenceController.ON;
import static com.android.settings.gestures.EmergencyGestureSoundPreferenceController.OFF;
import static com.android.settings.gestures.EmergencyGestureSoundPreferenceController.ON;
import static com.google.common.truth.Truth.assertThat;
@@ -39,17 +39,17 @@ import org.robolectric.annotation.Config;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = SettingsShadowResources.class)
public class PanicGestureSoundPreferenceControllerTest {
public class EmergencyGestureSoundPreferenceControllerTest {
private Context mContext;
private ContentResolver mContentResolver;
private PanicGestureSoundPreferenceController mController;
private EmergencyGestureSoundPreferenceController mController;
@Before
public void setUp() {
mContext = ApplicationProvider.getApplicationContext();
mContentResolver = mContext.getContentResolver();
mController = new PanicGestureSoundPreferenceController(mContext, "test_key");
mController = new EmergencyGestureSoundPreferenceController(mContext, "test_key");
}
@After
@@ -60,7 +60,7 @@ public class PanicGestureSoundPreferenceControllerTest {
@Test
public void isAvailable_configIsTrue_shouldReturnTrue() {
SettingsShadowResources.overrideResource(
R.bool.config_show_panic_gesture_settings,
R.bool.config_show_emergency_gesture_settings,
Boolean.TRUE);
assertThat(mController.isAvailable()).isTrue();
@@ -69,7 +69,7 @@ public class PanicGestureSoundPreferenceControllerTest {
@Test
public void isAvailable_configIsTrue_shouldReturnFalse() {
SettingsShadowResources.overrideResource(
R.bool.config_show_panic_gesture_settings,
R.bool.config_show_emergency_gesture_settings,
Boolean.FALSE);
assertThat(mController.isAvailable()).isFalse();