wear: support simplify ui for ambient mode

This commit is contained in:
Andries Smit 2022-01-04 10:48:57 +01:00
parent 8c06d860e9
commit 06c9920177
14 changed files with 135 additions and 107 deletions

View file

@ -130,7 +130,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
private void setupBatteryReceiver() { private void setupBatteryReceiver() {
if (sharedPrefs.getBoolean("simplify_ui_charging", false) && batteryReceiver == null) { if (sharedPrefs.getString("simplify_ui", "off") == "charching" && batteryReceiver == null) {
IntentFilter intentBatteryFilter = new IntentFilter(); IntentFilter intentBatteryFilter = new IntentFilter();
intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING); intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING);
intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING); intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING);
@ -306,7 +306,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
public void setDataFields() { public void setDataFields() {
setDateAndTime(); setDateAndTime();
if (setDataFieldsSimpleUi()) {
return;
}
if (mSgv != null) { if (mSgv != null) {
if (sharedPrefs.getBoolean("showBG", true)) { if (sharedPrefs.getBoolean("showBG", true)) {
mSgv.setText(rawData.sSgv); mSgv.setText(rawData.sSgv);
@ -485,11 +487,11 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
mLoop.setVisibility(View.GONE); mLoop.setVisibility(View.GONE);
} }
} }
setDataFieldsSimpleUi();
} }
void setDataFieldsSimpleUi() { boolean setDataFieldsSimpleUi() {
if (sharedPrefs.getBoolean("simplify_ui_charging", false) && isCharging()) { if (isSimpleUi()) {
mSimpleUi.setVisibility(View.VISIBLE); mSimpleUi.setVisibility(View.VISIBLE);
mSimpleSvg.setText(rawData.sSgv); mSimpleSvg.setText(rawData.sSgv);
@ -513,9 +515,10 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this); final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
mSimpleTime.setText(timeFormat.format(System.currentTimeMillis())); mSimpleTime.setText(timeFormat.format(System.currentTimeMillis()));
} else { return true;
mSimpleUi.setVisibility(View.GONE);
} }
mSimpleUi.setVisibility(View.GONE);
return false;
} }
@Override @Override
@ -598,7 +601,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
protected void onWatchModeChanged(WatchMode watchMode) { protected void onWatchModeChanged(WatchMode watchMode) {
setDataFields();
if (lowResMode ^ isLowRes(watchMode)) { //if there was a change in lowResMode if (lowResMode ^ isLowRes(watchMode)) { //if there was a change in lowResMode
lowResMode = isLowRes(watchMode); lowResMode = isLowRes(watchMode);
setColor(); setColor();
@ -612,6 +615,20 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN); // || (watchMode == WatchMode.LOW_BIT_BURN_IN); return (watchMode == WatchMode.LOW_BIT) || (watchMode == WatchMode.LOW_BIT_BURN_IN); // || (watchMode == WatchMode.LOW_BIT_BURN_IN);
} }
private boolean isSimpleUi() {
String simplify = sharedPrefs.getString("simplify_ui", "off");
if (simplify.equals("off")) {
return false;
}
if (simplify.equals("ambient") && getCurrentWatchMode() == WatchMode.AMBIENT) {
return true;
}
if (simplify.equals("charging") && isCharging()) {
return true;
}
return false;
}
@Override @Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) { public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
setupBatteryReceiver(); setupBatteryReceiver();
@ -640,6 +657,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
} }
public void setupCharts() { public void setupCharts() {
if (isSimpleUi()) {
return;
}
if (rawData.bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things if (rawData.bgDataList.size() > 0) { //Dont crash things just because we dont have values, people dont like crashy things
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
if (lowResMode) { if (lowResMode) {

View file

@ -65,4 +65,16 @@
<item>none</item> <item>none</item>
</string-array> </string-array>
<string-array name="watchface_simplify_ui_name">
<item>Off</item>
<item>During Charging</item>
<item>Always On Mode</item>
</string-array>
<string-array name="watchface_simplify_ui_values">
<item>off</item>
<item>charging</item>
<item>ambient</item>
</string-array>
</resources> </resources>

View file

@ -136,8 +136,8 @@
<string name="color_name_white">white</string> <string name="color_name_white">white</string>
<string name="color_name_black">black</string> <string name="color_name_black">black</string>
<string name="color_name_multicolor">multicolor</string> <string name="color_name_multicolor">multicolor</string>
<string name="pref_simplify_ui_charging">Simplify Charging UI</string> <string name="pref_simplify_ui">Simplify UI</string>
<string name="pref_simplify_ui_charging_sum">Only show time and BG when charging</string> <string name="pref_simplify_ui_sum">Only show time and BG</string>
<string name="pref_vibrate_hourly">Vibrate hourly</string> <string name="pref_vibrate_hourly">Vibrate hourly</string>

View file

@ -5,16 +5,16 @@
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="show_iob" android:key="show_iob"
android:title="@string/pref_show_iob"
android:summary="Show insulin on board." android:summary="Show insulin on board."
android:title="@string/pref_show_iob"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="show_cob" android:key="show_cob"
android:title="@string/pref_show_cob"
android:summary="Show carb on board." android:summary="Show carb on board."
android:title="@string/pref_show_cob"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
@ -85,8 +85,6 @@
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false" android:defaultValue="false"
android:key="highlight_basals" android:key="highlight_basals"
@ -103,14 +101,12 @@
android:summary="Chart Timeframe" android:summary="Chart Timeframe"
android:title="@string/pref_chart_timeframe" /> android:title="@string/pref_chart_timeframe" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true" android:defaultValue="true"
android:key="units_mgdl" android:key="units_mgdl"
android:title="@string/pref_units_for_actions"
android:summaryOn="mg/dl"
android:summaryOff="mmol/l" android:summaryOff="mmol/l"
android:summaryOn="mg/dl"
android:title="@string/pref_units_for_actions"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
@ -161,8 +157,6 @@
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<ListPreference <ListPreference
android:defaultValue="default" android:defaultValue="default"
android:entries="@array/complication_tap_action" android:entries="@array/complication_tap_action"

View file

@ -12,9 +12,10 @@
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly" android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly" android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
</PreferenceScreen> </PreferenceScreen>

View file

@ -42,11 +42,11 @@
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly" android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly" android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
</PreferenceScreen> </PreferenceScreen>

View file

@ -3,18 +3,18 @@
xmlns:app="http://schemas.android.com/apk/res-auto"> xmlns:app="http://schemas.android.com/apk/res-auto">
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly" android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly" android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <ListPreference
android:defaultValue="false" android:defaultValue="off"
android:key="simplify_ui_charging" android:entries="@array/watchface_simplify_ui_name"
android:summary="@string/pref_simplify_ui_charging_sum" android:entryValues="@array/watchface_simplify_ui_values"
android:title="@string/pref_simplify_ui_charging" android:key="simplify_ui"
app:wear_iconOff="@drawable/settings_off" android:summary="@string/pref_simplify_ui_sum"
app:wear_iconOn="@drawable/settings_on" /> android:title="@string/pref_simplify_ui" />
</PreferenceScreen> </PreferenceScreen>

View file

@ -4,59 +4,59 @@
<ListPreference <ListPreference
android:key="digitalstyle_frameStyle"
android:title="@string/digitalstyle_pref_your_style"
android:defaultValue="full" android:defaultValue="full"
android:entries="@array/digitalstyle_styles_name" android:entries="@array/digitalstyle_styles_name"
android:entryValues="@array/digitalstyle_styles_values"/> android:entryValues="@array/digitalstyle_styles_values"
android:key="digitalstyle_frameStyle"
android:title="@string/digitalstyle_pref_your_style" />
<ListPreference <ListPreference
android:key="digitalstyle_frameColor"
android:title="@string/digitalstyle_pref_your_color"
android:defaultValue="red" android:defaultValue="red"
android:entries="@array/digitalstyle_color_name" android:entries="@array/digitalstyle_color_name"
android:entryValues="@array/digitalstyle_color_values"/> android:entryValues="@array/digitalstyle_color_values"
android:key="digitalstyle_frameColor"
android:title="@string/digitalstyle_pref_your_color" />
<ListPreference <ListPreference
android:key="digitalstyle_frameColorSaturation"
android:title="@string/digitalstyle_pref_your_color_saturation"
android:defaultValue="700" android:defaultValue="700"
android:entries="@array/digitalstyle_color_saturation" android:entries="@array/digitalstyle_color_saturation"
android:entryValues="@array/digitalstyle_color_saturation"/> android:entryValues="@array/digitalstyle_color_saturation"
android:key="digitalstyle_frameColorSaturation"
android:title="@string/digitalstyle_pref_your_color_saturation" />
<ListPreference <ListPreference
android:key="digitalstyle_frameColorOpacity"
android:title="@string/digitalstyle_pref_your_color_opacity"
android:defaultValue="1" android:defaultValue="1"
android:entries="@array/digitalstyle_color_opacity_name" android:entries="@array/digitalstyle_color_opacity_name"
android:entryValues="@array/digitalstyle_color_opacity_value"/> android:entryValues="@array/digitalstyle_color_opacity_value"
android:key="digitalstyle_frameColorOpacity"
android:title="@string/digitalstyle_pref_your_color_opacity" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="true"
android:key="show_date" android:key="show_date"
android:title="@string/pref_show_date" android:title="@string/pref_show_date"
android:defaultValue="true"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="show_weeknumber" android:key="show_weeknumber"
android:title="@string/pref_show_weeknumber" android:title="@string/pref_show_weeknumber"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly" android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly" android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <ListPreference
android:defaultValue="false" android:defaultValue="off"
android:key="simplify_ui_charging" android:entries="@array/watchface_simplify_ui_name"
android:summary="@string/pref_simplify_ui_charging_sum" android:entryValues="@array/watchface_simplify_ui_values"
android:title="@string/pref_simplify_ui_charging" android:key="simplify_ui"
app:wear_iconOff="@drawable/settings_off" android:summary="@string/pref_simplify_ui_sum"
app:wear_iconOn="@drawable/settings_on" /> android:title="@string/pref_simplify_ui" />
</PreferenceScreen> </PreferenceScreen>

View file

@ -19,18 +19,18 @@
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly" android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly" android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <ListPreference
android:defaultValue="false" android:defaultValue="off"
android:key="simplify_ui_charging" android:entries="@array/watchface_simplify_ui_name"
android:summary="@string/pref_simplify_ui_charging_sum" android:entryValues="@array/watchface_simplify_ui_values"
android:title="@string/pref_simplify_ui_charging" android:key="simplify_ui"
app:wear_iconOff="@drawable/settings_off" android:summary="@string/pref_simplify_ui_sum"
app:wear_iconOn="@drawable/settings_on" /> android:title="@string/pref_simplify_ui" />
</PreferenceScreen> </PreferenceScreen>

View file

@ -32,12 +32,12 @@
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <ListPreference
android:defaultValue="false" android:defaultValue="off"
android:key="simplify_ui_charging" android:entries="@array/watchface_simplify_ui_name"
android:summary="@string/pref_simplify_ui_charging_sum" android:entryValues="@array/watchface_simplify_ui_values"
android:title="@string/pref_simplify_ui_charging" android:key="simplify_ui"
app:wear_iconOff="@drawable/settings_off" android:summary="@string/pref_simplify_ui_sum"
app:wear_iconOn="@drawable/settings_on" /> android:title="@string/pref_simplify_ui" />
</PreferenceScreen> </PreferenceScreen>

View file

@ -19,18 +19,18 @@
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly" android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly" android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <ListPreference
android:defaultValue="false" android:defaultValue="off"
android:key="simplify_ui_charging" android:entries="@array/watchface_simplify_ui_name"
android:summary="@string/pref_simplify_ui_charging_sum" android:entryValues="@array/watchface_simplify_ui_values"
android:title="@string/pref_simplify_ui_charging" android:key="simplify_ui"
app:wear_iconOff="@drawable/settings_off" android:summary="@string/pref_simplify_ui_sum"
app:wear_iconOn="@drawable/settings_on" /> android:title="@string/pref_simplify_ui" />
</PreferenceScreen> </PreferenceScreen>

View file

@ -12,9 +12,10 @@
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly" android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly" android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
</PreferenceScreen> </PreferenceScreen>

View file

@ -11,18 +11,18 @@
android:title="@string/pref_delta_granularity" /> android:title="@string/pref_delta_granularity" />
<CheckBoxPreference <CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly" android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly" android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off" app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" /> app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference <ListPreference
android:defaultValue="false" android:defaultValue="off"
android:key="simplify_ui_charging" android:entries="@array/watchface_simplify_ui_name"
android:summary="@string/pref_simplify_ui_charging_sum" android:entryValues="@array/watchface_simplify_ui_values"
android:title="@string/pref_simplify_ui_charging" android:key="simplify_ui"
app:wear_iconOff="@drawable/settings_off" android:summary="@string/pref_simplify_ui_sum"
app:wear_iconOn="@drawable/settings_on" /> android:title="@string/pref_simplify_ui" />
</PreferenceScreen> </PreferenceScreen>