1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 01:55:50 +01:00

Move Mi Band MAC address setting to Mi Band Settings

This commit is contained in:
Andreas Shimokawa 2015-05-10 13:08:28 +02:00
parent e78c912be3
commit 7f5b495480
7 changed files with 37 additions and 37 deletions

View File

@ -25,6 +25,7 @@ import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.adapter.GBDeviceAdapter;
import nodomain.freeyourgadget.gadgetbridge.discovery.DiscoveryActivity;
import nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst;
public class ControlCenter extends Activity {
@ -209,7 +210,7 @@ public class ControlCenter extends Activity {
}
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
String miAddr = sharedPrefs.getString(GB.PREF_DEVELOPMENT_MIBAND_ADDRESS, null);
String miAddr = sharedPrefs.getString(MiBandConst.PREF_MIBAND_ADDRESS, null);
if (miAddr != null && miAddr.length() > 0) {
GBDevice miDevice = new GBDevice(miAddr, "MI", DeviceType.MIBAND);
if (!availableDevices.contains(miDevice)) {

View File

@ -22,8 +22,6 @@ public class GB {
public static final int NOTIFICATION_ID = 1;
private static final String TAG = "GB";
public static final String PREF_DEVELOPMENT_MIBAND_ADDRESS = "development_miaddr";
public static Notification createNotification(String text, Context context) {
Intent notificationIntent = new Intent(context, ControlCenter.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK

View File

@ -42,21 +42,5 @@ public class SettingsActivity extends AbstractSettingsActivity {
}
});
final Preference developmentMiaddr = findPreference(GB.PREF_DEVELOPMENT_MIBAND_ADDRESS);
developmentMiaddr.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[] { GB.PREF_DEVELOPMENT_MIBAND_ADDRESS };
}
}

View File

@ -8,5 +8,5 @@ public interface MiBandConst {
String PREF_USER_GENDER = "mi_user_gender";
String PREF_USER_HEIGHT_CM = "mi_user_height_cm";
String PREF_USER_WEIGHT_KG = "mi_user_weight_kg";
String PREF_MIBAND_ADDRESS = GB.PREF_DEVELOPMENT_MIBAND_ADDRESS;
String PREF_MIBAND_ADDRESS = "development_miaddr"; // FIXME: should be prefixed mi_
}

View File

@ -1,9 +1,12 @@
package nodomain.freeyourgadget.gadgetbridge.miband;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.support.v4.content.LocalBroadcastManager;
import nodomain.freeyourgadget.gadgetbridge.ControlCenter;
import nodomain.freeyourgadget.gadgetbridge.GB;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.AbstractSettingsActivity;
@ -14,17 +17,30 @@ public class MiBandPreferencesActivity extends AbstractSettingsActivity {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.miband_preferences);
final Preference developmentMiaddr = findPreference(MiBandConst.PREF_MIBAND_ADDRESS);
developmentMiaddr.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() {
String[] prefsWithSummary = {
return new String[]{
MiBandConst.PREF_USER_ALIAS,
MiBandConst.PREF_USER_YEAR_OF_BIRTH,
MiBandConst.PREF_USER_GENDER,
MiBandConst.PREF_USER_HEIGHT_CM,
MiBandConst.PREF_USER_WEIGHT_KG
MiBandConst.PREF_USER_WEIGHT_KG,
MiBandConst.PREF_MIBAND_ADDRESS
};
return prefsWithSummary;
}
}

View File

@ -9,8 +9,8 @@
android:title="@string/miband_prefs_alias" />
<EditTextPreference
android:key="mi_user_year_of_birth"
android:digits="0123456789"
android:key="mi_user_year_of_birth"
android:maxLength="4"
android:title="@string/miband_prefs_year_birth" />
@ -23,17 +23,27 @@
<!--TODO: support localized heights and weights -->
<EditTextPreference
android:key="mi_user_height_cm"
android:digits="0123456789"
android:key="mi_user_height_cm"
android:maxLength="3"
android:title="@string/miband_prefs_height_cm" />
<EditTextPreference
android:key="mi_user_weight_kg"
android:digits="0123456789"
android:key="mi_user_weight_kg"
android:maxLength="3"
android:title="@string/miband_prefs_weight_kg" />
</PreferenceCategory>
<PreferenceCategory
android:key="pref_key_development"
android:title="@string/pref_header_development">
<EditTextPreference
android:digits="0123456789ABCDEF:"
android:key="development_miaddr"
android:maxLength="17"
android:title="@string/pref_title_development_miaddr" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -14,6 +14,7 @@
<CheckBoxPreference
android:defaultValue="true"
android:key="datetime_synconconnect"
android:summary="@string/pref_summary_datetime_syctimeonconnect"
android:title="@string/pref_title_datetime_syctimeonconnect" />
</PreferenceCategory>
<PreferenceCategory
@ -59,14 +60,4 @@
android:key="pref_key_miband"
android:title="@string/preferences_miband_settings" />
</PreferenceCategory>
<PreferenceCategory
android:key="pref_key_development"
android:title="@string/pref_header_development">
<EditTextPreference
android:digits="0123456789ABCDEF:"
android:key="development_miaddr"
android:maxLength="17"
android:title="@string/pref_title_development_miaddr" />
</PreferenceCategory>
</PreferenceScreen>
</PreferenceScreen>