Skip to content

Commit

Permalink
Update controller for accessibility settings
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwibrowser committed Dec 11, 2021
1 parent 48be0be commit 2a9853b
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.chromium.components.browser_ui.settings.ChromeBaseCheckBoxPreference;
import org.chromium.components.browser_ui.settings.SettingsUtils;
import org.chromium.components.user_prefs.UserPrefs;
import org.chromium.content_public.browser.ContentFeatureList;

import android.app.Activity;
import org.chromium.base.ContextUtils;
Expand Down Expand Up @@ -53,9 +54,7 @@ public class AccessibilitySettings

private TextScalePreference mTextScalePref;
private ChromeBaseCheckBoxPreference mForceEnableZoomPref;
private ChromeBaseCheckBoxPreference mKeepToolbar;
private ChromeBaseCheckBoxPreference mSideSwipePref;
private ChromeBaseCheckBoxPreference mTabSwitcherButtonPref;
private boolean mRecordFontSizeChangeOnStop;
private Timer mTimer;
private Activity mActivity;
Expand Down Expand Up @@ -90,8 +89,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
mTextScalePref.updateFontScaleFactors(mFontSizePrefs.getFontScaleFactor(),
mFontSizePrefs.getUserFontScaleFactor(), false);

mTabSwitcherButtonPref = (ChromeBaseCheckBoxPreference) findPreference("tabswitcher_opens_contextual_menu");
mTabSwitcherButtonPref.setOnPreferenceChangeListener(this);

mSideSwipePref = (ChromeBaseCheckBoxPreference) findPreference("side_swipe_mode_enabled");
mSideSwipePref.setOnPreferenceChangeListener(this);
Expand All @@ -108,6 +105,17 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
.getBoolean(Pref.READER_FOR_ACCESSIBILITY));
readerForAccessibilityPref.setOnPreferenceChangeListener(this);

ChromeBaseCheckBoxPreference mAccessibilityTabSwitcherPref =
(ChromeBaseCheckBoxPreference) findPreference(
ChromePreferenceKeys.ACCESSIBILITY_TAB_SWITCHER);
if (ChromeAccessibilityUtil.get().isAccessibilityEnabled()) {
mAccessibilityTabSwitcherPref.setChecked(
SharedPreferencesManager.getInstance().readBoolean(
ChromePreferenceKeys.ACCESSIBILITY_TAB_SWITCHER, true));
} else {
getPreferenceScreen().removePreference(mAccessibilityTabSwitcherPref);
}

Preference captions = findPreference(PREF_CAPTIONS);
captions.setOnPreferenceClickListener(preference -> {
Intent intent = new Intent(Settings.ACTION_CAPTIONING_SETTINGS);
Expand All @@ -123,6 +131,9 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
Preference imageDescriptionsPreference = findPreference(PREF_IMAGE_DESCRIPTIONS);
imageDescriptionsPreference.setVisible(
ImageDescriptionsController.getInstance().shouldShowImageDescriptionsMenuItem());

((ChromeBaseCheckBoxPreference) findPreference("text_rewrap")).setOnPreferenceChangeListener(this);
((ChromeBaseCheckBoxPreference) findPreference("show_extensions_first")).setOnPreferenceChangeListener(this);
}

@Override
Expand Down Expand Up @@ -155,19 +166,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
AskForRelaunch(getActivity());
} else if ("enable_overscroll_button".equals(preference.getKey())) {
AskForRelaunch(getActivity());
} else if ("tabswitcher_opens_contextual_menu".equals(preference.getKey())) {
AskForRelaunch(getActivity());
} else if ("keep_toolbar_visible".equals(preference.getKey())) {
SharedPreferences.Editor sharedPreferencesEditor = ContextUtils.getAppSharedPreferences().edit();
if ((boolean)newValue)
sharedPreferencesEditor.putString("keep_toolbar_visible_configuration", "on");
else
sharedPreferencesEditor.putString("keep_toolbar_visible_configuration", "off");
sharedPreferencesEditor.apply();
} else if ("text_rewrap".equals(preference.getKey())) {
AskForRelaunch(getActivity());
} else if ("enable_bottom_toolbar".equals(preference.getKey())) {
AskForRelaunch(getActivity());
}

return true;
Expand Down

0 comments on commit 2a9853b

Please sign in to comment.