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-12-01 00:25:01 +05:30
committed by Hưng Phan
parent d4f0414cf6
commit fe88dd2014
3 changed files with 36 additions and 0 deletions

View File

@@ -859,5 +859,7 @@
<!-- QS Footer Text --> <!-- QS Footer Text -->
<string name="qs_footer_text_title">QS footer text</string> <string name="qs_footer_text_title">QS footer text</string>
<string name="qs_footer_text_summary">Display text at bottom of QS panel</string> <string name="qs_footer_text_summary">Display text at bottom of QS panel</string>
<string name="qs_footer_text_string_title">Customize footer text</string>
<string name="qs_footer_text_string_summary">Set to empty for default #KeepTheLove</string>
</resources> </resources>

View File

@@ -32,6 +32,15 @@
android:summary="@string/qs_footer_text_summary" android:summary="@string/qs_footer_text_summary"
android:defaultValue="false"/> android:defaultValue="false"/>
<!-- QS footer text string -->
<com.cherish.settings.preferences.SystemSettingEditTextPreference
android:key="footer_text_string"
android:icon="@drawable/ic_edit"
android:title="@string/qs_footer_text_string_title"
android:summary="@string/qs_footer_text_string_summary"
android:dependency="omni_footer_text_show"
android:defaultValue="#KeeptheLove" />
<!-- QS brightness slider --> <!-- QS brightness slider -->
<com.cherish.settings.preferences.SystemSettingMasterSwitchPreference <com.cherish.settings.preferences.SystemSettingMasterSwitchPreference
android:key="qs_show_brightness" android:key="qs_show_brightness"

View File

@@ -33,8 +33,10 @@ public class QuickSettings extends SettingsPreferenceFragment implements
OnPreferenceChangeListener { OnPreferenceChangeListener {
private static final String BRIGHTNESS_SLIDER = "qs_show_brightness"; private static final String BRIGHTNESS_SLIDER = "qs_show_brightness";
private static final String FOOTER_TEXT_STRING = "footer_text_string";
private SystemSettingMasterSwitchPreference mBrightnessSlider; private SystemSettingMasterSwitchPreference mBrightnessSlider;
private SystemSettingEditTextPreference mFooterString;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@@ -51,6 +53,18 @@ public class QuickSettings extends SettingsPreferenceFragment implements
boolean enabled = Settings.System.getInt(resolver, boolean enabled = Settings.System.getInt(resolver,
BRIGHTNESS_SLIDER, 1) == 1; BRIGHTNESS_SLIDER, 1) == 1;
mBrightnessSlider.setChecked(enabled); mBrightnessSlider.setChecked(enabled);
mFooterString = (SystemSettingEditTextPreference) findPreference(FOOTER_TEXT_STRING);
mFooterString.setOnPreferenceChangeListener(this);
String footerString = Settings.System.getString(getContentResolver(),
FOOTER_TEXT_STRING);
if (footerString != null && footerString != "")
mFooterString.setText(footerString);
else {
mFooterString.setText("#KeepTheLove");
Settings.System.putString(getActivity().getContentResolver(),
Settings.System.FOOTER_TEXT_STRING, "#KeepTheLove");
}
} }
@Override @Override
@@ -61,6 +75,17 @@ public class QuickSettings extends SettingsPreferenceFragment implements
Settings.System.putInt(resolver, Settings.System.putInt(resolver,
BRIGHTNESS_SLIDER, value ? 1 : 0); BRIGHTNESS_SLIDER, value ? 1 : 0);
return true; return true;
} else if (preference == mFooterString) {
String value = (String) newValue;
if (value != "" && value != null)
Settings.System.putString(getActivity().getContentResolver(),
Settings.System.FOOTER_TEXT_STRING, value);
else {
mFooterString.setText("#KeepTheLove");
Settings.System.putString(getActivity().getContentResolver(),
Settings.System.FOOTER_TEXT_STRING, "#KeepTheLove");
}
return true;
} }
return false; return false;
} }