mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 18:45:49 +01:00
Mi Band 2: move settings to per-device settings
This commit is contained in:
parent
34e0c4e8bc
commit
3440485a51
@ -63,8 +63,6 @@ import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||||
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_DATEFORMAT;
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_ENABLE_TEXT_NOTIFICATIONS;
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_HEIGHT_CM;
|
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_HEIGHT_CM;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_SLEEP_DURATION;
|
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_SLEEP_DURATION;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_STEPS_GOAL;
|
import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_STEPS_GOAL;
|
||||||
@ -359,20 +357,6 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
|||||||
autoFetchInterval);
|
autoFetchInterval);
|
||||||
pref.setSummary(summary);
|
pref.setSummary(summary);
|
||||||
|
|
||||||
final Preference setDateFormat = findPreference(PREF_MI2_DATEFORMAT);
|
|
||||||
setDateFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
|
||||||
invokeLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
GBApplication.deviceService().onSendConfiguration(PREF_MI2_DATEFORMAT);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Get all receivers of Media Buttons
|
// Get all receivers of Media Buttons
|
||||||
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
|
||||||
|
|
||||||
@ -501,7 +485,6 @@ public class SettingsActivity extends AbstractSettingsActivity {
|
|||||||
PREF_USER_WEIGHT_KG,
|
PREF_USER_WEIGHT_KG,
|
||||||
PREF_USER_SLEEP_DURATION,
|
PREF_USER_SLEEP_DURATION,
|
||||||
PREF_USER_STEPS_GOAL,
|
PREF_USER_STEPS_GOAL,
|
||||||
PREF_MI2_ENABLE_TEXT_NOTIFICATIONS,
|
|
||||||
"weather_city",
|
"weather_city",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.XTimePreferenceFragment;
|
|||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION;
|
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_END;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION_START;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst.PREF_DISCONNECT_NOTIFICATION_START;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_DATEFORMAT;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_DO_NOT_DISTURB_OFF;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_DO_NOT_DISTURB_OFF;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_DO_NOT_DISTURB_SCHEDULED;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_MI2_DO_NOT_DISTURB_SCHEDULED;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_NIGHT_MODE;
|
import static nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst.PREF_NIGHT_MODE;
|
||||||
@ -234,6 +235,21 @@ public class DeviceSpecificSettingsFragment extends PreferenceFragmentCompat {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
final Preference setDateFormat = findPreference(PREF_MI2_DATEFORMAT);
|
||||||
|
if (setDateFormat != null) {
|
||||||
|
setDateFormat.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
||||||
|
invokeLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
GBApplication.deviceService().onSendConfiguration(PREF_MI2_DATEFORMAT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static DeviceSpecificSettingsFragment newInstance(String settingsFileSuffix, @NonNull int[] supportedSettings) {
|
static DeviceSpecificSettingsFragment newInstance(String settingsFileSuffix, @NonNull int[] supportedSettings) {
|
||||||
|
@ -131,10 +131,10 @@ public abstract class HuamiCoordinator extends AbstractDeviceCoordinator {
|
|||||||
return new MiBand2SampleProvider(device, session);
|
return new MiBand2SampleProvider(device, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DateTimeDisplay getDateDisplay(Context context) throws IllegalArgumentException {
|
public static DateTimeDisplay getDateDisplay(Context context, String deviceAddress) throws IllegalArgumentException {
|
||||||
Prefs prefs = GBApplication.getPrefs();
|
SharedPreferences sharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(deviceAddress);
|
||||||
String dateFormatTime = context.getString(R.string.p_dateformat_time);
|
String dateFormatTime = context.getString(R.string.p_dateformat_time);
|
||||||
if (dateFormatTime.equals(prefs.getString(MiBandConst.PREF_MI2_DATEFORMAT, dateFormatTime))) {
|
if (dateFormatTime.equals(sharedPrefs.getString(MiBandConst.PREF_MI2_DATEFORMAT, dateFormatTime))) {
|
||||||
return DateTimeDisplay.TIME;
|
return DateTimeDisplay.TIME;
|
||||||
}
|
}
|
||||||
return DateTimeDisplay.DATE_TIME;
|
return DateTimeDisplay.DATE_TIME;
|
||||||
|
@ -347,7 +347,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
return new Mi2NotificationStrategy(this);
|
return new Mi2NotificationStrategy(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (GBApplication.getPrefs().getBoolean(MiBandConst.PREF_MI2_ENABLE_TEXT_NOTIFICATIONS, true)) {
|
if (GBApplication.getDeviceSpecificSharedPrefs(gbDevice.getAddress()).getBoolean(MiBandConst.PREF_MI2_ENABLE_TEXT_NOTIFICATIONS, true)) {
|
||||||
return new Mi2TextNotificationStrategy(this);
|
return new Mi2TextNotificationStrategy(this);
|
||||||
}
|
}
|
||||||
return new Mi2NotificationStrategy(this);
|
return new Mi2NotificationStrategy(this);
|
||||||
@ -1580,7 +1580,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private HuamiSupport setDateDisplay(TransactionBuilder builder) {
|
private HuamiSupport setDateDisplay(TransactionBuilder builder) {
|
||||||
DateTimeDisplay dateTimeDisplay = HuamiCoordinator.getDateDisplay(getContext());
|
DateTimeDisplay dateTimeDisplay = HuamiCoordinator.getDateDisplay(getContext(), gbDevice.getAddress());
|
||||||
LOG.info("Setting date display to " + dateTimeDisplay);
|
LOG.info("Setting date display to " + dateTimeDisplay);
|
||||||
switch (dateTimeDisplay) {
|
switch (dateTimeDisplay) {
|
||||||
case TIME:
|
case TIME:
|
||||||
|
10
app/src/main/res/drawable/ic_access_time.xml
Normal file
10
app/src/main/res/drawable/ic_access_time.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="#7E7E7E"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8zM12.5,7H11v6l5.25,3.15 0.75,-1.23 -4.5,-2.67z" />
|
||||||
|
</vector>
|
10
app/src/main/res/drawable/ic_font_download.xml
Normal file
10
app/src/main/res/drawable/ic_font_download.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="#7E7E7E"
|
||||||
|
android:viewportWidth="24.0"
|
||||||
|
android:viewportHeight="24.0">
|
||||||
|
<path
|
||||||
|
android:fillColor="#FF000000"
|
||||||
|
android:pathData="M9.93,13.5h4.14L12,7.98zM20,2L4,2c-1.1,0 -2,0.9 -2,2v16c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,4c0,-1.1 -0.9,-2 -2,-2zM15.95,18.5l-1.14,-3L9.17,15.5l-1.12,3L5.96,18.5l5.11,-13h1.86l5.11,13h-2.09z" />
|
||||||
|
</vector>
|
@ -1,12 +1,30 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<MultiSelectListPreference
|
<MultiSelectListPreference
|
||||||
android:icon="@drawable/ic_widgets"
|
|
||||||
android:defaultValue="@array/pref_mi2_display_items_default"
|
android:defaultValue="@array/pref_mi2_display_items_default"
|
||||||
android:dialogTitle="@string/mi2_prefs_display_items"
|
android:dialogTitle="@string/mi2_prefs_display_items"
|
||||||
android:entries="@array/pref_mi2_display_items"
|
android:entries="@array/pref_mi2_display_items"
|
||||||
android:entryValues="@array/pref_mi2_display_items_values"
|
android:entryValues="@array/pref_mi2_display_items_values"
|
||||||
|
android:icon="@drawable/ic_widgets"
|
||||||
android:key="display_items"
|
android:key="display_items"
|
||||||
android:summary="@string/mi2_prefs_display_items_summary"
|
android:summary="@string/mi2_prefs_display_items_summary"
|
||||||
android:title="@string/mi2_prefs_display_items" />
|
android:title="@string/mi2_prefs_display_items" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:icon="@drawable/ic_font_download"
|
||||||
|
android:key="mi2_enable_text_notifications"
|
||||||
|
android:layout="@layout/preference_checkbox"
|
||||||
|
android:summary="@string/mi2_enable_text_notifications_summary"
|
||||||
|
android:title="@string/mi2_enable_text_notifications" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
android:defaultValue="@string/p_dateformat_time"
|
||||||
|
android:icon="@drawable/ic_access_time"
|
||||||
|
android:entries="@array/mi2_dateformats"
|
||||||
|
android:entryValues="@array/mi2_dateformats_values"
|
||||||
|
android:key="mi2_dateformat"
|
||||||
|
android:summary="%s"
|
||||||
|
android:title="@string/miband2_prefs_dateformat" />
|
||||||
|
|
||||||
</androidx.preference.PreferenceScreen>
|
</androidx.preference.PreferenceScreen>
|
||||||
|
@ -271,24 +271,6 @@
|
|||||||
android:icon="@drawable/ic_device_miband"
|
android:icon="@drawable/ic_device_miband"
|
||||||
android:key="pref_key_miband"
|
android:key="pref_key_miband"
|
||||||
android:title="@string/preferences_miband_settings" />
|
android:title="@string/preferences_miband_settings" />
|
||||||
<PreferenceScreen
|
|
||||||
android:icon="@drawable/ic_device_miband2"
|
|
||||||
android:title="@string/preferences_miband2_settings">
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:layout="@layout/preference_checkbox"
|
|
||||||
android:defaultValue="true"
|
|
||||||
android:key="mi2_enable_text_notifications"
|
|
||||||
android:summaryOn="@string/mi2_enable_text_notifications_summary"
|
|
||||||
android:summaryOff="@string/off"
|
|
||||||
android:title="@string/mi2_enable_text_notifications" />
|
|
||||||
<ListPreference
|
|
||||||
android:defaultValue="@string/p_dateformat_time"
|
|
||||||
android:entries="@array/mi2_dateformats"
|
|
||||||
android:entryValues="@array/mi2_dateformats_values"
|
|
||||||
android:key="mi2_dateformat"
|
|
||||||
android:title="@string/miband2_prefs_dateformat"
|
|
||||||
android:summary="%s" />
|
|
||||||
</PreferenceScreen>
|
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:icon="@drawable/ic_device_pebble"
|
android:icon="@drawable/ic_device_pebble"
|
||||||
|
Loading…
Reference in New Issue
Block a user