Search in sources :

Example 11 with Prefs

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;
}
Also used : Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs)

Example 12 with Prefs

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();
        }
    }
}
Also used : Intent(android.content.Intent) Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs)

Example 13 with Prefs

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();
    }
}
Also used : Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs) Date(java.util.Date)

Example 14 with Prefs

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();
}
Also used : Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs) HashSet(java.util.HashSet)

Example 15 with Prefs

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);
}
Also used : Prefs(nodomain.freeyourgadget.gadgetbridge.util.Prefs)

Aggregations

Prefs (nodomain.freeyourgadget.gadgetbridge.util.Prefs)31 Intent (android.content.Intent)6 IOException (java.io.IOException)5 BluetoothGattCharacteristic (android.bluetooth.BluetoothGattCharacteristic)3 PowerManager (android.os.PowerManager)3 GregorianCalendar (java.util.GregorianCalendar)3 HashSet (java.util.HashSet)3 Alarm (nodomain.freeyourgadget.gadgetbridge.model.Alarm)3 NotificationSpec (nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec)3 TransactionBuilder (nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder)3 Notification (android.app.Notification)2 PackageManager (android.content.pm.PackageManager)2 Criteria (android.location.Criteria)2 Location (android.location.Location)2 LocationManager (android.location.LocationManager)2 Bundle (android.os.Bundle)2 StatusBarNotification (android.service.notification.StatusBarNotification)2 ArrayList (java.util.ArrayList)2 Calendar (java.util.Calendar)2 VibrationProfile (nodomain.freeyourgadget.gadgetbridge.devices.miband.VibrationProfile)2