Cherish: Introduce Battery Landscape | Left Battery Text [2/2]
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -867,6 +867,8 @@
|
|||||||
<!-- Battery -->
|
<!-- Battery -->
|
||||||
<string-array name="status_bar_battery_style_entries" translatable="false">
|
<string-array name="status_bar_battery_style_entries" translatable="false">
|
||||||
<item>@string/status_bar_battery_style_icon_portrait</item>
|
<item>@string/status_bar_battery_style_icon_portrait</item>
|
||||||
|
<item>@string/status_bar_battery_style_icon_rlandscape</item>
|
||||||
|
<item>@string/status_bar_battery_style_icon_landscape</item>
|
||||||
<item>@string/status_bar_battery_style_circle</item>
|
<item>@string/status_bar_battery_style_circle</item>
|
||||||
<item>@string/status_bar_battery_style_dotted_circle</item>
|
<item>@string/status_bar_battery_style_dotted_circle</item>
|
||||||
<item>@string/status_bar_battery_style_filled_circle</item>
|
<item>@string/status_bar_battery_style_filled_circle</item>
|
||||||
@@ -881,6 +883,8 @@
|
|||||||
<item>3</item>
|
<item>3</item>
|
||||||
<item>4</item>
|
<item>4</item>
|
||||||
<item>5</item>
|
<item>5</item>
|
||||||
|
<item>6</item>
|
||||||
|
<item>7</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- Status bar logo position -->
|
<!-- Status bar logo position -->
|
||||||
|
|||||||
@@ -836,17 +836,21 @@
|
|||||||
<string name="battery_percent_summary">Configure icon and text styles for the statusbar battery indicator</string>
|
<string name="battery_percent_summary">Configure icon and text styles for the statusbar battery indicator</string>
|
||||||
<string name="status_bar_battery_style_title">Battery style</string>
|
<string name="status_bar_battery_style_title">Battery style</string>
|
||||||
<string name="status_bar_battery_style_icon_portrait">Icon portrait</string>
|
<string name="status_bar_battery_style_icon_portrait">Icon portrait</string>
|
||||||
<string name="status_bar_battery_style_circle">Circle</string>
|
<string name="status_bar_battery_style_icon_rlandscape">Icon landscape R</string>
|
||||||
<string name="status_bar_battery_style_dotted_circle">Dotted circle</string>
|
<string name="status_bar_battery_style_icon_landscape">Icon landscape L</string>
|
||||||
|
<string name="status_bar_battery_style_circle">Circle (Dotted)</string>
|
||||||
|
<string name="status_bar_battery_style_dotted_circle">Circle</string>
|
||||||
<string name="status_bar_battery_style_filled_circle">Filled circle</string>
|
<string name="status_bar_battery_style_filled_circle">Filled circle</string>
|
||||||
<string name="status_bar_battery_style_text">Text</string>
|
<string name="status_bar_battery_style_text">Text</string>
|
||||||
<string name="status_bar_battery_style_hidden">Hidden</string>
|
<string name="status_bar_battery_style_hidden">Hidden</string>
|
||||||
<string name="status_bar_battery_percentage_title">Battery percentage</string>
|
<string name="status_bar_battery_percentage_title">Battery percentage</string>
|
||||||
<string name="status_bar_battery_percentage_default">Hidden</string>
|
<string name="status_bar_battery_percentage_default">Hidden</string>
|
||||||
<string name="status_bar_battery_percentage_text_inside">Inside the icon</string>
|
<string name="status_bar_battery_percentage_text_inside">Inside the icon</string>
|
||||||
<string name="status_bar_battery_percentage_text_next">Next to the icon</string>
|
<string name="status_bar_battery_percentage_text_next">Outside the icon</string>
|
||||||
<string name="qs_battery_percentage_title">QS battery percentage</string>
|
<string name="qs_battery_percentage_title">QS battery percentage</string>
|
||||||
<string name="qs_battery_percentage_summary">Show battery percentage in the QS header instead of battery estimate</string>
|
<string name="qs_battery_percentage_summary">Show battery percentage in the QS header instead of battery estimate</string>
|
||||||
|
<string name="left_battery_text_title">Left battery text</string>
|
||||||
|
<string name="left_battery_text_summary">Put the battery text on left of battery icon</string>
|
||||||
|
|
||||||
<string name="qs_media_player_title">QS Media player</string>
|
<string name="qs_media_player_title">QS Media player</string>
|
||||||
<string name="qs_media_player_summary_on">Show media player in QS.\nRequires a SystemUI restart</string>
|
<string name="qs_media_player_summary_on">Show media player in QS.\nRequires a SystemUI restart</string>
|
||||||
|
|||||||
@@ -29,6 +29,12 @@
|
|||||||
android:entryValues="@array/status_bar_battery_style_values"
|
android:entryValues="@array/status_bar_battery_style_values"
|
||||||
android:defaultValue="0" />
|
android:defaultValue="0" />
|
||||||
|
|
||||||
|
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||||
|
android:key="do_left_battery_text"
|
||||||
|
android:title="@string/left_battery_text_title"
|
||||||
|
android:summary="@string/left_battery_text_summary"
|
||||||
|
android:defaultValue="false"/>
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:key="status_bar_show_battery_percent"
|
android:key="status_bar_show_battery_percent"
|
||||||
android:title="@string/status_bar_battery_percentage_title"
|
android:title="@string/status_bar_battery_percentage_title"
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ import com.android.settings.search.BaseSearchIndexProvider;
|
|||||||
import com.android.settingslib.search.SearchIndexable;
|
import com.android.settingslib.search.SearchIndexable;
|
||||||
import com.cherish.settings.preferences.SystemSettingListPreference;
|
import com.cherish.settings.preferences.SystemSettingListPreference;
|
||||||
|
|
||||||
|
import com.cherish.settings.preferences.SystemSettingSwitchPreference;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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 STATUS_BAR_SHOW_BATTERY_PERCENT = "status_bar_show_battery_percent";
|
||||||
private static final String TEXT_CHARGING_SYMBOL = "text_charging_symbol";
|
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 mBatteryPercent;
|
||||||
private ListPreference mBatteryStyle;
|
private ListPreference mBatteryStyle;
|
||||||
private SystemSettingListPreference mChargingSymbol;
|
private SystemSettingListPreference mChargingSymbol;
|
||||||
private SwitchPreference mQsBatteryPercent;
|
private SwitchPreference mQsBatteryPercent;
|
||||||
private int mBatteryPercentValue;
|
private int mBatteryPercentValue;
|
||||||
|
|
||||||
|
private SystemSettingSwitchPreference mLeftBatteryText;
|
||||||
|
|
||||||
private static final int BATTERY_STYLE_PORTRAIT = 0;
|
private static final int BATTERY_STYLE_PORTRAIT = 0;
|
||||||
private static final int BATTERY_STYLE_TEXT = 4;
|
private static final int BATTERY_STYLE_TEXT = 6;
|
||||||
private static final int BATTERY_STYLE_HIDDEN = 5;
|
private static final int BATTERY_STYLE_HIDDEN = 7;
|
||||||
private static final int BATTERY_PERCENT_HIDDEN = 0;
|
private static final int BATTERY_PERCENT_HIDDEN = 0;
|
||||||
//private static final int BATTERY_PERCENT_SHOW_INSIDE = 1;
|
//private static final int BATTERY_PERCENT_SHOW_INSIDE = 1;
|
||||||
//private static final int BATTERY_PERCENT_SHOW_OUTSIDE = 2;
|
//private static final int BATTERY_PERCENT_SHOW_OUTSIDE = 2;
|
||||||
@@ -67,6 +73,7 @@ public class StatusbarBatterySettings extends SettingsPreferenceFragment impleme
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.cherish_settings_statusbar_battery);
|
addPreferencesFromResource(R.xml.cherish_settings_statusbar_battery);
|
||||||
|
final ContentResolver resolver = getActivity().getContentResolver();
|
||||||
|
|
||||||
int batterystyle = Settings.System.getIntForUser(getContentResolver(),
|
int batterystyle = Settings.System.getIntForUser(getContentResolver(),
|
||||||
Settings.System.STATUS_BAR_BATTERY_STYLE, BATTERY_STYLE_PORTRAIT, UserHandle.USER_CURRENT);
|
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.setSummary(mBatteryStyle.getEntry());
|
||||||
mBatteryStyle.setOnPreferenceChangeListener(this);
|
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(),
|
mBatteryPercentValue = Settings.System.getIntForUser(getContentResolver(),
|
||||||
Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, BATTERY_PERCENT_HIDDEN, UserHandle.USER_CURRENT);
|
Settings.System.STATUS_BAR_SHOW_BATTERY_PERCENT, BATTERY_PERCENT_HIDDEN, UserHandle.USER_CURRENT);
|
||||||
mBatteryPercent = (ListPreference) findPreference("status_bar_show_battery_percent");
|
mBatteryPercent = (ListPreference) findPreference("status_bar_show_battery_percent");
|
||||||
@@ -107,6 +119,8 @@ public class StatusbarBatterySettings extends SettingsPreferenceFragment impleme
|
|||||||
mBatteryStyle.setSummary(mBatteryStyle.getEntries()[index]);
|
mBatteryStyle.setSummary(mBatteryStyle.getEntries()[index]);
|
||||||
mBatteryPercent.setEnabled(
|
mBatteryPercent.setEnabled(
|
||||||
batterystyle != BATTERY_STYLE_TEXT && batterystyle != BATTERY_STYLE_HIDDEN);
|
batterystyle != BATTERY_STYLE_TEXT && batterystyle != BATTERY_STYLE_HIDDEN);
|
||||||
|
mLeftBatteryText.setEnabled(
|
||||||
|
batterystyle != BATTERY_STYLE_TEXT && batterystyle != BATTERY_STYLE_HIDDEN);
|
||||||
mChargingSymbol.setEnabled(
|
mChargingSymbol.setEnabled(
|
||||||
batterystyle != BATTERY_STYLE_PORTRAIT && batterystyle != BATTERY_STYLE_HIDDEN);
|
batterystyle != BATTERY_STYLE_PORTRAIT && batterystyle != BATTERY_STYLE_HIDDEN);
|
||||||
return true;
|
return true;
|
||||||
@@ -123,6 +137,11 @@ public class StatusbarBatterySettings extends SettingsPreferenceFragment impleme
|
|||||||
Settings.System.QS_SHOW_BATTERY_PERCENT,
|
Settings.System.QS_SHOW_BATTERY_PERCENT,
|
||||||
(Boolean) newValue ? 1 : 0);
|
(Boolean) newValue ? 1 : 0);
|
||||||
return true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user