Change BraveSiteSettingsPreferencesBase as a base class

Makes SiteSettingsPreferences inherits BraveSiteSettingsPreferencesBase.
With this, we don't need to modify multiple preferences xml files.
Only need to change one SiteSettingsPreferences.java file.
This commit is contained in:
Simon Hong
2019-10-03 06:33:46 +09:00
parent e0d8f6ce33
commit e6fdb9ecbb
5 changed files with 35 additions and 28 deletions
@@ -8,24 +8,40 @@ package org.chromium.chrome.browser.preferences.website;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.preferences.PreferenceUtils;
public class BraveSiteSettingsPreferences extends SiteSettingsPreferences {
public class BraveSiteSettingsPreferencesBase extends PreferenceFragmentCompat {
private static final String DESKTOP_MODE_CATEGORY_KEY = "desktop_mode_category";
private static final String PLAY_YT_VIDEO_IN_BROWSER_CATEGORY_KEY = "play_yt_video_in_browser_category";
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences(savedInstanceState, rootKey);
private static final String MEDIA_KEY = "media";
// Whether this class is handling showing the Media sub-menu (and not the main menu).
private boolean mMediaSubMenu;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Add brave's additional preferences here because |onCreatePreference| is not called
// by subclass (SiteSettingsPreferences::onCreatePreferences()).
// But, calling here has same effect because |onCreatePreferences()| is called by onCreate().
PreferenceUtils.addPreferencesFromResource(this, R.xml.brave_site_settings_preferences);
if (getArguments() != null) {
String category =
getArguments().getString(SingleCategoryPreferences.EXTRA_CATEGORY, "");
mMediaSubMenu = MEDIA_KEY.equals(category);
}
configureBravePreferences();
updateBravePreferenceStates();
}
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {}
@Override
public void onResume() {
super.onResume();