Convert Magnify controller to TogglePrefController

Convert below to TogglePreferenceController:
MagnificationNavbarPreferenceController
(Magnify with Button)
MagnificationGesturesPreferenceController
(Magnify with triple-tap)

The two controllers share the same fragment,
Add static method for set/get state in fragment,
And use them in controllers and fragment.

Change-Id: I2bdbdb36be71e1a3ffb557abc5a6115d48de53cf
Merged-In: I2bdbdb36be71e1a3ffb557abc5a6115d48de53cf
Fixes: 67997698
Fixes: 67997726
Test: make RunSettingsRoboTests
This commit is contained in:
hjchangliao
2018-05-02 16:57:20 +08:00
committed by Andrew Sapperstein
parent 8a9c47e1ba
commit a92271c26d
8 changed files with 131 additions and 26 deletions

View File

@@ -25,7 +25,6 @@ import android.media.MediaPlayer;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceScreen;
import android.support.v7.preference.PreferenceViewHolder;
@@ -174,7 +173,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
@Override
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
Settings.Secure.putInt(getContentResolver(), preferenceKey, enabled ? 1 : 0);
MagnificationPreferenceFragment.setChecked(getContentResolver(), preferenceKey, enabled);
updateConfigurationWarningIfNeeded();
}
@@ -183,7 +182,7 @@ public class ToggleScreenMagnificationPreferenceFragment extends
super.onInstallSwitchBarToggleSwitch();
mSwitchBar.setCheckedInternal(
Settings.Secure.getInt(getContentResolver(), mPreferenceKey, 0) == 1);
MagnificationPreferenceFragment.isChecked(getContentResolver(), mPreferenceKey));
mSwitchBar.addOnSwitchChangeListener(this);
}