use of nodomain.freeyourgadget.gadgetbridge.util.Prefs in project Gadgetbridge by Freeyourgadget.
the class MiBandCoordinator method getWearLocation.
public static int getWearLocation(String miBandAddress) throws IllegalArgumentException {
//left hand
int location = 0;
Prefs prefs = GBApplication.getPrefs();
if ("right".equals(prefs.getString(MiBandConst.PREF_MIBAND_WEARSIDE, "left"))) {
// right hand
location = 1;
}
return location;
}
use of nodomain.freeyourgadget.gadgetbridge.util.Prefs in project Gadgetbridge by Freeyourgadget.
the class BluetoothStateChangeReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1) == BluetoothAdapter.STATE_ON) {
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
LocalBroadcastManager.getInstance(context).sendBroadcast(refreshIntent);
Prefs prefs = GBApplication.getPrefs();
if (!prefs.getBoolean("general_autoconnectonbluetooth", false)) {
return;
}
LOG.info("Bluetooth turned on => connecting...");
GBApplication.deviceService().connect();
} else if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1) == BluetoothAdapter.STATE_OFF) {
GBApplication.quit();
}
}
}
use of nodomain.freeyourgadget.gadgetbridge.util.Prefs in project Gadgetbridge by Freeyourgadget.
the class TimeChangeReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
Prefs prefs = GBApplication.getPrefs();
final String action = intent.getAction();
if (prefs.getBoolean("datetime_synconconnect", true) && (action.equals(Intent.ACTION_TIME_CHANGED) || action.equals(Intent.ACTION_TIMEZONE_CHANGED))) {
Date newTime = GregorianCalendar.getInstance().getTime();
LOG.info("Time or Timezone changed, syncing with device: " + DateTimeUtils.formatDate(newTime) + " (" + newTime.toGMTString() + "), " + intent.getAction());
GBApplication.deviceService().onSetTime();
}
}
use of nodomain.freeyourgadget.gadgetbridge.util.Prefs in project Gadgetbridge by Freeyourgadget.
the class GBAlarm method store.
public void store() {
Prefs prefs = GBApplication.getPrefs();
Set<String> preferencesAlarmListSet = prefs.getStringSet(PREF_MIBAND_ALARMS, new HashSet<String>());
//the old Set cannot be updated in place see http://developer.android.com/reference/android/content/SharedPreferences.html#getStringSet%28java.lang.String,%20java.util.Set%3Cjava.lang.String%3E%29
Set<String> newPrefs = new HashSet<>(preferencesAlarmListSet);
Iterator<String> iterator = newPrefs.iterator();
while (iterator.hasNext()) {
String alarmString = iterator.next();
if (this.equals(new GBAlarm(alarmString))) {
iterator.remove();
break;
}
}
newPrefs.add(this.toPreferences());
prefs.getPreferences().edit().putStringSet(PREF_MIBAND_ALARMS, newPrefs).apply();
}
use of nodomain.freeyourgadget.gadgetbridge.util.Prefs in project Gadgetbridge by Freeyourgadget.
the class GBActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
if (GBApplication.isDarkThemeEnabled()) {
setTheme(R.style.GadgetbridgeThemeDark);
} else {
setTheme(R.style.GadgetbridgeTheme);
}
Prefs prefs = GBApplication.getPrefs();
String language = prefs.getString("language", "default");
setLanguage(language);
super.onCreate(savedInstanceState);
}
Aggregations