mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Zendure Solarflow: support always on display setting
(rename previous devicesettings_always_on_display.xml to devicesettings_always_on_display_mode.xml)
This commit is contained in:
+1
@@ -152,6 +152,7 @@ public class DeviceSettingsPreferenceConst {
|
||||
public static final String PREF_DISPLAY_ON_LIFT_END = "display_on_lift_end";
|
||||
public static final String PREF_DISPLAY_ON_LIFT_SENSITIVITY = "display_on_lift_sensitivity";
|
||||
|
||||
public static final String PREF_ALWAYS_ON_DISPLAY = "always_on_display";
|
||||
public static final String PREF_ALWAYS_ON_DISPLAY_MODE = "always_on_display_mode";
|
||||
public static final String PREF_ALWAYS_ON_DISPLAY_START = "always_on_display_start";
|
||||
public static final String PREF_ALWAYS_ON_DISPLAY_END = "always_on_display_end";
|
||||
|
||||
+1
@@ -953,6 +953,7 @@ public class DeviceSpecificSettingsFragment extends AbstractPreferenceFragment i
|
||||
addPreferenceHandlerFor(PREF_GPS_SATELLITE_SEARCH);
|
||||
addPreferenceHandlerFor(PREF_AGPS_EXPIRY_REMINDER_ENABLED);
|
||||
addPreferenceHandlerFor(PREF_AGPS_EXPIRY_REMINDER_TIME);
|
||||
addPreferenceHandlerFor(PREF_ALWAYS_ON_DISPLAY);
|
||||
addPreferenceHandlerFor(PREF_ALWAYS_ON_DISPLAY_FOLLOW_WATCHFACE);
|
||||
addPreferenceHandlerFor(PREF_ALWAYS_ON_DISPLAY_STYLE);
|
||||
addPreferenceHandlerFor(PREF_WEARDIRECTION);
|
||||
|
||||
+1
-1
@@ -444,7 +444,7 @@ public abstract class ZeppOsCoordinator extends HuamiCoordinator {
|
||||
display.add(R.xml.devicesettings_liftwrist_display_sensitivity_with_smart);
|
||||
display.add(R.xml.devicesettings_password);
|
||||
display.add(R.xml.devicesettings_huami2021_watchface);
|
||||
display.add(R.xml.devicesettings_always_on_display);
|
||||
display.add(R.xml.devicesettings_always_on_display_mode);
|
||||
display.add(R.xml.devicesettings_screen_timeout);
|
||||
if (supportsAutoBrightness(device)) {
|
||||
display.add(R.xml.devicesettings_screen_brightness_withauto);
|
||||
|
||||
+2
-1
@@ -97,7 +97,8 @@ public class SolarFlowDeviceCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
R.xml.devicesettings_battery_minimum_charge,
|
||||
R.xml.devicesettings_battery_maximum_charge,
|
||||
R.xml.devicesettings_output_power_grid,
|
||||
R.xml.devicesettings_offgrid_mode_on_off_eco
|
||||
R.xml.devicesettings_offgrid_mode_on_off_eco,
|
||||
R.xml.devicesettings_always_on_display,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -16,6 +16,7 @@
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.zendure;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_ALWAYS_ON_DISPLAY;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BATTERY_MAXIMUM_CHARGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_BATTERY_MINIMUM_CHARGE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_OFFGRID_MODE;
|
||||
@@ -69,6 +70,8 @@ public class SolarFlowDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
private int electricLevel = -1;
|
||||
private String deviceId;
|
||||
private int firmwareVersion = -1;
|
||||
private int lampSwitch = -1;
|
||||
|
||||
private boolean isSettingsSynced = false;
|
||||
|
||||
|
||||
@@ -189,6 +192,10 @@ public class SolarFlowDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
};
|
||||
sendWriteProperty("gridOffMode", gridOffMode);
|
||||
}
|
||||
case PREF_ALWAYS_ON_DISPLAY -> {
|
||||
boolean lampSwitch = devicePrefs.getBoolean(PREF_ALWAYS_ON_DISPLAY, true);
|
||||
sendWriteProperty("lampSwitch", lampSwitch ? 1 : 0);
|
||||
}
|
||||
default -> LOG.warn("Unknown config changed: {}", config);
|
||||
}
|
||||
}
|
||||
@@ -266,6 +273,9 @@ public class SolarFlowDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
getDevice().sendDeviceUpdateIntent(getContext());
|
||||
}
|
||||
}
|
||||
if (properties.has("lampSwitch")) {
|
||||
lampSwitch = properties.getInt("lampSwitch");
|
||||
}
|
||||
|
||||
} catch (JSONException e) {
|
||||
LOG.error("JSON error while parsing report: {}", e.getMessage());
|
||||
@@ -319,6 +329,7 @@ public class SolarFlowDeviceSupport extends AbstractBTLESingleDeviceSupport {
|
||||
devicePrefsEdit.putString(PREF_BATTERY_MINIMUM_CHARGE, String.valueOf(minSoc/10));
|
||||
devicePrefsEdit.putString(PREF_BATTERY_MAXIMUM_CHARGE, String.valueOf(socSet/10));
|
||||
devicePrefsEdit.putString(PREF_OUTPUT_POWER_GRID, String.valueOf(outputLimit));
|
||||
devicePrefsEdit.putBoolean(PREF_ALWAYS_ON_DISPLAY, lampSwitch != 0);
|
||||
String offGridMode = switch (gridOffMode) {
|
||||
case 0 -> "on";
|
||||
case 1 -> "eco";
|
||||
|
||||
@@ -1,46 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceScreen
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:icon="@drawable/ic_always_on_display"
|
||||
android:key="pref_screen_always_on_display"
|
||||
android:persistent="false"
|
||||
android:summary="@string/prefs_always_on_display_summary"
|
||||
android:title="@string/prefs_always_on_display">
|
||||
|
||||
<!-- workaround for missing toolbar -->
|
||||
<PreferenceCategory android:title="@string/prefs_always_on_display" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/p_off"
|
||||
android:entries="@array/always_on_display"
|
||||
android:entryValues="@array/always_on_display_values"
|
||||
android:key="always_on_display_mode"
|
||||
app:useSimpleSummaryProvider="true"
|
||||
android:title="@string/prefs_always_on_display" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
android:defaultValue="00:00"
|
||||
android:key="always_on_display_start"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_start" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
android:defaultValue="00:00"
|
||||
android:key="always_on_display_end"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_end" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="always_on_display_follow_watchface"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/prefs_always_on_display_follow_watchface" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue=""
|
||||
android:entries="@array/pref_huami2021_empty_array"
|
||||
android:entryValues="@array/pref_huami2021_empty_array"
|
||||
android:key="always_on_display_style"
|
||||
app:useSimpleSummaryProvider="true"
|
||||
android:title="@string/prefs_always_on_display_style" />
|
||||
</PreferenceScreen>
|
||||
android:key="always_on_display"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/prefs_always_on_display" />
|
||||
</androidx.preference.PreferenceScreen>
|
||||
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<PreferenceScreen
|
||||
android:icon="@drawable/ic_always_on_display"
|
||||
android:key="pref_screen_always_on_display"
|
||||
android:persistent="false"
|
||||
android:summary="@string/prefs_always_on_display_summary"
|
||||
android:title="@string/prefs_always_on_display">
|
||||
|
||||
<!-- workaround for missing toolbar -->
|
||||
<PreferenceCategory android:title="@string/prefs_always_on_display" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="@string/p_off"
|
||||
android:entries="@array/always_on_display"
|
||||
android:entryValues="@array/always_on_display_values"
|
||||
android:key="always_on_display_mode"
|
||||
app:useSimpleSummaryProvider="true"
|
||||
android:title="@string/prefs_always_on_display" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
android:defaultValue="00:00"
|
||||
android:key="always_on_display_start"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_start" />
|
||||
|
||||
<nodomain.freeyourgadget.gadgetbridge.util.XTimePreference
|
||||
android:defaultValue="00:00"
|
||||
android:key="always_on_display_end"
|
||||
android:title="@string/mi2_prefs_do_not_disturb_end" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="always_on_display_follow_watchface"
|
||||
android:layout="@layout/preference_checkbox"
|
||||
android:title="@string/prefs_always_on_display_follow_watchface" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue=""
|
||||
android:entries="@array/pref_huami2021_empty_array"
|
||||
android:entryValues="@array/pref_huami2021_empty_array"
|
||||
android:key="always_on_display_style"
|
||||
app:useSimpleSummaryProvider="true"
|
||||
android:title="@string/prefs_always_on_display_style" />
|
||||
</PreferenceScreen>
|
||||
</androidx.preference.PreferenceScreen>
|
||||
Reference in New Issue
Block a user