2015-08-03 23:09:49 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.activities;
|
2015-01-07 14:00:18 +01:00
|
|
|
|
2015-03-15 21:36:39 +01:00
|
|
|
import android.content.Intent;
|
2015-01-07 14:00:18 +01:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.preference.Preference;
|
2015-08-19 00:03:52 +02:00
|
|
|
import android.support.v4.content.LocalBroadcastManager;
|
2015-01-07 14:00:18 +01:00
|
|
|
|
2015-08-03 23:09:49 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandPreferencesActivity;
|
2015-05-07 01:30:40 +02:00
|
|
|
|
|
|
|
public class SettingsActivity extends AbstractSettingsActivity {
|
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
addPreferencesFromResource(R.xml.preferences);
|
|
|
|
}
|
|
|
|
|
2015-01-07 14:00:18 +01:00
|
|
|
@Override
|
|
|
|
protected void onPostCreate(Bundle savedInstanceState) {
|
|
|
|
super.onPostCreate(savedInstanceState);
|
|
|
|
|
2015-05-12 20:09:35 +02:00
|
|
|
Preference pref = findPreference("notifications_generic");
|
2015-03-15 21:36:39 +01:00
|
|
|
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
|
|
|
public boolean onPreferenceClick(Preference preference) {
|
|
|
|
Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
|
|
|
|
startActivity(enableIntent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2015-05-12 20:09:35 +02:00
|
|
|
pref = findPreference("pref_key_miband");
|
2015-05-07 01:30:40 +02:00
|
|
|
pref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
|
|
|
public boolean onPreferenceClick(Preference preference) {
|
|
|
|
Intent enableIntent = new Intent(SettingsActivity.this, MiBandPreferencesActivity.class);
|
|
|
|
startActivity(enableIntent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2015-04-19 12:35:23 +02:00
|
|
|
|
2015-08-19 00:03:52 +02:00
|
|
|
final Preference pebbleEmuAddr = findPreference("pebble_emu_addr");
|
|
|
|
pebbleEmuAddr.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
|
|
|
Intent refreshIntent = new Intent(ControlCenter.ACTION_REFRESH_DEVICELIST);
|
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(refreshIntent);
|
|
|
|
preference.setSummary(newVal.toString());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
final Preference pebbleEmuPort = findPreference("pebble_emu_port");
|
|
|
|
pebbleEmuPort.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onPreferenceChange(Preference preference, Object newVal) {
|
|
|
|
Intent refreshIntent = new Intent(ControlCenter.ACTION_REFRESH_DEVICELIST);
|
|
|
|
LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(refreshIntent);
|
|
|
|
preference.setSummary(newVal.toString());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected String[] getPreferenceKeysWithSummary() {
|
|
|
|
return new String[]{
|
|
|
|
"pebble_emu_addr",
|
|
|
|
"pebble_emu_port"
|
|
|
|
};
|
2015-01-07 14:00:18 +01:00
|
|
|
}
|
2015-08-19 00:03:52 +02:00
|
|
|
|
2015-01-07 14:00:18 +01:00
|
|
|
}
|