1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 02:46:50 +01:00

Make some more settings per-device settings

- All ID115 settings migrated, allowing removal from settings activity
- All timeformat settings for all devices migrated
- All wrist location settings for all devices migrated (now you can have a mi band 3 on the left wrist and a bip  on the right wrist :P)

Also deduplicated some strings from zetime/generic preferences
This commit is contained in:
Andreas Shimokawa 2019-10-05 22:35:30 +02:00
parent 50ff47e0e4
commit b5e9727dcd
46 changed files with 198 additions and 176 deletions

View File

@ -78,9 +78,13 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.AMAZFITBIP;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.AMAZFITCOR;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.AMAZFITCOR2;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.HPLUS;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.ID115;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.MIBAND;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.MIBAND2;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.MIBAND3;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.MIBAND4;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.ZETIME;
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.fromKey;
import static nodomain.freeyourgadget.gadgetbridge.util.GB.NOTIFICATION_CHANNEL_ID;
@ -99,7 +103,7 @@ public class GBApplication extends Application {
private static SharedPreferences sharedPrefs;
private static final String PREFS_VERSION = "shared_preferences_version";
//if preferences have to be migrated, increment the following and add the migration logic in migratePrefs below; see http://stackoverflow.com/questions/16397848/how-can-i-migrate-android-preferences-with-a-new-version
private static final int CURRENT_PREFS_VERSION = 4;
private static final int CURRENT_PREFS_VERSION = 5;
private static LimitedQueue mIDSenderLookup = new LimitedQueue(16);
private static Prefs prefs;
private static GBPrefs gbPrefs;
@ -761,6 +765,67 @@ public class GBApplication extends Application {
Log.w(TAG, "error acquiring DB lock");
}
}
if (oldVersion < 5) {
try (DBHandler db = acquireDB()) {
DaoSession daoSession = db.getDaoSession();
List<Device> activeDevices = DBHelper.getActiveDevices(daoSession);
for (Device dbDevice : activeDevices) {
SharedPreferences deviceSpecificSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
if (deviceSpecificSharedPrefs != null) {
SharedPreferences.Editor deviceSharedPrefsEdit = deviceSpecificSharedPrefs.edit();
DeviceType deviceType = fromKey(dbDevice.getType());
String newWearside = null;
String newOrientation = null;
String newTimeformat = null;
switch (deviceType) {
case AMAZFITBIP:
case AMAZFITCOR:
case AMAZFITCOR2:
case MIBAND:
case MIBAND2:
case MIBAND3:
case MIBAND4:
newWearside = prefs.getString("mi_wearside", "left");
break;
case HPLUS:
newWearside = prefs.getString("hplus_wrist", "left");
newTimeformat = prefs.getString("hplus_timeformat", "24h");
break;
case ID115:
newWearside = prefs.getString("id115_wrist", "left");
newOrientation = prefs.getString("id115_screen_orientation", "horizontal");
break;
case ZETIME:
newWearside = prefs.getString("zetime_wrist", "left");
newTimeformat = prefs.getInt("zetime_timeformat", 1) == 2 ? "am/pm" : "24h";
break;
}
if (newWearside != null) {
deviceSharedPrefsEdit.putString("wearlocation", newWearside);
}
if (newOrientation != null) {
deviceSharedPrefsEdit.putString("screen_orientation", newOrientation);
}
if (newTimeformat != null) {
deviceSharedPrefsEdit.putString("timeformat", newTimeformat);
}
deviceSharedPrefsEdit.apply();
}
}
editor.remove("hplus_timeformat");
editor.remove("hplus_wrist");
editor.remove("id115_wrist");
editor.remove("id115_screen_orientation");
editor.remove("mi_wearside");
editor.remove("zetime_timeformat");
editor.remove("zetime_wrist");
} catch (Exception e) {
Log.w(TAG, "error acquiring DB lock");
}
}
editor.putString(PREFS_VERSION, Integer.toString(CURRENT_PREFS_VERSION));
editor.apply();
}

View File

@ -1,5 +1,8 @@
package nodomain.freeyourgadget.gadgetbridge.activities.devicesettings;
public class DeviceSettingsPreferenceConst {
public static final String PREF_DATEFORMAT = "dateformat";
public static final String PREF_TIMEFORMAT = "timeformat";
public static final String PREF_WEARLOCATION = "wearlocation";
public static final String PREF_SCREEN_ORIENTATION = "screen_orientation";
}

View File

