diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 6c095261f..228e131ae 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -35,7 +35,7 @@ -keepattributes JavascriptInterface # https://github.com/tony19/logback-android/issues/29 --dontwarn javax.mail.**, javax.naming.Context, javax.naming.InitialContext +-dontwarn javax.mail.** # To avoid any stacktrace ambiguity -keepattributes SourceFile,LineNumberTable diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java index e3424f418..58954df3a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/AbstractDeviceCoordinator.java @@ -18,6 +18,8 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices; +import static nodomain.freeyourgadget.gadgetbridge.GBApplication.getPrefs; + import android.app.Activity; import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; @@ -62,12 +64,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.PaiSample; import nodomain.freeyourgadget.gadgetbridge.model.SleepRespiratoryRateSample; import nodomain.freeyourgadget.gadgetbridge.model.Spo2Sample; import nodomain.freeyourgadget.gadgetbridge.model.StressSample; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; -import static nodomain.freeyourgadget.gadgetbridge.GBApplication.getPrefs; - public abstract class AbstractDeviceCoordinator implements DeviceCoordinator { private static final Logger LOG = LoggerFactory.getLogger(AbstractDeviceCoordinator.class); @@ -110,13 +109,13 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator { } Prefs prefs = getPrefs(); - String lastDevice = prefs.getPreferences().getString("last_device_address",""); + String lastDevice = prefs.getPreferences().getString("last_device_address", ""); if (gbDevice.getAddress().equals(lastDevice)) { LOG.debug("#1605 removing last device"); prefs.getPreferences().edit().remove("last_device_address").apply(); } - String macAddress = prefs.getPreferences().getString(MiBandConst.PREF_MIBAND_ADDRESS,""); + String macAddress = prefs.getPreferences().getString(MiBandConst.PREF_MIBAND_ADDRESS, ""); if (gbDevice.getAddress().equals(macAddress)) { LOG.debug("#1605 removing devel miband"); prefs.getPreferences().edit().remove(MiBandConst.PREF_MIBAND_ADDRESS).apply(); @@ -201,7 +200,13 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator { } public boolean isHealthWearable(BluetoothDevice device) { - BluetoothClass bluetoothClass = device.getBluetoothClass(); + BluetoothClass bluetoothClass; + try { + bluetoothClass = device.getBluetoothClass(); + } catch (SecurityException se) { + LOG.warn("missing bluetooth permission: ", se); + return false; + } if (bluetoothClass == null) { LOG.warn("unable to determine bluetooth device class of " + device); return false; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/binary_sensor/coordinator/BinarySensorCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/binary_sensor/coordinator/BinarySensorCoordinator.java index 4aa3060d4..5ed252131 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/binary_sensor/coordinator/BinarySensorCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/binary_sensor/coordinator/BinarySensorCoordinator.java @@ -1,4 +1,4 @@ -package nodomain.freeyourgadget.gadgetbridge.devices.um25.Coordinator; +package nodomain.freeyourgadget.gadgetbridge.devices.binary_sensor.coordinator; import android.app.Activity; import android.bluetooth.le.ScanFilter; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband5/AmazfitBand5Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband5/AmazfitBand5Coordinator.java index 7e84b9f65..4e6a1f949 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband5/AmazfitBand5Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband5/AmazfitBand5Coordinator.java @@ -53,7 +53,7 @@ public class AmazfitBand5Coordinator extends HuamiCoordinator { if (name != null && name.equalsIgnoreCase(HuamiConst.AMAZFIT_BAND5_NAME)) { return DeviceType.AMAZFITBAND5; } - } catch (Exception ex) { + } catch (SecurityException ex) { LOG.error("unable to check device support", ex); } return DeviceType.UNKNOWN; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7Coordinator.java index 0ec498919..164ab16a2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7Coordinator.java @@ -46,7 +46,7 @@ public class AmazfitBand7Coordinator extends Huami2021Coordinator { if (name != null && name.startsWith(HuamiConst.AMAZFIT_BAND7_NAME)) { return DeviceType.AMAZFITBAND7; } - } catch (final Exception e) { + } catch (SecurityException e) { LOG.error("unable to check device support", e); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/smaq2oss/SMAQ2OSSCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/smaq2oss/SMAQ2OSSCoordinator.java index 000926824..652cd4da3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/smaq2oss/SMAQ2OSSCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/smaq2oss/SMAQ2OSSCoordinator.java @@ -1,20 +1,18 @@ package nodomain.freeyourgadget.gadgetbridge.devices.smaq2oss; -import android.annotation.TargetApi; import android.app.Activity; import android.bluetooth.BluetoothDevice; import android.bluetooth.le.ScanFilter; import android.content.Context; import android.net.Uri; -import android.os.Build; import android.os.ParcelUuid; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.util.Collection; import java.util.Collections; @@ -29,7 +27,6 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.smaq2oss.SMAQ2OSSSupport; public class SMAQ2OSSCoordinator extends AbstractBLEDeviceCoordinator { private static final Logger LOG = LoggerFactory.getLogger(SMAQ2OSSCoordinator.class); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/smaq2oss/SMAQ2OSSSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/smaq2oss/SMAQ2OSSSupport.java index 0dc5eecab..e7f204b60 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/smaq2oss/SMAQ2OSSSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/smaq2oss/SMAQ2OSSSupport.java @@ -1,4 +1,4 @@ -package nodomain.freeyourgadget.gadgetbridge.service.devices.smaq2oss; +package nodomain.freeyourgadget.gadgetbridge.devices.smaq2oss; import android.bluetooth.BluetoothGatt; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/AndroidUtils.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/AndroidUtils.java index af101a6e6..07cad80df 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/AndroidUtils.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/AndroidUtils.java @@ -17,6 +17,7 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.util; +import android.annotation.SuppressLint; import android.content.ActivityNotFoundException; import android.content.BroadcastReceiver; import android.content.ContentUris; @@ -124,6 +125,7 @@ public class AndroidUtils { dynamicColorContext = DynamicColors.wrapContextIfAvailable(context, R.style.GadgetbridgeThemeDynamicLight); } int[] attrsToResolve = {R.attr.colorOnSurface}; + @SuppressLint("ResourceType") TypedArray ta = dynamicColorContext.obtainStyledAttributes(attrsToResolve); color = ta.getColor(0, 0); ta.recycle(); @@ -149,6 +151,7 @@ public class AndroidUtils { dynamicColorContext = DynamicColors.wrapContextIfAvailable(context, R.style.GadgetbridgeThemeDynamicLight); } int[] attrsToResolve = {R.attr.colorSurface}; + @SuppressLint("ResourceType") TypedArray ta = dynamicColorContext.obtainStyledAttributes(attrsToResolve); color = ta.getColor(0, 0); ta.recycle(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java index 77df9c41b..f16375720 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java @@ -143,7 +143,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWH1000XM4Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sonyswr12.SonySWR12DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.tlw64.TLW64Coordinator; -import nodomain.freeyourgadget.gadgetbridge.devices.um25.Coordinator.BinarySensorCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.binary_sensor.coordinator.BinarySensorCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.um25.Coordinator.UM25Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.vesc.VescCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.vibratissimo.VibratissimoCoordinator; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/dialogs/MaterialDialogFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/dialogs/MaterialDialogFragment.java index 1b0cee5eb..27cfaacae 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/dialogs/MaterialDialogFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/dialogs/MaterialDialogFragment.java @@ -18,7 +18,6 @@ package nodomain.freeyourgadget.gadgetbridge.util.dialogs; import android.app.Dialog; import android.os.Bundle; -import android.view.LayoutInflater; import android.view.View; import androidx.annotation.NonNull; @@ -33,7 +32,7 @@ public class MaterialDialogFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireActivity()); - theDialogView = onCreateView(LayoutInflater.from(requireContext()), null, savedInstanceState); + theDialogView = onCreateView(getLayoutInflater(), null, savedInstanceState); builder.setView(theDialogView); return builder.create(); diff --git a/app/src/main/res/layout-land/activity_notification_filter.xml b/app/src/main/res/layout-land/activity_notification_filter.xml index 44e3e9ee2..6c6a73747 100644 --- a/app/src/main/res/layout-land/activity_notification_filter.xml +++ b/app/src/main/res/layout-land/activity_notification_filter.xml @@ -1,5 +1,5 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_qhybrid_hr_settings.xml b/app/src/main/res/layout/activity_qhybrid_hr_settings.xml index d399c2a8a..3292e68b1 100644 --- a/app/src/main/res/layout/activity_qhybrid_hr_settings.xml +++ b/app/src/main/res/layout/activity_qhybrid_hr_settings.xml @@ -34,7 +34,7 @@ - diff --git a/app/src/main/res/layout/device_itemv2.xml b/app/src/main/res/layout/device_itemv2.xml index 50ec6552a..04839ae9f 100644 --- a/app/src/main/res/layout/device_itemv2.xml +++ b/app/src/main/res/layout/device_itemv2.xml @@ -372,7 +372,7 @@ android:padding="4dp" android:scaleType="fitXY" card_view:srcCompat="@drawable/ic_device_set_reminders" - android:tint="@color/secondarytext" /> + app:tint="@color/secondarytext" /> - - - - - -