1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-16 21:54:05 +02:00

ignore weight data that are out of range

This commit is contained in:
OliE
2017-06-10 13:34:29 +02:00
parent 64afdb0ff9
commit 870d6ed08e
5 changed files with 32 additions and 4 deletions

View File

@@ -181,6 +181,7 @@ public class OpenScale {
scaleData.setUserId(getSelectedScaleUser().id);
}
// don't add scale data if no user is selected
if (scaleData.getUserId() == -1) {
return -1;
}
@@ -215,6 +216,14 @@ public class OpenScale {
return inRangeWeights.entrySet().iterator().next().getValue();
}
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
// if ignore out of range preference is true don't add this data
if (prefs.getBoolean("ignoreOfOutRange", false)) {
return -1;
}
// return selected scale user id if not out of range preference is checked and weight is out of range of any user
return getSelectedScaleUser().id;
}

View File

@@ -17,6 +17,7 @@ package com.health.openscale.gui.preferences;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.MultiSelectListPreference;
@@ -33,10 +34,16 @@ import java.util.Set;
public class BluetoothPreferences extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener {
String[] btDeviceSupportInit;
String[] btDeviceSupportDataTransfer;
String[] btDeviceSupportDataHistory;
String[] btDeviceDefaultName;
public static final String PREFERENCE_KEY_BLUETOOTH_SMARTUSERASSIGN = "smartUserAssign";
private static final String PREFERENCE_KEY_BLUETOOTH_IGNOREOUTOFRANGE = "ignoreOutOfRange";
private CheckBoxPreference smartAssignEnable;
private CheckBoxPreference ignoreOutOfRangeEnable;
private String[] btDeviceSupportInit;
private String[] btDeviceSupportDataTransfer;
private String[] btDeviceSupportDataHistory;
private String[] btDeviceDefaultName;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -44,6 +51,9 @@ public class BluetoothPreferences extends PreferenceFragment implements SharedPr
addPreferencesFromResource(R.xml.bluetooth_preferences);
smartAssignEnable = (CheckBoxPreference) findPreference(PREFERENCE_KEY_BLUETOOTH_SMARTUSERASSIGN);
ignoreOutOfRangeEnable = (CheckBoxPreference) findPreference(PREFERENCE_KEY_BLUETOOTH_IGNOREOUTOFRANGE);
btDeviceSupportInit = getResources().getStringArray(R.array.bt_device_support_initializing);
btDeviceSupportDataTransfer = getResources().getStringArray(R.array.bt_device_support_data_transfer);
btDeviceSupportDataHistory = getResources().getStringArray(R.array.bt_device_support_data_history);
@@ -82,6 +92,12 @@ public class BluetoothPreferences extends PreferenceFragment implements SharedPr
}
private void updatePrefSummary(Preference p) {
if (smartAssignEnable.isChecked()) {
ignoreOutOfRangeEnable.setEnabled(true);
} else {
ignoreOutOfRangeEnable.setEnabled(false);
}
if (p instanceof ListPreference) {
ListPreference listPref = (ListPreference) p;

View File

@@ -126,4 +126,5 @@
<string name="label_importBackup">Importiere Datensicherung</string>
<string name="label_export_dir">Export Ordner</string>
<string name="label_not_found">nicht gefunden</string>
<string name="label_ignoreOutOfRange">Ignoriere Daten außerhalb des zulässigen Bereiches</string>
</resources>

View File

@@ -145,4 +145,5 @@
<string name="label_backup">Backup</string>
<string name="label_export_dir">Export dir</string>
<string name="label_not_found">not found</string>
<string name="label_ignoreOutOfRange">Ignore data that are out of range</string>
</resources>

View File

@@ -4,4 +4,5 @@
<EditTextPreference android:title="@string/label_device_name" android:key="btDeviceName" android:defaultValue="MI_SCALE" />
<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"/>
</PreferenceScreen>