1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-23 16:53:04 +02:00

added an option for merging the Bluetooth measurement with the latest measurement

This commit is contained in:
OliE
2018-02-27 18:29:59 +01:00
parent f1a9f0a71d
commit b4d11190cc
4 changed files with 12 additions and 5 deletions

View File

@@ -74,6 +74,7 @@ import cat.ereza.customactivityoncrash.config.CaocConfig;
public class MainActivity extends AppCompatActivity
implements SharedPreferences.OnSharedPreferenceChangeListener{
private SharedPreferences prefs;
private static boolean firstAppStart = true;
private static boolean valueOfCountModified = false;
private static int bluetoothStatusIcon = R.drawable.ic_bluetooth_disabled;
@@ -91,7 +92,7 @@ public class MainActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
String app_theme = prefs.getString("app_theme", "Light");
@@ -492,11 +493,13 @@ public class MainActivity extends AppCompatActivity
OpenScale openScale = OpenScale.getInstance(getApplicationContext());
List<ScaleMeasurement> scaleMeasurementList = openScale.getScaleMeasurementList();
if (prefs.getBoolean("mergeWithLastMeasurement", true)) {
List<ScaleMeasurement> scaleMeasurementList = openScale.getScaleMeasurementList();
if (!scaleMeasurementList.isEmpty()) {
ScaleMeasurement lastMeasurement = scaleMeasurementList.get(0);
scaleBtData.merge(lastMeasurement);
if (!scaleMeasurementList.isEmpty()) {
ScaleMeasurement lastMeasurement = scaleMeasurementList.get(0);
scaleBtData.merge(lastMeasurement);
}
}
openScale.addScaleData(scaleBtData);

View File

@@ -180,5 +180,6 @@
<string name="label_press_hold_reorder">Halten Sie die Taste gedrückt, um die Reihenfolge zu ändern</string>
<string name="label_set_default_order">Default Reihenfolge wiederherstellen</string>
<string name="label_share_subject">openScale CSV Datenexport (%s)</string>
<string name="label_mergeWithLastMeasurement">Zusammenführen mit der letzten Messung</string>
</resources>

View File

@@ -119,6 +119,7 @@
<string name="label_bluetooth_title">Bluetooth</string>
<string name="label_bluetooth_enable">Search for scale on startup</string>
<string name="label_mergeWithLastMeasurement">Merge with last measurement</string>
<string name="label_bluetooth_searching">Searching for Bluetooth scales</string>
<string name="label_bluetooth_searching_finished">Finished searching for Bluetooth scales</string>
<string name="label_device_type">Device Type</string>
@@ -211,4 +212,5 @@
<string name="label_press_hold_reorder">Press and hold to reorder</string>
<string name="label_set_default_order">Set default order</string>
</resources>

View File

@@ -6,6 +6,7 @@
android:persistent="false">
<Preference android:key="0" android:title="@string/label_device_type"/>
</PreferenceScreen>
<CheckBoxPreference android:title="@string/label_mergeWithLastMeasurement" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="mergeWithLastMeasurement" android:defaultValue="true"/>
<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"/>
<CheckBoxPreference android:title="@string/label_smartUserAssign" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="smartUserAssign" android:defaultValue="false"/>
<CheckBoxPreference android:title="@string/label_ignoreOutOfRange" android:summaryOn="@string/info_is_enable" android:summaryOff="@string/info_is_not_enable" android:key="ignoreOutOfRange" android:enabled="false" android:defaultValue="false"/>