@ -21,8 +21,8 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.XTimePreference;
import nodomain.freeyourgadget.gadgetbridge.util.XTimePreferenceFragment;
import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.*;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_ACTIVATE_DISPLAY_ON_LIFT;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DATEFORMAT;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION_END;
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION_START;
@ -289,6 +289,9 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
addPreferenceHandlerFor(PREF_DISPLAY_ITEMS);
addPreferenceHandlerFor(PREF_LANGUAGE);
addPreferenceHandlerFor(PREF_EXPOSE_HR_THIRDPARTY);
addPreferenceHandlerFor(PREF_WEARLOCATION);
addPreferenceHandlerFor(PREF_SCREEN_ORIENTATION);
addPreferenceHandlerFor(PREF_TIMEFORMAT);
String displayOnLiftState = prefs.getString(PREF_ACTIVATE_DISPLAY_ON_LIFT, PREF_DO_NOT_DISTURB_OFF);
boolean displayOnLiftScheduled = displayOnLiftState.equals(PREF_DO_NOT_DISTURB_SCHEDULED);

View File

@ -128,8 +128,6 @@ public final class HPlusConstants {
public static final String PREF_HPLUS_SCREENTIME = "hplus_screentime";
public static final String PREF_HPLUS_ALLDAYHR = "hplus_alldayhr";
public static final String PREF_HPLUS_TIMEFORMAT = "hplus_timeformat";
public static final String PREF_HPLUS_WRIST = "hplus_wrist";
public static final String PREF_HPLUS_SIT_START_TIME = "hplus_sit_start_time";
public static final String PREF_HPLUS_SIT_END_TIME = "hplus_sit_end_time";
public static final String PREF_HPLUS_UNICODE = "hplus_unicode";

View File

@ -43,6 +43,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
@ -196,10 +197,10 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator {
}
}
public static byte getTimeMode(String address) {
String tmode = prefs.getString(HPlusConstants.PREF_HPLUS_TIMEFORMAT, getContext().getString(R.string.p_timeformat_24h));
public static byte getTimeMode(String deviceAddress) {
String tmode = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress).getString(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, "24h");
if(tmode.equals(getContext().getString(R.string.p_timeformat_24h))) {
if ("24h".equals(tmode)) {
return HPlusConstants.ARG_TIMEMODE_24H;
}else{
return HPlusConstants.ARG_TIMEMODE_12H;
@ -269,10 +270,12 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator {
return (byte) 255;
}
public static byte getUserWrist(String address) {
String value = prefs.getString(HPlusConstants.PREF_HPLUS_WRIST, getContext().getString(R.string.left));
//FIXME: unused
public static byte getUserWrist(String deviceAddress) {
SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);
String value = sharedPreferences.getString(DeviceSettingsPreferenceConst.PREF_WEARLOCATION, "left");
if(value.equals(getContext().getString(R.string.left))){
if ("left".equals(value)) {
return HPlusConstants.ARG_WRIST_LEFT;
} else {
return HPlusConstants.ARG_WRIST_RIGHT;
@ -290,10 +293,19 @@ public class HPlusCoordinator extends AbstractDeviceCoordinator {
public static void setUnicodeSupport(String address, boolean state){
SharedPreferences.Editor editor = prefs.getPreferences().edit();
editor.putBoolean(HPlusConstants.PREF_HPLUS_UNICODE + "_" + address, state);
editor.commit();
editor.apply();
}
public static boolean getUnicodeSupport(String address){
return (prefs.getBoolean(HPlusConstants.PREF_HPLUS_UNICODE + "_" + address, false));
}
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
//R.xml.devicesettings_wearlocation, // disabled, since it is never used in code
R.xml.devicesettings_timeformat
};
}
}

View File

@ -60,7 +60,6 @@ public class HuamiConst {
public static final String PREF_DISPLAY_ITEMS = "display_items";
public static final String PREF_LANGUAGE = "language";
public static final String PREF_DATEFORMAT = "dateformat";
public static final String PREF_EXPOSE_HR_THIRDPARTY = "expose_hr_thirdparty";
public static final String PREF_USE_CUSTOM_FONT = "use_custom_font";

View File

@ -81,6 +81,7 @@ public class AmazfitBipCoordinator extends HuamiCoordinator {
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_amazfitbip,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_disconnectnotification,

View File

@ -84,6 +84,7 @@ public class AmazfitCorCoordinator extends HuamiCoordinator {
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_amazfitcor,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_custom_emoji_font,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_disconnectnotification,

View File

@ -86,6 +86,7 @@ public class AmazfitCor2Coordinator extends HuamiCoordinator {
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_amazfitcor,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_disconnectnotification,
R.xml.devicesettings_pairingkey};

View File

@ -84,6 +84,7 @@ public class MiBand2Coordinator extends HuamiCoordinator {
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_miband2,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_donotdisturb_withauto,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_rotatewrist_cycleinfo,

View File

@ -25,6 +25,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import androidx.annotation.NonNull;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -75,4 +77,15 @@ public class MiBand2HRXCoordinator extends HuamiCoordinator {
return false;
}
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_miband2,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_donotdisturb_withauto,
R.xml.devicesettings_liftwrist_display,
R.xml.devicesettings_rotatewrist_cycleinfo,
R.xml.devicesettings_pairingkey
};
}
}

View File

@ -103,6 +103,7 @@ public class MiBand3Coordinator extends HuamiCoordinator {
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_miband3,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_dateformat,
R.xml.devicesettings_nightmode,
R.xml.devicesettings_donotdisturb_withauto,

View File

@ -88,6 +88,7 @@ public class MiBand4Coordinator extends HuamiCoordinator {
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_miband3,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_dateformat,
R.xml.devicesettings_nightmode,
R.xml.devicesettings_liftwrist_display,

View File

@ -23,9 +23,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
import static nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport.BASE_UUID;
public class ID115Constants {
public static final String PREF_WRIST = "id115_wrist";
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"));

View File

@ -31,6 +31,7 @@ import java.util.Collections;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
@ -154,4 +155,12 @@ public class ID115Coordinator extends AbstractDeviceCoordinator {
public boolean supportsFindDevice() {
return false;
}
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_screenorientation
};
}
}

View File

@ -23,7 +23,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.Version;
public final class MiBandConst {
public static final String PREF_USER_ALIAS = "mi_user_alias";
public static final String PREF_MIBAND_WEARSIDE = "mi_wearside";
public static final String PREF_MIBAND_ADDRESS = "development_miaddr"; // FIXME: should be prefixed mi_
public static final String PREF_MIBAND_ALARMS = "mi_alarms";
public static final String PREF_MIBAND_DONT_ACK_TRANSFER = "mi_dont_ack_transfer";

View File

@ -22,7 +22,6 @@ import android.app.Activity;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelUuid;
@ -38,6 +37,7 @@ import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
@ -228,10 +228,10 @@ public class MiBandCoordinator extends AbstractDeviceCoordinator {
return info;
}
public static int getWearLocation(String miBandAddress) throws IllegalArgumentException {
public static int getWearLocation(String deviceAddress) throws IllegalArgumentException {
int location = 0; //left hand
Prefs prefs = GBApplication.getPrefs();
if ("right".equals(prefs.getString(MiBandConst.PREF_MIBAND_WEARSIDE, "left"))) {
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(deviceAddress));
if ("right".equals(prefs.getString(DeviceSettingsPreferenceConst.PREF_WEARLOCATION, "left"))) {
location = 1; // right hand
}
return location;
@ -261,6 +261,7 @@ public class MiBandCoordinator extends AbstractDeviceCoordinator {
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_lowlatency_fwupdate,
R.xml.devicesettings_fake_timeoffset
};

View File

@ -124,7 +124,6 @@ public class ZeTimeConstants {
public static final byte INACTIVITY_TYPE = (byte) 0x08;
public static final byte LOW_POWER_TYPE = (byte) 0x09;
// watch settings
public static final String PREF_WRIST = "zetime_wrist";
public static final byte WEAR_ON_LEFT_WRIST = (byte) 0x00;
public static final byte WEAR_ON_RIGHT_WRIST = (byte) 0x01;
@ -160,7 +159,6 @@ public class ZeTimeConstants {
public static final String PREF_ACTIVITY_TRACKING = "zetime_activity_tracking";
public static final String PREF_HANDMOVE_DISPLAY = "zetime_handmove_display";
public static final String PREF_CALORIES_TYPE = "zetime_calories_type";
public static final String PREF_TIME_FORMAT = "zetime_time_format";
public static final String PREF_DATE_FORMAT = "zetime_date_format";
public static final String PREF_ALARM_SIGNALING = "zetime_alarm_signaling";

View File

@ -22,11 +22,12 @@ import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import java.util.Collection;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import java.util.Collection;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
@ -37,9 +38,6 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
/**
* Created by lightwars on 06.02.18.
*/
public class ZeTimeCoordinator extends AbstractDeviceCoordinator {
@Override
@ -135,7 +133,7 @@ public class ZeTimeCoordinator extends AbstractDeviceCoordinator {
}
@Override
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) {
}
@ -161,4 +159,12 @@ public class ZeTimeCoordinator extends AbstractDeviceCoordinator {
@Override
public boolean supportsUnicodeEmojis() { return true; }
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{
R.xml.devicesettings_timeformat,
R.xml.devicesettings_wearlocation,
};
}
}

View File

@ -22,6 +22,7 @@ import android.preference.Preference;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
@Override
@ -43,8 +44,6 @@ public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
addPreferenceHandlerFor(ZeTimeConstants.PREF_SCREENTIME);
addPreferenceHandlerFor(ZeTimeConstants.PREF_WRIST);
addPreferenceHandlerFor(ZeTimeConstants.PREF_ANALOG_MODE);
addPreferenceHandlerFor(ZeTimeConstants.PREF_ACTIVITY_TRACKING);
@ -57,8 +56,6 @@ public class ZeTimePreferenceActivity extends AbstractSettingsActivity {
addPreferenceHandlerFor(ZeTimeConstants.PREF_CALORIES_TYPE);
addPreferenceHandlerFor(ZeTimeConstants.PREF_TIME_FORMAT);
addPreferenceHandlerFor(ZeTimeConstants.PREF_DATE_FORMAT);
addPreferenceHandlerFor(ZeTimeConstants.PREF_INACTIVITY_ENABLE);

View File

@ -53,6 +53,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.Logging;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.SettingsActivity;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
@ -127,7 +128,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.NotificationUtils;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
import nodomain.freeyourgadget.gadgetbridge.util.Version;
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_COUNT;
@ -1502,7 +1502,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
case MiBandConst.PREF_SWIPE_UNLOCK:
setBandScreenUnlock(builder);
break;
case HuamiConst.PREF_DATEFORMAT:
case DeviceSettingsPreferenceConst.PREF_DATEFORMAT:
setDateFormat(builder);
break;
case HuamiConst.PREF_LANGUAGE:
@ -1511,6 +1511,9 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
case HuamiConst.PREF_EXPOSE_HR_THIRDPARTY:
setExposeHRThridParty(builder);
break;
case DeviceSettingsPreferenceConst.PREF_WEARLOCATION:
setWearLocation(builder);
break;
}
builder.queue(getQueue());
} catch (IOException e) {

View File

@ -30,6 +30,7 @@ import java.util.TimeZone;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.devices.id115.ID115Constants;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
@ -296,11 +297,11 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
}
ID115Support setWrist(TransactionBuilder builder) {
String value = GBApplication.getPrefs().getString(ID115Constants.PREF_WRIST,
String value = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_WEARLOCATION,
"left");
byte wrist;
if (value.equals("left")) {
if ("left".equals(value)) {
wrist = ID115Constants.CMD_ARG_LEFT;
} else {
wrist = ID115Constants.CMD_ARG_RIGHT;
@ -314,11 +315,11 @@ public class ID115Support extends AbstractBTLEDeviceSupport {
}
ID115Support setScreenOrientation(TransactionBuilder builder) {
String value = GBApplication.getPrefs().getString(ID115Constants.PREF_SCREEN_ORIENTATION,
String value = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_SCREEN_ORIENTATION,
"horizontal");
byte orientation;
if (value.equals("horizontal")) {
if ("horizontal".equals(value)) {
orientation = ID115Constants.CMD_ARG_HORIZONTAL;
} else {
orientation = ID115Constants.CMD_ARG_VERTICAL;

View File

@ -39,6 +39,7 @@ import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventBatteryInfo;
@ -147,7 +148,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
try {
TransactionBuilder builder = performInitialized("sendConfiguration");
switch (config) {
case ZeTimeConstants.PREF_WRIST:
case DeviceSettingsPreferenceConst.PREF_WEARLOCATION:
setWrist(builder);
break;
case ZeTimeConstants.PREF_SCREENTIME:
@ -170,7 +171,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
case ZeTimeConstants.PREF_CALORIES_TYPE:
setCaloriesType(builder);
break;
case ZeTimeConstants.PREF_TIME_FORMAT:
case DeviceSettingsPreferenceConst.PREF_TIMEFORMAT:
setTimeFormate(builder);
break;
case ZeTimeConstants.PREF_DATE_FORMAT:
@ -1421,7 +1422,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
// function serving the settings
private void setWrist(TransactionBuilder builder) {
String value = GBApplication.getPrefs().getString(ZeTimeConstants.PREF_WRIST, "left");
String value = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_WEARLOCATION, "left");
byte[] wrist = {ZeTimeConstants.CMD_PREAMBLE,
ZeTimeConstants.CMD_USAGE_HABITS,
@ -1430,7 +1431,7 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
(byte) 0x0,
ZeTimeConstants.WEAR_ON_LEFT_WRIST,
ZeTimeConstants.CMD_END};
if (value.equals("right")) {
if ("right".equals(value)) {
wrist[5] = ZeTimeConstants.WEAR_ON_RIGHT_WRIST;
}
@ -1681,8 +1682,11 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
}
private void setTimeFormate(TransactionBuilder builder) {
Prefs prefs = GBApplication.getPrefs();
int type = prefs.getInt(ZeTimeConstants.PREF_TIME_FORMAT, 0);
String timeFormat = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getString(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, "24h");
int type = 1;
if ("am/pm".equals(timeFormat)) {
type = 2;
}
byte[] timeformat = {ZeTimeConstants.CMD_PREAMBLE,
ZeTimeConstants.CMD_TIME_SURFACE_SETTINGS,
@ -1961,8 +1965,17 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
prefs.putString(ZeTimeConstants.PREF_DATE_FORMAT, Integer.toString(msg[5]));
prefs.putString(ZeTimeConstants.PREF_TIME_FORMAT, Integer.toString(msg[6]));
prefs.apply();
String timeFormat = "24h";
SharedPreferences.Editor prefsEditor = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).edit();
if (msg[6] == 2) {
timeFormat = "am/pm";
}
prefsEditor.putString(DeviceSettingsPreferenceConst.PREF_TIMEFORMAT, timeFormat);
prefsEditor.apply();
}
private void getSignaling(byte[] msg) {
@ -2021,12 +2034,12 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
}
private void getWrist(byte[] msg) {
SharedPreferences.Editor prefs = GBApplication.getPrefs().getPreferences().edit();
SharedPreferences.Editor prefs = GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).edit();
if (ZeTimeConstants.WEAR_ON_LEFT_WRIST == msg[5]) {
prefs.putString(ZeTimeConstants.PREF_WRIST, "left");
prefs.putString(DeviceSettingsPreferenceConst.PREF_WEARLOCATION, "left");
} else if (ZeTimeConstants.WEAR_ON_RIGHT_WRIST == msg[5]) {
prefs.putString(ZeTimeConstants.PREF_WRIST, "right");
prefs.putString(DeviceSettingsPreferenceConst.PREF_WEARLOCATION, "right");
}
prefs.apply();
}

View File

@ -305,9 +305,6 @@
<string name="zetime_calories_type">Вид калории</string>
<string name="zetime_calories_type_active">Само активно изгорени калории</string>
<string name="zetime_calories_type_all">Активно и неактивно изгорени калории</string>
<string name="zetime_time_format">Часови формат</string>
<string name="zetime_time_format_24h">24часа</string>
<string name="zetime_time_format_12h">12часа</string>
<string name="zetime_date_format">Формат на датата</string>
<string name="zetime_date_format_1">ГГ/ММ/ДД</string>
<string name="zetime_date_format_2">ДД/ММ/ГГ</string>

View File

@ -659,9 +659,6 @@
<string name="zetime_calories_type">Tipus de calories</string>
<string name="zetime_calories_type_active">Només les calories cremades de forma activa</string>
<string name="zetime_calories_type_all">Calories cremades de forma activa i en repòs</string>
<string name="zetime_time_format">Format d\'hora</string>
<string name="zetime_time_format_24h">24h</string>
<string name="zetime_time_format_12h">12h</string>
<string name="zetime_date_format">Format de data</string>
<string name="zetime_date_format_1">AA/MM/DD</string>
<string name="zetime_date_format_2">DD/MM/AA</string>

View File

@ -647,9 +647,6 @@
<string name="zetime_calories_type">Nastavení kalorií</string>
<string name="zetime_calories_type_active">Pouze spálené kalorie</string>
<string name="zetime_calories_type_all">Aktivní a neaktivní spálené kalorie</string>
<string name="zetime_time_format">Formát času</string>
<string name="zetime_time_format_24h">24h</string>
<string name="zetime_time_format_12h">12h</string>
<string name="zetime_date_format">Formát datumu</string>
<string name="zetime_date_format_1">YY/MM/DD</string>
<string name="zetime_date_format_2">DD/MM/YY</string>

View File

@ -652,9 +652,6 @@
<string name="zetime_title_heartrate">Herzfrequenz Einstellungen</string>
<string name="zetime_title_heart_rate_alarm">Herzfrequenz Alarm</string>
<string name="zetime_heart_rate_alarm_enable">Herzfrequenz Alarm aktivieren</string>
<string name="zetime_time_format">Zeitformat</string>
<string name="zetime_time_format_24h">24h</string>
<string name="zetime_time_format_12h">12h</string>
<string name="zetime_date_format">Datumsformat</string>
<string name="zetime_date_format_1">JJ/MM/TT</string>
<string name="zetime_date_format_2">TT/MM/JJ</string>

View File

@ -656,9 +656,6 @@
<string name="zetime_calories_type">Τύπος θερμίδων</string>
<string name="zetime_calories_type_active">Ενεργές μόνο θερμίδες που έχετε κάψει</string>
<string name="zetime_calories_type_all">Ενεργές και ανενεργές θερμίδες</string>
<string name="zetime_time_format">Μορφή ώρας</string>
<string name="zetime_time_format_24h">24ωρη</string>
<string name="zetime_time_format_12h">12ωρη</string>
<string name="zetime_date_format">Μορφή ημερομηνίας</string>
<string name="zetime_date_format_1">ΕΕ/ΜΜ/ΗΗ</string>
<string name="zetime_date_format_2">ΗΗ/ΜΜ/ΕΕ</string>

View File

@ -648,9 +648,6 @@
<string name="zetime_handmove_display_summary">Gire la muñeca para activar o desactivar la pantalla.</string>
<string name="zetime_calories_type">Tipo de calorías</string>
<string name="zetime_calories_type_active">Solo activo para quemar calorías</string>
<string name="zetime_time_format">Formato de hora</string>
<string name="zetime_time_format_24h">24H</string>
<string name="zetime_time_format_12h">12H</string>
<string name="zetime_date_format">Formato de fecha</string>
<string name="zetime_date_format_1">aa/mm/dd</string>
<string name="zetime_date_format_2">dd/mm/aa</string>

View File

@ -201,9 +201,6 @@
<string name="zetime_calories_type">Kalorite tüüp</string>
<string name="zetime_calories_type_active">Ainult aktiivselt põletatud kalorid</string>
<string name="zetime_calories_type_all">Aktiivselt ja passiivselt põletatud kalorid</string>
<string name="zetime_time_format">Kellaaja vorming</string>
<string name="zetime_time_format_24h">24h</string>
<string name="zetime_time_format_12h">12h</string>
<string name="zetime_date_format">Kuupäeva vorming</string>
<string name="zetime_prefs_inactivity_repetitions">Kordused</string>
<string name="zetime_prefs_inactivity_mo">Esmaspäev</string>

View File

@ -650,9 +650,6 @@ Temps de sommeil préféré en heures</string>
<string name="zetime_calories_type">Type de calories</string>
<string name="zetime_calories_type_active">Seulement les calories brûlées activement</string>
<string name="zetime_calories_type_all">Calories brûlées activement et au repos</string>
<string name="zetime_time_format">Format de l\'heure</string>
<string name="zetime_time_format_24h">24h</string>
<string name="zetime_time_format_12h">12h</string>
<string name="zetime_date_format">Format de la date</string>
<string name="zetime_date_format_1">aaaa/mm/jj</string>
<string name="zetime_date_format_2">jj/mm/aaaa</string>

View File

@ -644,9 +644,6 @@
<string name="zetime_calories_type">סוג קלוריות</string>
<string name="zetime_calories_type_active">קלוריות פעילות שנשרפו בלבד</string>
<string name="zetime_calories_type_all">קלוריות פעילות ובלתי פעילות שנשרפו בלבד</string>
<string name="zetime_time_format">תצורת זמן</string>
<string name="zetime_time_format_24h">24 שעות</string>
<string name="zetime_time_format_12h">12 שעות</string>
<string name="zetime_date_format">תצורת תאריך</string>
<string name="zetime_date_format_1">YY/MM/DD</string>
<string name="zetime_date_format_2">DD/MM/YY</string>

View File

@ -414,9 +414,6 @@
<string name="debugactivity_really_factoryreset_title">Biztos a gyári beállítások visszaállításában\?</string>
<string name="zetime_analog_mode">Analóg mód</string>
<string name="zetime_handmove_display_summary">Képernyő be és kikapcsolása csukló forgatása által.</string>
<string name="zetime_time_format">Időformátum</string>
<string name="zetime_time_format_24h">24 óra</string>
<string name="zetime_time_format_12h">12 óra</string>
<string name="zetime_date_format">Dátum formátum</string>
<string name="zetime_prefs_inactivity_repetitions">Ismétlés</string>
<string name="zetime_prefs_inactivity_mo">Hétfő</string>

View File

@ -630,8 +630,6 @@
<string name="activity_prefs_alarm_max_heart_rate">Frequenza cardiaca massima</string>
<string name="activity_prefs_alarm_min_heart_rate">Frequenza cardiaca minima</string>
<string name="zetime_handmove_display_summary">Ruota il polso per attivare o disattivare il display.</string>
<string name="zetime_time_format_24h">24h</string>
<string name="zetime_time_format_12h">12h</string>
<string name="zetime_date_format">Formato data</string>
<string name="zetime_date_format_1">AA/MM/GG</string>
<string name="zetime_date_format_2">GG/MM/AA</string>
@ -656,7 +654,6 @@
<string name="zetime_calories_type">Tipo calorie</string>
<string name="zetime_calories_type_active">Solo calorie bruciate attivamente</string>
<string name="zetime_calories_type_all">Calorie bruciate attivamente e passivamente</string>
<string name="zetime_time_format">Formato ora</string>
<string name="zetime_prefs_inactivity_repetitions">Ripetizioni</string>
<string name="zetime_title_alarm_signaling">Imposta il tipo di segnale per l\'allarme</string>
<string name="zetime_signaling_none">Silenzioso</string>

View File

@ -637,9 +637,6 @@
<string name="zetime_activity_tracking">Aktivitetssporing</string>
<string name="zetime_handmove_display">Håndbevegelse</string>
<string name="zetime_calories_type">Kaloritype</string>
<string name="zetime_time_format">Tidsformat</string>
<string name="zetime_time_format_24h">24t</string>
<string name="zetime_time_format_12h">12t</string>
<string name="zetime_date_format">Datoformat</string>
<string name="zetime_date_format_1">ÅÅ/MM/DD</string>
<string name="zetime_date_format_2">DD/MM/ÅÅ</string>

View File

@ -651,9 +651,6 @@
<string name="zetime_calories_type">Soort calorieën</string>
<string name="zetime_calories_type_active">Alleen calorieën verbrand gedurende activiteiten</string>
<string name="zetime_calories_type_all">Verbrande calorieën actief en inactief</string>
<string name="zetime_time_format">Tijd formaat</string>
<string name="zetime_time_format_24h">24 uur</string>
<string name="zetime_time_format_12h">12 uur</string>
<string name="zetime_date_format">Datum formaat</string>
<string name="zetime_date_format_1">YY/MM/DD</string>
<string name="zetime_date_format_2">DD/MM/YY</string>

View File

@ -657,9 +657,6 @@
<string name="zetime_calories_type">Tipo de calorias</string>
<string name="zetime_calories_type_active">Só ativar calorias queimadas</string>
<string name="zetime_calories_type_all">Calorias queimadas ativas e inativas</string>
<string name="zetime_time_format">Formato da hora</string>
<string name="zetime_time_format_24h">24h</string>
<string name="zetime_time_format_12h">12h</string>
<string name="zetime_date_format">Formato da data</string>
<string name="zetime_date_format_1">AA/MM/DD</string>
<string name="zetime_date_format_2">DD/MM/AA</string>

View File

@ -466,9 +466,6 @@
<string name="activity_prefs_alarm_min_heart_rate">Мінімальне серцебиття</string>
<string name="zetime_analog_mode">Аналоговий режим</string>
<string name="zetime_analog_mode_hands">Лише вручну</string>
<string name="zetime_time_format">Формат часу</string>
<string name="zetime_time_format_24h">24г</string>
<string name="zetime_time_format_12h">12г</string>
<string name="zetime_date_format">Формат дати</string>
<string name="zetime_date_format_1">РР/ММ/ДД</string>
<string name="zetime_date_format_2">ДД/ММ/РР</string>

View File

@ -651,9 +651,6 @@
<string name="zetime_calories_type">卡路里类型</string>
<string name="zetime_calories_type_active">仅运动消耗的热量</string>
<string name="zetime_calories_type_all">运行和非运动消耗的热量</string>
<string name="zetime_time_format">时间格式</string>
<string name="zetime_time_format_24h">24小时制</string>
<string name="zetime_time_format_12h">12小时制</string>
<string name="zetime_date_format">日期格式</string>
<string name="zetime_date_format_1">YY/MM/DD</string>
<string name="zetime_date_format_2">DD/MM/YY</string>

View File

@ -546,14 +546,6 @@
<item>0</item>
<item>1</item>
</string-array>
<string-array name="zetime_time_format">
<item name="1">@string/zetime_time_format_24h</item>
<item name="2">@string/zetime_time_format_12h</item>
</string-array>
<string-array name="zetime_time_format_values">
<item>1</item>
<item>2</item>
</string-array>
<string-array name="zetime_date_format">
<item name="1">@string/zetime_date_format_1</item>
<item name="2">@string/zetime_date_format_2</item>

View File

@ -210,9 +210,6 @@
<string name="zetime_calories_type">Calories type</string>
<string name="zetime_calories_type_active">Only active burnt calories</string>
<string name="zetime_calories_type_all">Active and inactive burnt calories</string>
<string name="zetime_time_format">Time format</string>
<string name="zetime_time_format_24h">24h</string>
<string name="zetime_time_format_12h">12h</string>
<string name="zetime_date_format">Date format</string>
<string name="zetime_date_format_1">YY/MM/DD</string>
<string name="zetime_date_format_2">DD/MM/YY</string>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:defaultValue="horizontal"
android:entries="@array/orientation"
android:entryValues="@array/orientation_values"
android:key="screen_orientation"
android:summary="%s"
android:title="@string/prefs_screen_orientation" />
</androidx.preference.PreferenceScreen>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<ListPreference
android:defaultValue="left"
android:entries="@array/wearside"
android:entryValues="@array/wearside_values"
android:key="wearlocation"
android:summary="%s"
android:title="@string/prefs_wearside" />
</androidx.preference.PreferenceScreen>

View File

@ -9,14 +9,6 @@
android:maxLength="17"
android:title="@string/miband_prefs_alias" />
<ListPreference
android:defaultValue="left"
android:entries="@array/wearside"
android:entryValues="@array/wearside_values"
android:key="mi_wearside"
android:title="@string/prefs_wearside"
android:summary="%s" />
<EditTextPreference
android:defaultValue="10000"
android:inputType="number"

View File

@ -556,22 +556,6 @@
android:key="pref_category_hplus_general"
android:title="@string/pref_header_general">
<ListPreference
android:defaultValue="left"
android:entries="@array/wearside"
android:entryValues="@array/wearside_values"
android:key="hplus_wrist"
android:title="@string/prefs_wearside"
android:summary="%s" />
<ListPreference
android:defaultValue="24h"
android:entries="@array/pref_timeformat_entries"
android:entryValues="@array/pref_timeformat_values"
android:key="hplus_timeformat"
android:title="@string/pref_title_timeformat"
android:summary="%s" />
<EditTextPreference
android:defaultValue="5"
android:key="hplus_screentime"
@ -586,32 +570,6 @@
</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="left"
android:entries="@array/wearside"
android:entryValues="@array/wearside_values"
android:key="id115_wrist"
android:title="@string/prefs_wearside"
android:summary="%s" />
<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>
<Preference
android:icon="@drawable/ic_device_zetime"
android:key="pref_key_zetime"

View File

@ -4,13 +4,6 @@
android:key="pref_category_zetime_general"
android:title="@string/pref_header_general">
<ListPreference
android:defaultValue="left"
android:entries="@array/wearside"
android:entryValues="@array/wearside_values"
android:key="zetime_wrist"
android:title="@string/prefs_wearside"
android:summary="%s" />
<EditTextPreference
android:inputType="number"
android:maxLength="5"
@ -151,14 +144,6 @@
android:title="@string/zetime_analog_mode"
android:summary="%s" />
<ListPreference
android:defaultValue="1"
android:entries="@array/zetime_time_format"
android:entryValues="@array/zetime_time_format_values"
android:key="zetime_time_format"
android:title="@string/zetime_time_format"
android:summary="%s" />
<ListPreference
android:defaultValue="2"
android:entries="@array/zetime_date_format"