mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-28 01:55:40 +02:00
ID115: screen orientation preference
This commit is contained in:
parent
02b3f23329
commit
fe9ec9b88a
@ -7,6 +7,8 @@ import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport.BASE_UUID;
|
||||
|
||||
public class ID115Constants {
|
||||
public static final String PREF_SCREEN_ORIENTATION = "id115_screen_orientation";
|
||||
|
||||
public static final UUID UUID_SERVICE_ID115 = UUID.fromString(String.format(BASE_UUID, "0AF0"));
|
||||
public static final UUID UUID_CHARACTERISTIC_WRITE_NORMAL = UUID.fromString(String.format(BASE_UUID, "0AF6"));
|
||||
public static final UUID UUID_CHARACTERISTIC_NOTIFY_NORMAL = UUID.fromString(String.format(BASE_UUID, "0AF7"));
|
||||
@ -30,6 +32,8 @@ public class ID115Constants {
|
||||
public static final byte CMD_KEY_SET_TIME = 0x01;
|
||||
public static final byte CMD_KEY_SET_GOAL = 0x03;
|
||||
public static final byte CMD_KEY_SET_DISPLAY_MODE = 0x2B;
|
||||
public static final byte CMD_ARG_HORIZONTAL = 0x00;
|
||||
public static final byte CMD_ARG_VERTICAL = 0x02;
|
||||
|
||||
// CMD_ID_NOTIFY
|
||||
public static final byte CMD_KEY_NOTIFY_CALL = 0x01;
|
||||
|
@ -15,6 +15,7 @@ import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.id115.ID115Constants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||
@ -63,7 +64,7 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
|
||||
builder.notify(normalNotifyCharacteristic, true);
|
||||
|
||||
setTime(builder)
|
||||
.setDisplayMode(builder, false)
|
||||
.setScreenOrientation(builder)
|
||||
.setGoal(builder)
|
||||
.setInitialized(builder);
|
||||
|
||||
@ -303,11 +304,22 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
|
||||
return this;
|
||||
}
|
||||
|
||||
ID115Support setDisplayMode(TransactionBuilder builder, boolean vertical) {
|
||||
byte mode = (byte)(vertical? 2 : 0);
|
||||
ID115Support setScreenOrientation(TransactionBuilder builder) {
|
||||
String value = GBApplication.getPrefs().getString(ID115Constants.PREF_SCREEN_ORIENTATION,
|
||||
"horizontal");
|
||||
LOG.warn("value: '" + value + "'");
|
||||
|
||||
byte orientation;
|
||||
if (value.equals("horizontal")) {
|
||||
orientation = ID115Constants.CMD_ARG_HORIZONTAL;
|
||||
} else {
|
||||
orientation = ID115Constants.CMD_ARG_VERTICAL;
|
||||
}
|
||||
|
||||
LOG.warn("Screen orientation: " + orientation);
|
||||
builder.write(normalWriteCharacteristic, new byte[] {
|
||||
ID115Constants.CMD_ID_SETTINGS, ID115Constants.CMD_KEY_SET_DISPLAY_MODE,
|
||||
mode
|
||||
orientation
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
@ -86,6 +86,15 @@
|
||||
<item>right</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="orientation">
|
||||
<item>@string/horizontal</item>
|
||||
<item>@string/vertical</item>
|
||||
</string-array>
|
||||
<string-array name="orientation_values">
|
||||
<item>horizontal</item>
|
||||
<item>vertical</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="vibration_profile">
|
||||
<item>@string/vibration_profile_staccato</item>
|
||||
<item>@string/vibration_profile_short</item>
|
||||
|
@ -192,6 +192,10 @@
|
||||
<string name="prefs_title_all_day_heart_rate">All day heart rate measurement</string>
|
||||
<string name="preferences_hplus_settings">HPlus/Makibes settings</string>
|
||||
|
||||
<!-- ID115 Preferences -->
|
||||
<string name="preferences_id115_settings">ID115 settings</string>
|
||||
<string name="prefs_screen_orientation">Screen orientation</string>
|
||||
|
||||
<!-- Auto export preferences -->
|
||||
<string name="pref_header_auto_export">Auto export</string>
|
||||
<string name="pref_title_auto_export_enabled">Auto export enabled</string>
|
||||
@ -252,6 +256,8 @@
|
||||
<string name="other">Other</string>
|
||||
<string name="left">Left</string>
|
||||
<string name="right">Right</string>
|
||||
<string name="horizontal">Horizontal</string>
|
||||
<string name="vertical">Vertical</string>
|
||||
<string name="miband_pairing_using_dummy_userdata">No valid user data given, using dummy user data for now.</string>
|
||||
<string name="miband_pairing_tap_hint">When your Mi Band vibrates and blinks, tap it a few times in a row.</string>
|
||||
<string name="appinstaller_install">Install</string>
|
||||
|
@ -507,6 +507,22 @@
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
android:icon="@drawable/ic_device_h30_h10"
|
||||
android:key="pref_key_id115"
|
||||
android:title="@string/preferences_id115_settings">
|
||||
<PreferenceCategory
|
||||
android:key="pref_category_id115_general"
|
||||
android:title="@string/pref_header_general">
|
||||
<ListPreference
|
||||
android:defaultValue="horizontal"
|
||||
android:entries="@array/orientation"
|
||||
android:entryValues="@array/orientation_values"
|
||||
android:key="id115_screen_orientation"
|
||||
android:title="@string/prefs_screen_orientation"
|
||||
android:summary="%s" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
Loading…
Reference in New Issue
Block a user