Commit cf0eff4c authored by Natalie Chouinard's avatar Natalie Chouinard Committed by Commit Bot

Move and rename Notification settings

Move Notification settings and tests to subpackage, and rename
according to go/clank-preferences-refactor naming conventions.

Bug: 876376, 1030446
Change-Id: I050d854907d46a45e35e24ce3eadf14c8ecc9915
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1953607
Commit-Queue: Natalie Chouinard <chouinard@chromium.org>
Reviewed-by: default avatarSky Malice <skym@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722594}
parent 5993f75d
...@@ -1352,7 +1352,6 @@ chrome_java_sources = [ ...@@ -1352,7 +1352,6 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/settings/MainPreferences.java", "java/src/org/chromium/chrome/browser/settings/MainPreferences.java",
"java/src/org/chromium/chrome/browser/settings/ManagedPreferenceDelegate.java", "java/src/org/chromium/chrome/browser/settings/ManagedPreferenceDelegate.java",
"java/src/org/chromium/chrome/browser/settings/ManagedPreferencesUtils.java", "java/src/org/chromium/chrome/browser/settings/ManagedPreferencesUtils.java",
"java/src/org/chromium/chrome/browser/settings/NotificationsPreferences.java",
"java/src/org/chromium/chrome/browser/settings/PreferencesLauncher.java", "java/src/org/chromium/chrome/browser/settings/PreferencesLauncher.java",
"java/src/org/chromium/chrome/browser/settings/SearchEngineAdapter.java", "java/src/org/chromium/chrome/browser/settings/SearchEngineAdapter.java",
"java/src/org/chromium/chrome/browser/settings/SearchEnginePreference.java", "java/src/org/chromium/chrome/browser/settings/SearchEnginePreference.java",
...@@ -1405,6 +1404,7 @@ chrome_java_sources = [ ...@@ -1405,6 +1404,7 @@ chrome_java_sources = [
"java/src/org/chromium/chrome/browser/settings/languages/LanguageListPreference.java", "java/src/org/chromium/chrome/browser/settings/languages/LanguageListPreference.java",
"java/src/org/chromium/chrome/browser/settings/languages/LanguagesManager.java", "java/src/org/chromium/chrome/browser/settings/languages/LanguagesManager.java",
"java/src/org/chromium/chrome/browser/settings/languages/LanguagesPreferences.java", "java/src/org/chromium/chrome/browser/settings/languages/LanguagesPreferences.java",
"java/src/org/chromium/chrome/browser/settings/notifications/NotificationsSettings.java",
"java/src/org/chromium/chrome/browser/settings/password/CallbackDelayer.java", "java/src/org/chromium/chrome/browser/settings/password/CallbackDelayer.java",
"java/src/org/chromium/chrome/browser/settings/password/DialogManager.java", "java/src/org/chromium/chrome/browser/settings/password/DialogManager.java",
"java/src/org/chromium/chrome/browser/settings/password/ExportErrorDialogFragment.java", "java/src/org/chromium/chrome/browser/settings/password/ExportErrorDialogFragment.java",
......
...@@ -407,7 +407,6 @@ chrome_test_java_sources = [ ...@@ -407,7 +407,6 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/searchwidget/SearchActivityTest.java", "javatests/src/org/chromium/chrome/browser/searchwidget/SearchActivityTest.java",
"javatests/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProviderTest.java", "javatests/src/org/chromium/chrome/browser/searchwidget/SearchWidgetProviderTest.java",
"javatests/src/org/chromium/chrome/browser/services/GoogleServicesManagerIntegrationTest.java", "javatests/src/org/chromium/chrome/browser/services/GoogleServicesManagerIntegrationTest.java",
"javatests/src/org/chromium/chrome/browser/settings/NotificationsPreferencesTest.java",
"javatests/src/org/chromium/chrome/browser/settings/PasswordViewingTypeTest.java", "javatests/src/org/chromium/chrome/browser/settings/PasswordViewingTypeTest.java",
"javatests/src/org/chromium/chrome/browser/settings/SettingsActivityTest.java", "javatests/src/org/chromium/chrome/browser/settings/SettingsActivityTest.java",
"javatests/src/org/chromium/chrome/browser/settings/accessibility/AccessibilitySettingsTest.java", "javatests/src/org/chromium/chrome/browser/settings/accessibility/AccessibilitySettingsTest.java",
...@@ -415,6 +414,7 @@ chrome_test_java_sources = [ ...@@ -415,6 +414,7 @@ chrome_test_java_sources = [
"javatests/src/org/chromium/chrome/browser/settings/autofill/AutofillTestRule.java", "javatests/src/org/chromium/chrome/browser/settings/autofill/AutofillTestRule.java",
"javatests/src/org/chromium/chrome/browser/settings/autofill_assistant/AutofillAssistantSettingsTest.java", "javatests/src/org/chromium/chrome/browser/settings/autofill_assistant/AutofillAssistantSettingsTest.java",
"javatests/src/org/chromium/chrome/browser/settings/developer/TracingSettingsTest.java", "javatests/src/org/chromium/chrome/browser/settings/developer/TracingSettingsTest.java",
"javatests/src/org/chromium/chrome/browser/settings/notifications/NotificationsSettingsTest.java",
"javatests/src/org/chromium/chrome/browser/settings/password/SavePasswordsPreferencesTest.java", "javatests/src/org/chromium/chrome/browser/settings/password/SavePasswordsPreferencesTest.java",
"javatests/src/org/chromium/chrome/browser/settings/privacy/BrowsingDataBridgeTest.java", "javatests/src/org/chromium/chrome/browser/settings/privacy/BrowsingDataBridgeTest.java",
"javatests/src/org/chromium/chrome/browser/settings/privacy/BrowsingDataTest.java", "javatests/src/org/chromium/chrome/browser/settings/privacy/BrowsingDataTest.java",
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
android:order="8" android:order="8"
android:title="@string/prefs_autofill_assistant_title"/> android:title="@string/prefs_autofill_assistant_title"/>
<Preference <Preference
android:fragment="org.chromium.chrome.browser.settings.NotificationsPreferences" android:fragment="org.chromium.chrome.browser.settings.notifications.NotificationsSettings"
android:key="notifications" android:key="notifications"
android:order="9" android:order="9"
android:title="@string/prefs_notifications"/> android:title="@string/prefs_notifications"/>
......
...@@ -26,8 +26,8 @@ import org.chromium.chrome.browser.notifications.NotificationMetadata; ...@@ -26,8 +26,8 @@ import org.chromium.chrome.browser.notifications.NotificationMetadata;
import org.chromium.chrome.browser.notifications.NotificationUmaTracker; import org.chromium.chrome.browser.notifications.NotificationUmaTracker;
import org.chromium.chrome.browser.notifications.PendingIntentProvider; import org.chromium.chrome.browser.notifications.PendingIntentProvider;
import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions; import org.chromium.chrome.browser.notifications.channels.ChannelDefinitions;
import org.chromium.chrome.browser.settings.NotificationsPreferences;
import org.chromium.chrome.browser.settings.PreferencesLauncher; import org.chromium.chrome.browser.settings.PreferencesLauncher;
import org.chromium.chrome.browser.settings.notifications.NotificationsSettings;
import org.chromium.content_public.browser.BrowserStartupController; import org.chromium.content_public.browser.BrowserStartupController;
import org.chromium.content_public.browser.BrowserStartupController.StartupCallback; import org.chromium.content_public.browser.BrowserStartupController.StartupCallback;
...@@ -84,7 +84,7 @@ public class PrefetchedPagesNotifier { ...@@ -84,7 +84,7 @@ public class PrefetchedPagesNotifier {
public void onReceive(final Context context, Intent intent) { public void onReceive(final Context context, Intent intent) {
recordNotificationActionWhenChromeLoadsNative(NOTIFICATION_ACTION_SETTINGS_CLICKED); recordNotificationActionWhenChromeLoadsNative(NOTIFICATION_ACTION_SETTINGS_CLICKED);
Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage( Intent settingsIntent = PreferencesLauncher.createIntentForSettingsPage(
context, NotificationsPreferences.class.getName()); context, NotificationsSettings.class.getName());
settingsIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); settingsIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivity(settingsIntent); context.startActivity(settingsIntent);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.settings; package org.chromium.chrome.browser.settings.notifications;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
...@@ -15,6 +15,8 @@ import org.chromium.chrome.R; ...@@ -15,6 +15,8 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.ContentSettingsType; import org.chromium.chrome.browser.ContentSettingsType;
import org.chromium.chrome.browser.offlinepages.prefetch.PrefetchConfiguration; import org.chromium.chrome.browser.offlinepages.prefetch.PrefetchConfiguration;
import org.chromium.chrome.browser.offlinepages.prefetch.PrefetchPrefs; import org.chromium.chrome.browser.offlinepages.prefetch.PrefetchPrefs;
import org.chromium.chrome.browser.settings.ChromeSwitchPreference;
import org.chromium.chrome.browser.settings.SettingsUtils;
import org.chromium.chrome.browser.settings.website.ContentSettingsResources; import org.chromium.chrome.browser.settings.website.ContentSettingsResources;
import org.chromium.chrome.browser.settings.website.SingleCategoryPreferences; import org.chromium.chrome.browser.settings.website.SingleCategoryPreferences;
import org.chromium.chrome.browser.settings.website.SiteSettingsCategory; import org.chromium.chrome.browser.settings.website.SiteSettingsCategory;
...@@ -25,7 +27,7 @@ import org.chromium.chrome.browser.settings.website.WebsitePreferenceBridge; ...@@ -25,7 +27,7 @@ import org.chromium.chrome.browser.settings.website.WebsitePreferenceBridge;
* notification channels at the top level and links to website specific notifications. This is only * notification channels at the top level and links to website specific notifications. This is only
* used on pre-O devices, devices on Android O+ will link to the Android notification settings. * used on pre-O devices, devices on Android O+ will link to the Android notification settings.
*/ */
public class NotificationsPreferences extends PreferenceFragmentCompat { public class NotificationsSettings extends PreferenceFragmentCompat {
// These are package-private to be used in tests. // These are package-private to be used in tests.
static final String PREF_FROM_WEBSITES = "from_websites"; static final String PREF_FROM_WEBSITES = "from_websites";
static final String PREF_SUGGESTIONS = "content_suggestions"; static final String PREF_SUGGESTIONS = "content_suggestions";
...@@ -40,7 +42,7 @@ public class NotificationsPreferences extends PreferenceFragmentCompat { ...@@ -40,7 +42,7 @@ public class NotificationsPreferences extends PreferenceFragmentCompat {
@Override @Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
assert Build.VERSION.SDK_INT < Build.VERSION_CODES.O assert Build.VERSION.SDK_INT < Build.VERSION_CODES.O
: "NotificationsPreferences should only be used pre-O."; : "NotificationsSettings should only be used pre-O.";
SettingsUtils.addPreferencesFromResource(this, R.xml.notifications_preferences); SettingsUtils.addPreferencesFromResource(this, R.xml.notifications_preferences);
getActivity().setTitle(R.string.prefs_notifications); getActivity().setTitle(R.string.prefs_notifications);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.settings; package org.chromium.chrome.browser.settings.notifications;
import android.os.Build; import android.os.Build;
import android.support.test.InstrumentationRegistry; import android.support.test.InstrumentationRegistry;
...@@ -23,6 +23,9 @@ import org.chromium.base.test.util.DisableIf; ...@@ -23,6 +23,9 @@ import org.chromium.base.test.util.DisableIf;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.chrome.browser.ContentSettingsType; import org.chromium.chrome.browser.ContentSettingsType;
import org.chromium.chrome.browser.offlinepages.prefetch.PrefetchPrefs; import org.chromium.chrome.browser.offlinepages.prefetch.PrefetchPrefs;
import org.chromium.chrome.browser.settings.ChromeSwitchPreference;
import org.chromium.chrome.browser.settings.SettingsActivity;
import org.chromium.chrome.browser.settings.SettingsActivityTest;
import org.chromium.chrome.browser.settings.website.ContentSettingsResources; import org.chromium.chrome.browser.settings.website.ContentSettingsResources;
import org.chromium.chrome.browser.settings.website.SingleCategoryPreferences; import org.chromium.chrome.browser.settings.website.SingleCategoryPreferences;
import org.chromium.chrome.browser.settings.website.SiteSettingsCategory; import org.chromium.chrome.browser.settings.website.SiteSettingsCategory;
...@@ -35,10 +38,10 @@ import org.chromium.content_public.browser.test.util.CriteriaHelper; ...@@ -35,10 +38,10 @@ import org.chromium.content_public.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.test.util.TestThreadUtils; import org.chromium.content_public.browser.test.util.TestThreadUtils;
/** /**
* Tests for the NotificationsPreferences. * Tests for the NotificationsSettings.
*/ */
@RunWith(ChromeJUnit4ClassRunner.class) @RunWith(ChromeJUnit4ClassRunner.class)
public class NotificationsPreferencesTest { public class NotificationsSettingsTest {
@Rule @Rule
public final ChromeBrowserTestRule mBrowserTestRule = new ChromeBrowserTestRule(); public final ChromeBrowserTestRule mBrowserTestRule = new ChromeBrowserTestRule();
private SettingsActivity mActivity; private SettingsActivity mActivity;
...@@ -50,7 +53,7 @@ public class NotificationsPreferencesTest { ...@@ -50,7 +53,7 @@ public class NotificationsPreferencesTest {
public void setUp() { public void setUp() {
mActivity = SettingsActivityTest.startSettingsActivity( mActivity = SettingsActivityTest.startSettingsActivity(
InstrumentationRegistry.getInstrumentation(), InstrumentationRegistry.getInstrumentation(),
NotificationsPreferences.class.getName()); NotificationsSettings.class.getName());
} }
// TODO(https://crbug.com/894334): Remove format suppression once formatting bug is fixed. // TODO(https://crbug.com/894334): Remove format suppression once formatting bug is fixed.
...@@ -66,7 +69,7 @@ public class NotificationsPreferencesTest { ...@@ -66,7 +69,7 @@ public class NotificationsPreferencesTest {
final PreferenceFragmentCompat fragment = final PreferenceFragmentCompat fragment =
(PreferenceFragmentCompat) mActivity.getMainFragment(); (PreferenceFragmentCompat) mActivity.getMainFragment();
final ChromeSwitchPreference toggle = (ChromeSwitchPreference) fragment.findPreference( final ChromeSwitchPreference toggle = (ChromeSwitchPreference) fragment.findPreference(
NotificationsPreferences.PREF_SUGGESTIONS); NotificationsSettings.PREF_SUGGESTIONS);
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
// Make sure the toggle reflects the state correctly. // Make sure the toggle reflects the state correctly.
...@@ -102,7 +105,7 @@ public class NotificationsPreferencesTest { ...@@ -102,7 +105,7 @@ public class NotificationsPreferencesTest {
PreferenceFragmentCompat fragment = (PreferenceFragmentCompat) mActivity.getMainFragment(); PreferenceFragmentCompat fragment = (PreferenceFragmentCompat) mActivity.getMainFragment();
ChromeSwitchPreference toggle = (ChromeSwitchPreference) fragment.findPreference( ChromeSwitchPreference toggle = (ChromeSwitchPreference) fragment.findPreference(
NotificationsPreferences.PREF_SUGGESTIONS); NotificationsSettings.PREF_SUGGESTIONS);
Assert.assertFalse(toggle.isEnabled()); Assert.assertFalse(toggle.isEnabled());
Assert.assertFalse(toggle.isChecked()); Assert.assertFalse(toggle.isChecked());
...@@ -123,7 +126,7 @@ public class NotificationsPreferencesTest { ...@@ -123,7 +126,7 @@ public class NotificationsPreferencesTest {
PreferenceFragmentCompat fragment = PreferenceFragmentCompat fragment =
(PreferenceFragmentCompat) mActivity.getMainFragment(); (PreferenceFragmentCompat) mActivity.getMainFragment();
Preference fromWebsites = Preference fromWebsites =
fragment.findPreference(NotificationsPreferences.PREF_FROM_WEBSITES); fragment.findPreference(NotificationsSettings.PREF_FROM_WEBSITES);
fromWebsites.performClick(); fromWebsites.performClick();
}); });
...@@ -154,7 +157,7 @@ public class NotificationsPreferencesTest { ...@@ -154,7 +157,7 @@ public class NotificationsPreferencesTest {
final PreferenceFragmentCompat fragment = final PreferenceFragmentCompat fragment =
(PreferenceFragmentCompat) mActivity.getMainFragment(); (PreferenceFragmentCompat) mActivity.getMainFragment();
final Preference fromWebsites = final Preference fromWebsites =
fragment.findPreference(NotificationsPreferences.PREF_FROM_WEBSITES); fragment.findPreference(NotificationsSettings.PREF_FROM_WEBSITES);
TestThreadUtils.runOnUiThreadBlocking(() -> { TestThreadUtils.runOnUiThreadBlocking(() -> {
WebsitePreferenceBridge.setCategoryEnabled(ContentSettingsType.NOTIFICATIONS, false); WebsitePreferenceBridge.setCategoryEnabled(ContentSettingsType.NOTIFICATIONS, false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment