Cherish: Allow customizing footer text [2/2]

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Ido Ben-Hur
2019-11-28 15:27:23 +02:00
committed by Hưng Phan
parent 0b61f74039
commit fdc85e21ef
3 changed files with 46 additions and 0 deletions

View File

@@ -471,4 +471,9 @@
<!-- Sb Icon Style --> <!-- Sb Icon Style -->
<string name="statusbar_icons_style">Colored Statusbar Icons</string> <string name="statusbar_icons_style">Colored Statusbar Icons</string>
<string name="statusbar_icons_style_summary">Choose the style of your statusbar icons (requires SystemUI restart)</string> <string name="statusbar_icons_style_summary">Choose the style of your statusbar icons (requires SystemUI restart)</string>
<!-- QS footer text -->
<string name="qs_footer_text_show_title">Show QS footer text</string>
<string name="qs_footer_text_string_title">Customize footer text</string>
<string name="qs_footer_text_string_summary">Set to empty for default TheKeepLove</string>
</resources> </resources>

View File

@@ -21,6 +21,20 @@
<PreferenceCategory <PreferenceCategory
android:title="@string/qs_title"> android:title="@string/qs_title">
<!-- QS footer text toggle -->
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="qs_footer_text_show"
android:title="@string/qs_footer_text_show_title"
android:defaultValue="false" />
<!-- QS footer text string -->
<com.cherish.settings.preferences.SystemSettingEditTextPreference
android:key="qs_footer_text_string"
android:title="@string/qs_footer_text_string_title"
android:summary="@string/qs_footer_text_string_summary"
android:dependency="qs_footer_text_show"
android:defaultValue="TheKeepLove" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference <com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="qs_show_battery_estimate" android:key="qs_show_battery_estimate"
android:title="@string/qs_show_battery_estimate_title" android:title="@string/qs_show_battery_estimate_title"

View File

@@ -37,6 +37,10 @@ import java.util.ArrayList;
public class QuickSettings extends SettingsPreferenceFragment implements public class QuickSettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener { OnPreferenceChangeListener {
private static final String QS_FOOTER_TEXT_STRING = "qs_footer_text_string";
private SystemSettingEditTextPreference mFooterString;
private ListPreference mQuickPulldown; private ListPreference mQuickPulldown;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@@ -53,6 +57,18 @@ public class QuickSettings extends SettingsPreferenceFragment implements
mQuickPulldown.setValue(String.valueOf(qpmode)); mQuickPulldown.setValue(String.valueOf(qpmode));
mQuickPulldown.setSummary(mQuickPulldown.getEntry()); mQuickPulldown.setSummary(mQuickPulldown.getEntry());
mQuickPulldown.setOnPreferenceChangeListener(this); mQuickPulldown.setOnPreferenceChangeListener(this);
mFooterString = (SystemSettingEditTextPreference) findPreference(QS_FOOTER_TEXT_STRING);
mFooterString.setOnPreferenceChangeListener(this);
String footerString = Settings.System.getString(getContentResolver(),
QS_FOOTER_TEXT_STRING);
if (footerString != null && !footerString.isEmpty())
mFooterString.setText(footerString);
else {
mFooterString.setText("TheKeepLove");
Settings.System.putString(getActivity().getContentResolver(),
Settings.System.QS_FOOTER_TEXT_STRING, "TheKeepLove");
}
} }
@Override @Override
@@ -66,6 +82,17 @@ public class QuickSettings extends SettingsPreferenceFragment implements
int index = mQuickPulldown.findIndexOfValue((String) newValue); int index = mQuickPulldown.findIndexOfValue((String) newValue);
mQuickPulldown.setSummary( mQuickPulldown.setSummary(
mQuickPulldown.getEntries()[index]); mQuickPulldown.getEntries()[index]);
return true;
} else if (preference == mFooterString) {
String value = (String) newValue;
if (value != "" && !value.isEmpty())
Settings.System.putString(getActivity().getContentResolver(),
Settings.System.QS_FOOTER_TEXT_STRING, value);
else {
mFooterString.setText("TheKeepLove");
Settings.System.putString(getActivity().getContentResolver(),
Settings.System.QS_FOOTER_TEXT_STRING, "TheKeepLove");
}
return true; return true;
} }
return false; return false;