From 389b11f3a145390b5b2a40ac34bae7a0fda1b431 Mon Sep 17 00:00:00 2001 From: oliexdev Date: Sat, 15 Aug 2020 08:19:43 +0200 Subject: [PATCH] fixed bug for fetching strings, see issue #608 --- .../gui/preferences/BluetoothSettingsFragment.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java b/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java index 8c3c4330..63bbcba5 100644 --- a/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java +++ b/android_app/app/src/main/java/com/health/openscale/gui/preferences/BluetoothSettingsFragment.java @@ -67,8 +67,6 @@ import java.util.Map; import timber.log.Timber; public class BluetoothSettingsFragment extends Fragment { - private Context context; - public static final String PREFERENCE_KEY_BLUETOOTH_DEVICE_NAME = "btDeviceName"; public static final String PREFERENCE_KEY_BLUETOOTH_HW_ADDRESS = "btHwAddress"; @@ -86,8 +84,6 @@ public class BluetoothSettingsFragment extends Fragment { setHasOptionsMenu(true); - context = getContext(); - deviceListView = root.findViewById(R.id.deviceListView); txtSearching = root.findViewById(R.id.txtSearching); progressBar = root.findViewById(R.id.progressBar); @@ -156,9 +152,9 @@ public class BluetoothSettingsFragment extends Fragment { txtSearching.setText(R.string.label_bluetooth_searching_finished); progressBar.setVisibility(View.GONE); - BluetoothDeviceView notSupported = new BluetoothDeviceView(context); - notSupported.setDeviceName(getString(R.string.label_scale_not_supported)); - notSupported.setSummaryText(getString(R.string.label_click_to_help_add_support)); + BluetoothDeviceView notSupported = new BluetoothDeviceView(getContext()); + notSupported.setDeviceName(getContext().getString(R.string.label_scale_not_supported)); + notSupported.setSummaryText(getContext().getString(R.string.label_click_to_help_add_support)); notSupported.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { @@ -207,7 +203,7 @@ public class BluetoothSettingsFragment extends Fragment { Timber.d("Found unsupported device %s", formatDeviceName(device)); deviceView.setIcon(R.drawable.ic_bluetooth_device_not_supported); - deviceView.setSummaryText(getString(R.string.label_bt_device_no_support)); + deviceView.setSummaryText(getContext().getString(R.string.label_bt_device_no_support)); deviceView.setEnabled(false); if (OpenScale.DEBUG_MODE) { @@ -346,7 +342,7 @@ public class BluetoothSettingsFragment extends Fragment { public void onClick(View view) { BluetoothDevice device = foundDevices.get(getDeviceAddress()); - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); prefs.edit() .putString(PREFERENCE_KEY_BLUETOOTH_HW_ADDRESS, device.getAddress())