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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.preferences.website; 5 package org.chromium.chrome.browser.preferences.website;
6 6
7 import android.os.Bundle; 7 import android.os.Bundle;
8 import android.preference.Preference; 8 import android.preference.Preference;
9 import android.preference.Preference.OnPreferenceChangeListener; 9 import android.preference.Preference.OnPreferenceChangeListener;
10 import android.preference.Preference.OnPreferenceClickListener; 10 import android.preference.Preference.OnPreferenceClickListener;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Whether the Allowed list should be shown expanded. 74 // Whether the Allowed list should be shown expanded.
75 private boolean mAllowListExpanded = true; 75 private boolean mAllowListExpanded = true;
76 // Whether this is the first time this screen is shown. 76 // Whether this is the first time this screen is shown.
77 private boolean mIsInitialRun = true; 77 private boolean mIsInitialRun = true;
78 // The number of sites that are on the Allowed list. 78 // The number of sites that are on the Allowed list.
79 private int mAllowedSiteCount = 0; 79 private int mAllowedSiteCount = 0;
80 80
81 // Keys for individual preferences. 81 // Keys for individual preferences.
82 public static final String READ_WRITE_TOGGLE_KEY = "read_write_toggle"; 82 public static final String READ_WRITE_TOGGLE_KEY = "read_write_toggle";
83 public static final String THIRD_PARTY_COOKIES_TOGGLE_KEY = "third_party_coo kies"; 83 public static final String THIRD_PARTY_COOKIES_TOGGLE_KEY = "third_party_coo kies";
84 public static final String NOTIFICATIONS_VIBRATE_TOGGLE_KEY = "notifications _vibrate";
84 public static final String EXPLAIN_PROTECTED_MEDIA_KEY = "protected_content_ learn_more"; 85 public static final String EXPLAIN_PROTECTED_MEDIA_KEY = "protected_content_ learn_more";
85 private static final String ADD_EXCEPTION_KEY = "add_exception"; 86 private static final String ADD_EXCEPTION_KEY = "add_exception";
86 // Keys for Allowed/Blocked preference groups/headers. 87 // Keys for Allowed/Blocked preference groups/headers.
87 private static final String ALLOWED_GROUP = "allowed_group"; 88 private static final String ALLOWED_GROUP = "allowed_group";
88 private static final String BLOCKED_GROUP = "blocked_group"; 89 private static final String BLOCKED_GROUP = "blocked_group";
89 90
90 private void getInfoForOrigins() { 91 private void getInfoForOrigins() {
91 if (!mCategory.enabledInAndroid(getActivity())) { 92 if (!mCategory.enabledInAndroid(getActivity())) {
92 // No need to fetch any data if we're not going to show it, but we d o need to update 93 // No need to fetch any data if we're not going to show it, but we d o need to update
93 // the global toggle to reflect updates in Android settings (e.g. Lo cation). 94 // the global toggle to reflect updates in Android settings (e.g. Lo cation).
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 } else if (mCategory.showFullscreenSites()) { 412 } else if (mCategory.showFullscreenSites()) {
412 PrefServiceBridge.getInstance().setFullscreenAllowed((boolean) n ewValue); 413 PrefServiceBridge.getInstance().setFullscreenAllowed((boolean) n ewValue);
413 } else if (mCategory.showGeolocationSites()) { 414 } else if (mCategory.showGeolocationSites()) {
414 PrefServiceBridge.getInstance().setAllowLocationEnabled((boolean ) newValue); 415 PrefServiceBridge.getInstance().setAllowLocationEnabled((boolean ) newValue);
415 } else if (mCategory.showJavaScriptSites()) { 416 } else if (mCategory.showJavaScriptSites()) {
416 PrefServiceBridge.getInstance().setJavaScriptEnabled((boolean) n ewValue); 417 PrefServiceBridge.getInstance().setJavaScriptEnabled((boolean) n ewValue);
417 } else if (mCategory.showMicrophoneSites()) { 418 } else if (mCategory.showMicrophoneSites()) {
418 PrefServiceBridge.getInstance().setMicEnabled((boolean) newValue ); 419 PrefServiceBridge.getInstance().setMicEnabled((boolean) newValue );
419 } else if (mCategory.showNotificationsSites()) { 420 } else if (mCategory.showNotificationsSites()) {
420 PrefServiceBridge.getInstance().setNotificationsEnabled((boolean ) newValue); 421 PrefServiceBridge.getInstance().setNotificationsEnabled((boolean ) newValue);
422 updateNotificationsVibrateCheckBox();
421 } else if (mCategory.showPopupSites()) { 423 } else if (mCategory.showPopupSites()) {
422 PrefServiceBridge.getInstance().setAllowPopupsEnabled((boolean) newValue); 424 PrefServiceBridge.getInstance().setAllowPopupsEnabled((boolean) newValue);
423 } else if (mCategory.showProtectedMediaSites()) { 425 } else if (mCategory.showProtectedMediaSites()) {
424 PrefServiceBridge.getInstance().setProtectedMediaIdentifierEnabl ed( 426 PrefServiceBridge.getInstance().setProtectedMediaIdentifierEnabl ed(
425 (boolean) newValue); 427 (boolean) newValue);
426 } 428 }
427 429
428 // Categories that support adding exceptions also manage the 'Add si te' preference. 430 // Categories that support adding exceptions also manage the 'Add si te' preference.
429 if (mCategory.showAutoplaySites() || mCategory.showBackgroundSyncSit es() 431 if (mCategory.showAutoplaySites() || mCategory.showBackgroundSyncSit es()
430 || mCategory.showJavaScriptSites()) { 432 || mCategory.showJavaScriptSites()) {
(...skipping 10 matching lines...) Expand all
441 } 443 }
442 } 444 }
443 445
444 ChromeSwitchPreference globalToggle = (ChromeSwitchPreference) 446 ChromeSwitchPreference globalToggle = (ChromeSwitchPreference)
445 getPreferenceScreen().findPreference(READ_WRITE_TOGGLE_KEY); 447 getPreferenceScreen().findPreference(READ_WRITE_TOGGLE_KEY);
446 updateAllowedHeader(mAllowedSiteCount, !globalToggle.isChecked()); 448 updateAllowedHeader(mAllowedSiteCount, !globalToggle.isChecked());
447 449
448 getInfoForOrigins(); 450 getInfoForOrigins();
449 } else if (THIRD_PARTY_COOKIES_TOGGLE_KEY.equals(preference.getKey())) { 451 } else if (THIRD_PARTY_COOKIES_TOGGLE_KEY.equals(preference.getKey())) {
450 PrefServiceBridge.getInstance().setBlockThirdPartyCookiesEnabled(!(( boolean) newValue)); 452 PrefServiceBridge.getInstance().setBlockThirdPartyCookiesEnabled(!(( boolean) newValue));
453 } else if (NOTIFICATIONS_VIBRATE_TOGGLE_KEY.equals(preference.getKey())) {
454 PrefServiceBridge.getInstance().setNotificationsVibrateEnabled((bool ean) newValue);
451 } 455 }
452 return true; 456 return true;
453 } 457 }
454 458
455 private String getAddExceptionDialogMessage() { 459 private String getAddExceptionDialogMessage() {
456 int resource = 0; 460 int resource = 0;
457 if (mCategory.showAutoplaySites()) { 461 if (mCategory.showAutoplaySites()) {
458 resource = R.string.website_settings_add_site_description_autoplay; 462 resource = R.string.website_settings_add_site_description_autoplay;
459 } else if (mCategory.showBackgroundSyncSites()) { 463 } else if (mCategory.showBackgroundSyncSites()) {
460 resource = R.string.website_settings_add_site_description_background _sync; 464 resource = R.string.website_settings_add_site_description_background _sync;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 // Configure/hide the third-party cookie toggle, as needed. 535 // Configure/hide the third-party cookie toggle, as needed.
532 Preference thirdPartyCookies = getPreferenceScreen().findPreference( 536 Preference thirdPartyCookies = getPreferenceScreen().findPreference(
533 THIRD_PARTY_COOKIES_TOGGLE_KEY); 537 THIRD_PARTY_COOKIES_TOGGLE_KEY);
534 if (mCategory.showCookiesSites()) { 538 if (mCategory.showCookiesSites()) {
535 thirdPartyCookies.setOnPreferenceChangeListener(this); 539 thirdPartyCookies.setOnPreferenceChangeListener(this);
536 updateThirdPartyCookiesCheckBox(); 540 updateThirdPartyCookiesCheckBox();
537 } else { 541 } else {
538 getPreferenceScreen().removePreference(thirdPartyCookies); 542 getPreferenceScreen().removePreference(thirdPartyCookies);
539 } 543 }
540 544
545 // Configure/hide the notifications vibrate toggle, as needed.
546 Preference notificationsVibrate =
547 getPreferenceScreen().findPreference(NOTIFICATIONS_VIBRATE_TOGGL E_KEY);
548 if (mCategory.showNotificationsSites()) {
549 notificationsVibrate.setOnPreferenceChangeListener(this);
550 updateNotificationsVibrateCheckBox();
551 } else {
552 getPreferenceScreen().removePreference(notificationsVibrate);
553 }
554
541 // Show/hide the link that explains protected media settings, as needed. 555 // Show/hide the link that explains protected media settings, as needed.
542 if (!mCategory.showProtectedMediaSites()) { 556 if (!mCategory.showProtectedMediaSites()) {
543 getPreferenceScreen().removePreference( 557 getPreferenceScreen().removePreference(
544 getPreferenceScreen().findPreference(EXPLAIN_PROTECTED_MEDIA _KEY)); 558 getPreferenceScreen().findPreference(EXPLAIN_PROTECTED_MEDIA _KEY));
545 } 559 }
546 560
547 if (mCategory.showAllSites() 561 if (mCategory.showAllSites()
548 || mCategory.showStorageSites()) { 562 || mCategory.showStorageSites()) {
549 getPreferenceScreen().removePreference(globalToggle); 563 getPreferenceScreen().removePreference(globalToggle);
550 getPreferenceScreen().removePreference( 564 getPreferenceScreen().removePreference(
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 getPreferenceScreen().findPreference(THIRD_PARTY_COOKIES_TOGGLE_ KEY); 659 getPreferenceScreen().findPreference(THIRD_PARTY_COOKIES_TOGGLE_ KEY);
646 thirdPartyCookiesPref.setEnabled(PrefServiceBridge.getInstance().isAccep tCookiesEnabled()); 660 thirdPartyCookiesPref.setEnabled(PrefServiceBridge.getInstance().isAccep tCookiesEnabled());
647 thirdPartyCookiesPref.setManagedPreferenceDelegate(new ManagedPreference Delegate() { 661 thirdPartyCookiesPref.setManagedPreferenceDelegate(new ManagedPreference Delegate() {
648 @Override 662 @Override
649 public boolean isPreferenceControlledByPolicy(Preference preference) { 663 public boolean isPreferenceControlledByPolicy(Preference preference) {
650 return PrefServiceBridge.getInstance().isBlockThirdPartyCookiesM anaged(); 664 return PrefServiceBridge.getInstance().isBlockThirdPartyCookiesM anaged();
651 } 665 }
652 }); 666 });
653 } 667 }
654 668
669 private void updateNotificationsVibrateCheckBox() {
670 ChromeBaseCheckBoxPreference preference =
671 (ChromeBaseCheckBoxPreference) getPreferenceScreen().findPrefere nce(
672 NOTIFICATIONS_VIBRATE_TOGGLE_KEY);
673 preference.setEnabled(PrefServiceBridge.getInstance().isNotificationsEna bled());
674 }
675
655 private void showManagedToast() { 676 private void showManagedToast() {
656 if (mCategory.isManagedByCustodian()) { 677 if (mCategory.isManagedByCustodian()) {
657 ManagedPreferencesUtils.showManagedByParentToast(getActivity()); 678 ManagedPreferencesUtils.showManagedByParentToast(getActivity());
658 } else { 679 } else {
659 ManagedPreferencesUtils.showManagedByAdministratorToast(getActivity( )); 680 ManagedPreferencesUtils.showManagedByAdministratorToast(getActivity( ));
660 } 681 }
661 } 682 }
662 683
663 // ProtectedContentResetCredentialConfirmDialogFragment.Listener: 684 // ProtectedContentResetCredentialConfirmDialogFragment.Listener:
664 @Override 685 @Override
665 public void resetDeviceCredential() { 686 public void resetDeviceCredential() {
666 MediaDrmCredentialManager.resetCredentials(new MediaDrmCredentialManager Callback() { 687 MediaDrmCredentialManager.resetCredentials(new MediaDrmCredentialManager Callback() {
667 @Override 688 @Override
668 public void onCredentialResetFinished(boolean succeeded) { 689 public void onCredentialResetFinished(boolean succeeded) {
669 if (succeeded) return; 690 if (succeeded) return;
670 String message = getString(R.string.protected_content_reset_fail ed); 691 String message = getString(R.string.protected_content_reset_fail ed);
671 Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show( ); 692 Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show( );
672 } 693 }
673 }); 694 });
674 } 695 }
675 } 696 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698