Cherish: Introduce Battery Landscape | Left Battery Text [2/2]
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -38,6 +38,8 @@ import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.cherish.settings.preferences.SystemSettingListPreference;
|
||||
|
||||
import com.cherish.settings.preferences.SystemSettingSwitchPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -50,15 +52,19 @@ public class StatusbarBatterySettings extends SettingsPreferenceFragment impleme
|
||||
private static final String STATUS_BAR_SHOW_BATTERY_PERCENT = "status_bar_show_battery_percent";
|
||||
private static final String TEXT_CHARGING_SYMBOL = "text_charging_symbol";
|
||||
|
||||
private static final String LEFT_BATTERY_TEXT = "do_left_battery_text";
|
||||
|
||||
private ListPreference mBatteryPercent;
|
||||
private ListPreference mBatteryStyle;
|
||||
private SystemSettingListPreference mChargingSymbol;
|
||||
private SwitchPreference mQsBatteryPercent;
|
||||
private int mBatteryPercentValue;
|
||||
|
||||
private SystemSettingSwitchPreference mLeftBatteryText;
|
||||
|
||||
private static final int BATTERY_STYLE_PORTRAIT = 0;
|
||||
private static final int BATTERY_STYLE_TEXT = 4;
|
||||
private static final int BATTERY_STYLE_HIDDEN = 5;
|
||||
private static final int BATTERY_STYLE_TEXT = 6;
|
||||
private static final int BATTERY_STYLE_HIDDEN = 7;
|
||||
private static final int BATTERY_PERCENT_HIDDEN = 0;
|
||||
//private static final int BATTERY_PERCENT_SHOW_INSIDE = 1;
|
||||
//private static final int BATTERY_PERCENT_SHOW_OUTSIDE = 2;
|
||||
@@ -67,6 +73,7 @@ public class StatusbarBatterySettings extends SettingsPreferenceFragment impleme
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.cherish_settings_statusbar_battery);
|
||||
final ContentResolver resolver = getActivity().getContentResolver();
|
||||
|
||||
int batterystyle = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.STATUS_BAR_BATTERY_STYLE, BATTERY_STYLE_PORTRAIT, UserHandle.USER_CURRENT);
|
||||
@@ -75,6 +82,11 @@ public class StatusbarBatterySettings extends SettingsPreferenceFragment impleme
|
||||
mBatteryStyle.setSummary(mBatteryStyle.getEntry());
|
||||
mBatteryStyle.setOnPreferenceChangeListener(this);
|
||||
|
||||
mLeftBatteryText = (SystemSettingSwitchPreference) findPreference(LEFT_BATTERY_TEXT);
|
||||
mLeftBatteryText.setChecked((Settings.System.getInt(resolver,
|
||||
Settings.System.DO_LEFT_BATTERY_TEXT, 0) == 1));
|
||||
mLeftBatteryText.setOnPreferenceChangeListener(this);
|
||||
|
||||
mBatteryPercentValue = Settings.System.getIntForUser(getContentResolver(),
|
||||
Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, BATTERY_PERCENT_HIDDEN, UserHandle.USER_CURRENT);
|
||||
mBatteryPercent = (ListPreference) findPreference("status_bar_show_battery_percent");
|
||||
@@ -107,6 +119,8 @@ public class StatusbarBatterySettings extends SettingsPreferenceFragment impleme
|
||||
mBatteryStyle.setSummary(mBatteryStyle.getEntries()[index]);
|
||||
mBatteryPercent.setEnabled(
|
||||
batterystyle != BATTERY_STYLE_TEXT && batterystyle != BATTERY_STYLE_HIDDEN);
|
||||
mLeftBatteryText.setEnabled(
|
||||
batterystyle != BATTERY_STYLE_TEXT && batterystyle != BATTERY_STYLE_HIDDEN);
|
||||
mChargingSymbol.setEnabled(
|
||||
batterystyle != BATTERY_STYLE_PORTRAIT && batterystyle != BATTERY_STYLE_HIDDEN);
|
||||
return true;
|
||||
@@ -123,6 +137,11 @@ public class StatusbarBatterySettings extends SettingsPreferenceFragment impleme
|
||||
Settings.System.QS_SHOW_BATTERY_PERCENT,
|
||||
(Boolean) newValue ? 1 : 0);
|
||||
return true;
|
||||
} else if (preference == mLeftBatteryText) {
|
||||
boolean value = (Boolean) newValue;
|
||||
Settings.System.putInt(resolver,
|
||||
Settings.System.DO_LEFT_BATTERY_TEXT, value ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user