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() {
if (sharedPrefs.getBoolean("simplify_ui_charging", false) && batteryReceiver == null) {
if (sharedPrefs.getString("simplify_ui", "off") == "charching" && batteryReceiver == null) {
IntentFilter intentBatteryFilter = new IntentFilter();
intentBatteryFilter.addAction(BatteryManager.ACTION_CHARGING);
intentBatteryFilter.addAction(BatteryManager.ACTION_DISCHARGING);
@ -306,7 +306,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
public void setDataFields() {
setDateAndTime();
if (setDataFieldsSimpleUi()) {
return;
}
if (mSgv != null) {
if (sharedPrefs.getBoolean("showBG", true)) {
mSgv.setText(rawData.sSgv);
@ -485,11 +487,11 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
mLoop.setVisibility(View.GONE);
}
}
setDataFieldsSimpleUi();
}
void setDataFieldsSimpleUi() {
if (sharedPrefs.getBoolean("simplify_ui_charging", false) && isCharging()) {
boolean setDataFieldsSimpleUi() {
if (isSimpleUi()) {
mSimpleUi.setVisibility(View.VISIBLE);
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);
mSimpleTime.setText(timeFormat.format(System.currentTimeMillis()));
} else {
mSimpleUi.setVisibility(View.GONE);
return true;
}
mSimpleUi.setVisibility(View.GONE);
return false;
}
@Override
@ -598,7 +601,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
}
protected void onWatchModeChanged(WatchMode watchMode) {
setDataFields();
if (lowResMode ^ isLowRes(watchMode)) { //if there was a change in lowResMode
lowResMode = isLowRes(watchMode);
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);
}
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
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
setupBatteryReceiver();
@ -640,6 +657,9 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
}
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
int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3"));
if (lowResMode) {

View file

@ -65,4 +65,16 @@
<item>none</item>
</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>

View file

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

View file

@ -5,16 +5,16 @@
<CheckBoxPreference
android:defaultValue="true"
android:key="show_iob"
android:title="@string/pref_show_iob"
android:summary="Show insulin on board."
android:title="@string/pref_show_iob"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
android:key="show_cob"
android:title="@string/pref_show_cob"
android:summary="Show carb on board."
android:title="@string/pref_show_cob"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
@ -24,7 +24,7 @@
android:summary="Show BG."
android:title="@string/pref_show_bg"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
@ -32,7 +32,7 @@
android:summary="Show delta."
android:title="@string/pref_show_delta"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
@ -40,14 +40,14 @@
android:summary="Show the avgDelta."
android:title="@string/pref_show_avgdelta"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
android:key="show_direction"
android:summary="Show direction arrow"
android:title="@string/pref_show_direction_arrow"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
@ -55,7 +55,7 @@
android:summary="Minutes since last reading."
android:title="@string/pref_show_ago"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
@ -85,15 +85,13 @@
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="highlight_basals"
android:summary="Better visible basal rate and temp basals"
android:title="@string/pref_highlight_basals"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<ListPreference
android:defaultValue="3"
@ -103,14 +101,12 @@
android:summary="Chart Timeframe"
android:title="@string/pref_chart_timeframe" />
<CheckBoxPreference
android:defaultValue="true"
android:key="units_mgdl"
android:title="@string/pref_units_for_actions"
android:summaryOn="mg/dl"
android:summaryOff="mmol/l"
android:summaryOn="mg/dl"
android:title="@string/pref_units_for_actions"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
@ -128,7 +124,7 @@
android:summary="Wizard from watch possible"
android:title="@string/pref_wizard_in_menu"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
@ -143,7 +139,7 @@
android:summary="Prime/Fill from watch possible"
android:title="@string/pref_prime_in_menu"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
@ -151,7 +147,7 @@
android:summary="Single temp-target instead of a range."
android:title="@string/pref_single_target"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
@ -159,9 +155,7 @@
android:summary="Percentage correction."
android:title="@string/pref_wizard_percentage"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<ListPreference
android:defaultValue="default"
@ -177,7 +171,7 @@
android:summary="Use unicode special characters in complications."
android:title="@string/pref_unicode_in_complications"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<info.nightscout.androidaps.interaction.utils.VersionPreference
android:defaultValue="1"

View file

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<wallpaper />
<wallpaper />

View file

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

View file

@ -8,7 +8,7 @@
android:summary="Dark theme"
android:title="@string/pref_dark"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
@ -16,7 +16,7 @@
android:summary="Big numbers. (Circle WF)"
android:title="@string/pref_big_numbers"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
@ -32,7 +32,7 @@
android:summary="Less eyecandy. (Circle WF)"
android:title="@string/pref_light_ring_history"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="true"
@ -40,13 +40,13 @@
android:summary="Animations. (Circle WF)"
android:title="@string/pref_animations"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
</PreferenceScreen>

View file

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

View file

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

View file

@ -8,7 +8,7 @@
android:summary="Dark theme"
android:title="@string/pref_dark"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
@ -16,21 +16,21 @@
android:summary="Status bar divider background matches watchface background"
android:title="@string/pref_matching_divider"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="simplify_ui_charging"
android:summary="@string/pref_simplify_ui_charging_sum"
android:title="@string/pref_simplify_ui_charging"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<ListPreference
android:defaultValue="off"
android:entries="@array/watchface_simplify_ui_name"
android:entryValues="@array/watchface_simplify_ui_values"
android:key="simplify_ui"
android:summary="@string/pref_simplify_ui_sum"
android:title="@string/pref_simplify_ui" />
</PreferenceScreen>

View file

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

View file

@ -8,7 +8,7 @@
android:summary="Dark theme"
android:title="@string/pref_dark"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
@ -16,21 +16,21 @@
android:summary="Status bar divider background matches watchface background"
android:title="@string/pref_matching_divider"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="simplify_ui_charging"
android:summary="@string/pref_simplify_ui_charging_sum"
android:title="@string/pref_simplify_ui_charging"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
<ListPreference
android:defaultValue="off"
android:entries="@array/watchface_simplify_ui_name"
android:entryValues="@array/watchface_simplify_ui_values"
android:key="simplify_ui"
android:summary="@string/pref_simplify_ui_sum"
android:title="@string/pref_simplify_ui" />
</PreferenceScreen>

View file

@ -8,13 +8,14 @@
android:summary="Dark theme"
android:title="@string/pref_dark"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on"/>
app:wear_iconOn="@drawable/settings_on" />
<CheckBoxPreference
android:defaultValue="false"
android:key="vibrate_Hourly"
android:title="@string/pref_vibrate_hourly"
android:defaultValue="false"
app:wear_iconOff="@drawable/settings_off"
app:wear_iconOn="@drawable/settings_on" />
</PreferenceScreen>

View file

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