From 2d992f0d2e514589f608e4e86c09b6f5261a8aaa Mon Sep 17 00:00:00 2001 From: samartnik Date: Fri, 26 Mar 2021 10:31:23 -0400 Subject: [PATCH] [Android] Night mode was modularized The only reason we used BravePreferenceFragment is to have a close button in the settings. This will be re-done in the context of this issue brave/brave-browser#10375 Chromium change: https://chromium.googlesource.com/chromium/src.git/+/b8f8625d98d573809cf06674f733ae31e6276eec Android: Modularize c.b.night_mode Moves c.b.night_mode files to a new moduarlized target chrome/browser/ ui/android/night_mode. This helps modularize other packages that depend on static utils such as NightModeUtils. Bug: 1171512 --- .../BraveRadioButtonGroupThemePreference.java | 2 +- ...ttonGroupCustomHomepageThemePreference.java | 18 ++++++++++-------- ...e-settings-ThemeSettingsFragment.java.patch | 13 ------------- 3 files changed, 11 insertions(+), 22 deletions(-) delete mode 100644 patches/chrome-browser-ui-android-night_mode-java-src-org-chromium-chrome-browser-night_mode-settings-ThemeSettingsFragment.java.patch diff --git a/android/java/org/chromium/chrome/browser/night_mode/settings/BraveRadioButtonGroupThemePreference.java b/android/java/org/chromium/chrome/browser/night_mode/settings/BraveRadioButtonGroupThemePreference.java index c8d1a5bd68dd..7a32f3b122e7 100644 --- a/android/java/org/chromium/chrome/browser/night_mode/settings/BraveRadioButtonGroupThemePreference.java +++ b/android/java/org/chromium/chrome/browser/night_mode/settings/BraveRadioButtonGroupThemePreference.java @@ -12,7 +12,7 @@ import androidx.preference.PreferenceViewHolder; -import org.chromium.chrome.R; +import org.chromium.chrome.browser.night_mode.R; public class BraveRadioButtonGroupThemePreference extends RadioButtonGroupThemePreference { public BraveRadioButtonGroupThemePreference(Context context, AttributeSet attrs) { diff --git a/android/java/org/chromium/chrome/browser/settings/themes/BraveRadioButtonGroupCustomHomepageThemePreference.java b/android/java/org/chromium/chrome/browser/settings/themes/BraveRadioButtonGroupCustomHomepageThemePreference.java index bae83792dd82..e512b4247e4c 100644 --- a/android/java/org/chromium/chrome/browser/settings/themes/BraveRadioButtonGroupCustomHomepageThemePreference.java +++ b/android/java/org/chromium/chrome/browser/settings/themes/BraveRadioButtonGroupCustomHomepageThemePreference.java @@ -6,19 +6,20 @@ package org.chromium.chrome.browser.settings.themes; import android.content.Context; -import androidx.preference.PreferenceViewHolder; import android.util.AttributeSet; import android.view.View; import android.widget.RadioGroup; -import org.chromium.chrome.R; -import org.chromium.components.browser_ui.widget.RadioButtonWithDescription; -import org.chromium.chrome.browser.profiles.Profile; -import org.chromium.chrome.browser.preferences.BravePref; -import org.chromium.components.user_prefs.UserPrefs; +import androidx.preference.PreferenceViewHolder; + +import org.chromium.chrome.browser.BraveRelaunchUtils; +import org.chromium.chrome.browser.night_mode.R; import org.chromium.chrome.browser.night_mode.settings.RadioButtonGroupThemePreference; import org.chromium.chrome.browser.ntp_background_images.NTPBackgroundImagesBridge; -import org.chromium.chrome.browser.BraveRelaunchUtils; +import org.chromium.chrome.browser.preferences.BravePref; +import org.chromium.chrome.browser.profiles.Profile; +import org.chromium.components.browser_ui.widget.RadioButtonWithDescription; +import org.chromium.components.user_prefs.UserPrefs; public class BraveRadioButtonGroupCustomHomepageThemePreference extends RadioButtonGroupThemePreference { @@ -50,7 +51,8 @@ public void onBindViewHolder(PreferenceViewHolder holder) { braveDefaultView.setChecked(true); } } - braveDefaultView.setPrimaryText(getContext().getResources().getString(R.string.brave_default)); + braveDefaultView.setPrimaryText( + getContext().getResources().getString(org.chromium.chrome.R.string.brave_default)); } @Override diff --git a/patches/chrome-browser-ui-android-night_mode-java-src-org-chromium-chrome-browser-night_mode-settings-ThemeSettingsFragment.java.patch b/patches/chrome-browser-ui-android-night_mode-java-src-org-chromium-chrome-browser-night_mode-settings-ThemeSettingsFragment.java.patch deleted file mode 100644 index 298b64ba9763..000000000000 --- a/patches/chrome-browser-ui-android-night_mode-java-src-org-chromium-chrome-browser-night_mode-settings-ThemeSettingsFragment.java.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/chrome/browser/ui/android/night_mode/java/src/org/chromium/chrome/browser/night_mode/settings/ThemeSettingsFragment.java b/chrome/browser/ui/android/night_mode/java/src/org/chromium/chrome/browser/night_mode/settings/ThemeSettingsFragment.java -index 3cad3ac1f22dcbea840cb98ab7c3a0ceeecd1f7b..7fa738902700cdf10631dbd74a5b0d65fb20acac 100644 ---- a/chrome/browser/ui/android/night_mode/java/src/org/chromium/chrome/browser/night_mode/settings/ThemeSettingsFragment.java -+++ b/chrome/browser/ui/android/night_mode/java/src/org/chromium/chrome/browser/night_mode/settings/ThemeSettingsFragment.java -@@ -23,7 +23,7 @@ import org.chromium.ui.UiUtils; - /** - * Fragment to manage the theme user settings. - */ --public class ThemeSettingsFragment extends PreferenceFragmentCompat { -+public class ThemeSettingsFragment extends org.chromium.chrome.browser.settings.BravePreferenceFragment { - static final String PREF_UI_THEME_PREF = "ui_theme_pref"; - - @Override