mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-21 16:02:04 +02:00
add an option for searching a Bluetooth scale on startup
This commit is contained in:
@@ -98,7 +98,6 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
|
||||
|
@@ -56,8 +56,8 @@ public class MainActivity extends ActionBarActivity implements
|
||||
*/
|
||||
private SectionsPagerAdapter mSectionsPagerAdapter;
|
||||
|
||||
private static boolean firstAppStart = false;
|
||||
private static int bluetoothStatusIcon = 0;
|
||||
private static boolean firstAppStart = true;
|
||||
private static int bluetoothStatusIcon = R.drawable.bluetooth_disabled;
|
||||
private static MenuItem bluetoothStatus;
|
||||
|
||||
/**
|
||||
@@ -127,10 +127,12 @@ public class MainActivity extends ActionBarActivity implements
|
||||
|
||||
bluetoothStatus = menu.findItem(R.id.action_bluetooth_status);
|
||||
|
||||
// Just search for a bluetooth device just once at the start of the app
|
||||
if (!firstAppStart) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
// Just search for a bluetooth device just once at the start of the app and if start preference enabled
|
||||
if (firstAppStart && prefs.getBoolean("btEnable", false)) {
|
||||
invokeSearchBluetoothDevice();
|
||||
firstAppStart = true;
|
||||
firstAppStart = false;
|
||||
} else {
|
||||
// Set current bluetooth status icon while e.g. orientation changes
|
||||
setBluetoothStatusIcon(bluetoothStatusIcon);
|
||||
@@ -155,9 +157,9 @@ public class MainActivity extends ActionBarActivity implements
|
||||
if (id == R.id.action_bluetooth_status) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if (prefs.getBoolean("btEnable", false) && BluetoothAdapter.getDefaultAdapter().isEnabled()) {
|
||||
if (BluetoothAdapter.getDefaultAdapter().isEnabled()) {
|
||||
String deviceName = prefs.getString("btDeviceName", "MI_SCALE");
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.info_bluetooth_try_reconnection) + " " + deviceName, Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.info_bluetooth_try_connection) + " " + deviceName, Toast.LENGTH_SHORT).show();
|
||||
invokeSearchBluetoothDevice();
|
||||
} else {
|
||||
setBluetoothStatusIcon(R.drawable.bluetooth_disabled);
|
||||
@@ -183,7 +185,6 @@ public class MainActivity extends ActionBarActivity implements
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if(prefs.getBoolean("btEnable", false)) {
|
||||
String deviceName = prefs.getString("btDeviceName", "MI_SCALE");
|
||||
String deviceType = prefs.getString("btDeviceTypes", "0");
|
||||
|
||||
@@ -200,9 +201,6 @@ public class MainActivity extends ActionBarActivity implements
|
||||
|
||||
OpenScale.getInstance(getApplicationContext()).stopSearchingForBluetooth();
|
||||
OpenScale.getInstance(getApplicationContext()).startSearchingForBluetooth(Integer.parseInt(deviceType), deviceName, callbackBtHandler);
|
||||
} else {
|
||||
setBluetoothStatusIcon(R.drawable.bluetooth_disabled);
|
||||
}
|
||||
}
|
||||
|
||||
private final Handler callbackBtHandler = new Handler() {
|
||||
|
@@ -135,16 +135,6 @@ private void updatePrefSummary(Preference p) {
|
||||
EditTextPreference editTextPref = (EditTextPreference) p;
|
||||
p.setSummary(editTextPref.getText());
|
||||
}
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
if(prefs.getBoolean("btEnable", true))
|
||||
{
|
||||
findPreference("btDeviceName").setEnabled(true);
|
||||
findPreference("btDeviceTypes").setEnabled(true);
|
||||
} else {
|
||||
findPreference("btDeviceName").setEnabled(false);
|
||||
findPreference("btDeviceTypes").setEnabled(false);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||
|
@@ -38,7 +38,7 @@
|
||||
<string name="info_your_weight">Dein Gewicht war</string>
|
||||
<string name="label_add">Hinzufügen</string>
|
||||
<string name="label_birthday">Geburtstag</string>
|
||||
<string name="label_bluetooth_enable">Suche nach Bluetooth Waage</string>
|
||||
<string name="label_bluetooth_enable">Suche nach Waage beim Start</string>
|
||||
<string name="label_bluetooth_title">Bluetooth</string>
|
||||
<string name="label_bmi">BMI</string>
|
||||
<string name="label_body_height">Körpergröße</string>
|
||||
@@ -101,7 +101,7 @@
|
||||
<string name="info_bluetooth_connection_lost">Bluetooth Verbindung verloren</string>
|
||||
<string name="info_bluetooth_connection_successful">Verbindung erfolgreich hergestellt</string>
|
||||
<string name="info_bluetooth_no_device">Kein Bluetooth Gerät gefunden</string>
|
||||
<string name="info_bluetooth_try_reconnection">Versuche Verbindung herzustellen zu</string>
|
||||
<string name="info_bluetooth_try_connection">Versuche Verbindung herzustellen zu</string>
|
||||
<string name="label_device_type">Gerätetyp</string>
|
||||
<string name="info_bluetooth_init">Initializiere Bluetooth Gerät</string>
|
||||
</resources>
|
@@ -42,7 +42,7 @@
|
||||
<string name="label_title_last_measurement">最終の計測</string>
|
||||
<string name="label_goal_date_is">目標期日は</string>
|
||||
<string name="label_delete_all">全てデリート</string>
|
||||
<string name="label_bluetooth_enable">Bluetoothの体重計を探索する</string>
|
||||
<string name="label_bluetooth_enable">起動時に体重計を探索します</string>
|
||||
<string name="label_last_month">過去30日</string>
|
||||
<string name="label_last_week">過去7日</string>
|
||||
<string name="label_device_name">デバイス名</string>
|
||||
@@ -98,7 +98,7 @@
|
||||
<string name="label_whr">ウエストヒップ比</string>
|
||||
<string name="action_bluetooth_status">Bluetoothステータス</string>
|
||||
<string name="info_bluetooth_no_device">Bluetooth接続を確立できなかった場合</string>
|
||||
<string name="info_bluetooth_try_reconnection">再接続しようとしています</string>
|
||||
<string name="info_bluetooth_try_connection">接続しようとしています</string>
|
||||
<string name="info_bluetooth_connection_error">Bluetoothに予期しないエラーがあります</string>
|
||||
<string name="info_bluetooth_connection_lost">Bluetooth接続を失いました</string>
|
||||
<string name="info_bluetooth_connection_successful">接続に成功しました</string>
|
||||
|
@@ -92,7 +92,7 @@
|
||||
<string name="info_is_not_available">is not available</string>
|
||||
<string name="info_delete_bluetooth_data">Clear all Bluetooth data</string>
|
||||
<string name="info_delete_bluetooth_data_success">Bluetooth data was successful cleared</string>
|
||||
<string name="info_bluetooth_try_reconnection">Trying to reconnect to</string>
|
||||
<string name="info_bluetooth_try_connection">Trying to connect to</string>
|
||||
<string name="info_bluetooth_connection_lost">Lost Bluetooth connection.</string>
|
||||
<string name="info_bluetooth_no_device">No Bluetooth device found</string>
|
||||
<string name="info_bluetooth_connection_successful">Connection successful established</string>
|
||||
@@ -107,7 +107,7 @@
|
||||
<string name="question_really_delete_user">Do you really want to delete the user? </string>
|
||||
|
||||
<string name="label_bluetooth_title">Bluetooth</string>
|
||||
<string name="label_bluetooth_enable">Search for Bluetooth scale</string>
|
||||
<string name="label_bluetooth_enable">Search for scale on startup</string>
|
||||
<string name="label_device_name">Device Name</string>
|
||||
<string name="label_device_type">Device Type</string>
|
||||
|
||||
|
Reference in New Issue
Block a user