mirror of
https://github.com/oliexdev/openScale.git
synced 2025-08-19 23:12:12 +02:00
use MI_SCALE as default device name
check if bluetooth on the device is enabled
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.health.openscale.gui;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -144,11 +145,12 @@ public class MainActivity extends ActionBarActivity implements
|
||||
if (id == R.id.action_bluetooth_status) {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if (prefs.getBoolean("btEnable", false)) {
|
||||
String deviceName = prefs.getString("btDeviceName", "openScale");
|
||||
if (prefs.getBoolean("btEnable", false) && 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();
|
||||
invokeSearchBluetoothDevice();
|
||||
} else {
|
||||
bluetoothStatus.setIcon(getResources().getDrawable(R.drawable.bluetooth_disabled));
|
||||
Toast.makeText(getApplicationContext(), "Bluetooth " + getResources().getString(R.string.info_is_not_enable), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
return true;
|
||||
@@ -165,10 +167,14 @@ public class MainActivity extends ActionBarActivity implements
|
||||
}
|
||||
|
||||
private void invokeSearchBluetoothDevice() {
|
||||
if (!BluetoothAdapter.getDefaultAdapter().isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
|
||||
if(prefs.getBoolean("btEnable", false)) {
|
||||
String deviceName = prefs.getString("btDeviceName", "openScale");
|
||||
String deviceName = prefs.getString("btDeviceName", "MI_SCALE");
|
||||
String deviceType = prefs.getString("btDeviceTypes", "0");
|
||||
|
||||
// Check if Bluetooth 4.x is available
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<PreferenceCategory android:title="@string/label_bluetooth_title">
|
||||
<CheckBoxPreference android:title="@string/label_bluetooth_enable" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="btEnable" android:defaultValue="false"/>
|
||||
<ListPreference android:title="@string/label_device_type" android:key="btDeviceTypes" android:entries="@array/btDeviceTypes" android:entryValues="@array/btDeviceTypesAlias" android:defaultValue="0"/>
|
||||
<EditTextPreference android:title="@string/label_device_name" android:key="btDeviceName" android:defaultValue="openScale" />
|
||||
<EditTextPreference android:title="@string/label_device_name" android:key="btDeviceName" android:defaultValue="MI_SCALE" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory android:title="@string/title_graph">
|
||||
|
Reference in New Issue
Block a user