<!-- Title for accessibility preference screen for configuring vibrations. -->
<string name="accessibility_vibration_settings_title">Vibration</string>
<!-- Title for accessibility preference for configuring notification vibrations. -->
- <string name="accessibility_notification_vibration_title">Ring & notification vibration</string>
+ <string name="accessibility_notification_vibration_title">Notification vibration</string>
+ <!-- Title for accessibility preference for configuring ring vibrations. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_ring_vibration_title">Ring vibration</string>
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
<string name="accessibility_touch_vibration_title">Touch vibration</string>
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
<item quantity="other">Very long delay (<xliff:g id="click_delay_label" example="200">%1$d</xliff:g> ms)</item>
</plurals>
- <!-- Summary for vibration settings preference when notification vibration and haptic feedback intensity are set. [CHAR LIMIT=32] -->
- <string name="accessibility_vibration_summary">Ring <xliff:g id="summary_ring" example="Medium">%1$s</xliff:g>, touch <xliff:g id="summary_touch" example="High">%2$s</xliff:g></string>
+ <!-- Summary for vibration settings preference when notification vibration and haptic feedback intensity are set. [CHAR LIMIT=50] -->
+ <string name="accessibility_vibration_summary">Ring <xliff:g id="summary_ring" example="Medium">%1$s</xliff:g>, notification <xliff:g id="summary_notification" example="Low">%2$s</xliff:g>, touch <xliff:g id="summary_touch" example="High">%3$s</xliff:g></string>
<!-- Summary for vibration settings preference when ring & notification are set to off-->
<string name="accessibility_vibration_summary_off">Ring & notification set to off</string>
<!-- List of synonyms for touch vibration setting (where you get a haptic response for touching things on the screen), used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_touch_vibration">haptics, vibrate, screen, sensitivity</string>
- <!-- List of synonyms for ring and notification vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
- <string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity</string>
+ <!-- List of synonyms for ring vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
+ <string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity, ring</string>
+ <!-- List of synonyms for notification vibration setting (changes whether your phone vibrates when it shows a notification), used to match in settings search [CHAR LIMIT=NONE] -->
+ <string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
<!-- NFC Wi-Fi pairing/setup strings-->
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2018 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"
+ android:title="@string/accessibility_ring_vibration_title" />
android:title="@string/accessibility_vibration_settings_title">
<Preference
+ android:fragment="com.android.settings.accessibility.RingVibrationPreferenceFragment"
+ android:key="ring_vibration_preference_screen"
+ android:title="@string/accessibility_ring_vibration_title"
+ settings:keywords="@string/keywords_ring_vibration"
+ app:controller="com.android.settings.accessibility.RingVibrationIntensityPreferenceController" />
+
+ <Preference
android:fragment="com.android.settings.accessibility.NotificationVibrationPreferenceFragment"
android:key="notification_vibration_preference_screen"
android:title="@string/accessibility_notification_vibration_title"
- settings:keywords="@string/keywords_ring_vibration"
+ settings:keywords="@string/keywords_notification_vibration"
app:controller="com.android.settings.accessibility.NotificationVibrationIntensityPreferenceController" />
<Preference
final Context context = getContext();
final Vibrator vibrator = context.getSystemService(Vibrator.class);
- final int ringIntensity = Settings.System.getInt(context.getContentResolver(),
- Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
- vibrator.getDefaultNotificationVibrationIntensity());
+ int ringIntensity = Settings.System.getInt(context.getContentResolver(),
+ Settings.System.RING_VIBRATION_INTENSITY,
+ vibrator.getDefaultRingVibrationIntensity());
+ if (Settings.System.getInt(context.getContentResolver(),
+ Settings.System.VIBRATE_WHEN_RINGING, 0) == 0) {
+ ringIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
+ }
CharSequence ringIntensityString =
VibrationIntensityPreferenceController.getIntensityString(context, ringIntensity);
- final int touchIntensity = Settings.System.getInt(context.getContentResolver(),
+ int notificationIntensity = Settings.System.getInt(context.getContentResolver(),
+ Settings.System.NOTIFICATION_VIBRATION_INTENSITY,
+ vibrator.getDefaultNotificationVibrationIntensity());
+ CharSequence notificationIntensityString =
+ VibrationIntensityPreferenceController.getIntensityString(context,
+ notificationIntensity);
+
+ int touchIntensity = Settings.System.getInt(context.getContentResolver(),
Settings.System.HAPTIC_FEEDBACK_INTENSITY,
vibrator.getDefaultHapticFeedbackIntensity());
+ if (Settings.System.getInt(context.getContentResolver(),
+ Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) == 0) {
+ touchIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
+ }
CharSequence touchIntensityString =
VibrationIntensityPreferenceController.getIntensityString(context, touchIntensity);
mVibrationPreferenceScreen = findPreference(VIBRATION_PREFERENCE_SCREEN);
}
- if (ringIntensity == touchIntensity) {
+ if (ringIntensity == touchIntensity && ringIntensity == notificationIntensity) {
mVibrationPreferenceScreen.setSummary(ringIntensityString);
} else {
mVibrationPreferenceScreen.setSummary(
getString(R.string.accessibility_vibration_summary,
- ringIntensityString, touchIntensityString));
+ ringIntensityString,
+ notificationIntensityString,
+ touchIntensityString));
}
}
static final String PREF_KEY = "touch_vibration_preference_screen";
public HapticFeedbackIntensityPreferenceController(Context context) {
- super(context, PREF_KEY, Settings.System.HAPTIC_FEEDBACK_INTENSITY);
+ super(context, PREF_KEY, Settings.System.HAPTIC_FEEDBACK_INTENSITY,
+ Settings.System.HAPTIC_FEEDBACK_ENABLED);
}
@Override
static final String PREF_KEY = "notification_vibration_preference_screen";
public NotificationVibrationIntensityPreferenceController(Context context) {
- super(context, PREF_KEY, Settings.System.NOTIFICATION_VIBRATION_INTENSITY);
+ super(context, PREF_KEY, Settings.System.NOTIFICATION_VIBRATION_INTENSITY, "");
}
@Override
}
@Override
+ protected String getVibrationEnabledSetting() {
+ return "";
+ }
+
+ @Override
protected int getPreviewVibrationAudioAttributesUsage() {
return AudioAttributes.USAGE_NOTIFICATION;
}
--- /dev/null
+/*
+ * Copyright (C) 2018 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.
+ */
+
+package com.android.settings.accessibility;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+
+public class RingVibrationIntensityPreferenceController
+ extends VibrationIntensityPreferenceController {
+
+ @VisibleForTesting
+ static final String PREF_KEY = "ring_vibration_preference_screen";
+
+ public RingVibrationIntensityPreferenceController(Context context) {
+ super(context, PREF_KEY, Settings.System.RING_VIBRATION_INTENSITY,
+ Settings.System.VIBRATE_WHEN_RINGING);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return AVAILABLE;
+ }
+
+ @Override
+ protected int getDefaultIntensity() {
+ return mVibrator.getDefaultRingVibrationIntensity();
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2018 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.
+ */
+package com.android.settings.accessibility;
+
+import android.media.AudioAttributes;
+import android.os.Vibrator;
+import android.provider.Settings;
+
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.settings.R;
+
+/**
+ * Fragment for picking accessibility shortcut service
+ */
+public class RingVibrationPreferenceFragment extends VibrationPreferenceFragment {
+ @Override
+ public int getMetricsCategory() {
+ return MetricsEvent.ACCESSIBILITY_VIBRATION_RING;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.accessibility_ring_vibration_settings;
+ }
+
+ /**
+ * Get the setting string of the vibration intensity setting this preference is dealing with.
+ */
+ @Override
+ protected String getVibrationIntensitySetting() {
+ return Settings.System.RING_VIBRATION_INTENSITY;
+ }
+
+ @Override
+ protected String getVibrationEnabledSetting() {
+ return Settings.System.VIBRATE_WHEN_RINGING;
+ }
+
+ @Override
+ protected int getPreviewVibrationAudioAttributesUsage() {
+ return AudioAttributes.USAGE_NOTIFICATION;
+ }
+
+ @Override
+ protected int getDefaultVibrationIntensity() {
+ Vibrator vibrator = getContext().getSystemService(Vibrator.class);
+ return vibrator.getDefaultRingVibrationIntensity();
+ }
+}
}
@Override
+ protected String getVibrationEnabledSetting() {
+ return Settings.System.HAPTIC_FEEDBACK_ENABLED;
+ }
+
+ @Override
protected int getDefaultVibrationIntensity() {
Vibrator vibrator = getContext().getSystemService(Vibrator.class);
return vibrator.getDefaultHapticFeedbackIntensity();
protected int getPreviewVibrationAudioAttributesUsage() {
return AudioAttributes.USAGE_ASSISTANCE_SONIFICATION;
}
-
- @Override
- public void onVibrationIntensitySelected(int intensity) {
- // We want to keep HAPTIC_FEEDBACK_ENABLED consistent with this setting since some
- // applications check it directly before triggering their own haptic feedback.
- final boolean hapticFeedbackEnabled = !(intensity == Vibrator.VIBRATION_INTENSITY_OFF);
- Settings.System.putInt(getContext().getContentResolver(),
- Settings.System.HAPTIC_FEEDBACK_ENABLED, hapticFeedbackEnabled ? 1 : 0);
- }
}
protected final Vibrator mVibrator;
private final SettingObserver mSettingsContentObserver;
private final String mSettingKey;
+ private final String mEnabledKey;
private Preference mPreference;
public VibrationIntensityPreferenceController(Context context, String prefkey,
- String settingKey) {
+ String settingKey, String enabledKey) {
super(context, prefkey);
mVibrator = mContext.getSystemService(Vibrator.class);
mSettingKey = settingKey;
+ mEnabledKey = enabledKey;
mSettingsContentObserver = new SettingObserver(settingKey) {
@Override
public void onChange(boolean selfChange, Uri uri) {
public CharSequence getSummary() {
final int intensity = Settings.System.getInt(mContext.getContentResolver(),
mSettingKey, getDefaultIntensity());
- return getIntensityString(mContext, intensity);
+ final boolean enabled = Settings.System.getInt(mContext.getContentResolver(),
+ mEnabledKey, 1) == 1;
+ return getIntensityString(mContext, enabled ? intensity : Vibrator.VIBRATION_INTENSITY_OFF);
}
public static CharSequence getIntensityString(Context context, int intensity) {
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.Settings;
+import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
protected abstract String getVibrationIntensitySetting();
/**
+ * Get the setting string of the vibration enabledness setting this preference is dealing with.
+ */
+ protected abstract String getVibrationEnabledSetting();
+
+ /**
* Get the default intensity for the desired setting.
*/
protected abstract int getDefaultVibrationIntensity();
@Override
protected String getDefaultKey() {
- final int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
+ int vibrationIntensity = Settings.System.getInt(getContext().getContentResolver(),
getVibrationIntensitySetting(), getDefaultVibrationIntensity());
+ final boolean vibrationEnabled = Settings.System.getInt(getContext().getContentResolver(),
+ getVibrationEnabledSetting(), 1) == 1;
+ if (!vibrationEnabled) {
+ vibrationIntensity = Vibrator.VIBRATION_INTENSITY_OFF;
+ }
for (VibrationIntensityCandidateInfo candidate : mCandidates.values()) {
final boolean matchesIntensity = candidate.getIntensity() == vibrationIntensity;
final boolean matchesOn = candidate.getKey().equals(KEY_INTENSITY_ON)
Log.e(TAG, "Tried to set unknown intensity (key=" + key + ")!");
return false;
}
- Settings.System.putInt(getContext().getContentResolver(),
- getVibrationIntensitySetting(), candidate.getIntensity());
+ if (candidate.getIntensity() != Vibrator.VIBRATION_INTENSITY_OFF ||
+ TextUtils.isEmpty(getVibrationEnabledSetting())) {
+ Settings.System.putInt(getContext().getContentResolver(),
+ getVibrationIntensitySetting(), candidate.getIntensity());
+ }
onVibrationIntensitySelected(candidate.getIntensity());
return true;
}
}
@Override
+ protected String getVibrationEnabledSetting() {
+ return "";
+ }
+
+ @Override
protected int getDefaultVibrationIntensity() {
return Vibrator.VIBRATION_INTENSITY_MEDIUM;
}