Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleCategoryPreferences.java

Issue 2039953002: Add a preference for disabling vibration in notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Address Dan's comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleCategoryPreferences.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleCategoryPreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleCategoryPreferences.java
index e49d6d8ecbe758cc94a0a50fe47aeaa85679e4fd..b3a4288fb80d6dc3130a6d9ed48eaa4228646401 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleCategoryPreferences.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleCategoryPreferences.java
@@ -80,6 +80,7 @@
// Keys for individual preferences.
public static final String READ_WRITE_TOGGLE_KEY = "read_write_toggle";
public static final String THIRD_PARTY_COOKIES_TOGGLE_KEY = "third_party_cookies";
+ public static final String NOTIFICATIONS_VIBRATE_TOGGLE_KEY = "notifications_vibrate";
public static final String EXPLAIN_PROTECTED_MEDIA_KEY = "protected_content_learn_more";
private static final String ADD_EXCEPTION_KEY = "add_exception";
// Keys for Allowed/Blocked preference groups/headers.
@@ -417,6 +418,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
PrefServiceBridge.getInstance().setMicEnabled((boolean) newValue);
} else if (mCategory.showNotificationsSites()) {
PrefServiceBridge.getInstance().setNotificationsEnabled((boolean) newValue);
+ updateNotificationsVibrateCheckBox();
} else if (mCategory.showPopupSites()) {
PrefServiceBridge.getInstance().setAllowPopupsEnabled((boolean) newValue);
} else if (mCategory.showProtectedMediaSites()) {
@@ -447,6 +449,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
getInfoForOrigins();
} else if (THIRD_PARTY_COOKIES_TOGGLE_KEY.equals(preference.getKey())) {
PrefServiceBridge.getInstance().setBlockThirdPartyCookiesEnabled(!((boolean) newValue));
+ } else if (NOTIFICATIONS_VIBRATE_TOGGLE_KEY.equals(preference.getKey())) {
+ PrefServiceBridge.getInstance().setNotificationsVibrateEnabled((boolean) newValue);
}
return true;
}
@@ -537,6 +541,16 @@ private void configureGlobalToggles() {
getPreferenceScreen().removePreference(thirdPartyCookies);
}
+ // Configure/hide the notifications vibrate toggle, as needed.
+ Preference notificationsVibrate =
+ getPreferenceScreen().findPreference(NOTIFICATIONS_VIBRATE_TOGGLE_KEY);
+ if (mCategory.showNotificationsSites()) {
+ notificationsVibrate.setOnPreferenceChangeListener(this);
+ updateNotificationsVibrateCheckBox();
+ } else {
+ getPreferenceScreen().removePreference(notificationsVibrate);
+ }
+
// Show/hide the link that explains protected media settings, as needed.
if (!mCategory.showProtectedMediaSites()) {
getPreferenceScreen().removePreference(
@@ -651,6 +665,13 @@ public boolean isPreferenceControlledByPolicy(Preference preference) {
});
}
+ private void updateNotificationsVibrateCheckBox() {
+ ChromeBaseCheckBoxPreference preference =
+ (ChromeBaseCheckBoxPreference) getPreferenceScreen().findPreference(
+ NOTIFICATIONS_VIBRATE_TOGGLE_KEY);
+ preference.setEnabled(PrefServiceBridge.getInstance().isNotificationsEnabled());
+ }
+
private void showManagedToast() {
if (mCategory.isManagedByCustodian()) {
ManagedPreferencesUtils.showManagedByParentToast(getActivity());

Powered by Google App Engine
This is Rietveld 408576698