mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-19 08:29:25 +01:00
Fix issues reported by linter
This commit is contained in:
parent
2d8f312c4b
commit
8e9a7d2471
2
app/proguard-rules.pro
vendored
2
app/proguard-rules.pro
vendored
@ -35,7 +35,7 @@
|
|||||||
-keepattributes JavascriptInterface
|
-keepattributes JavascriptInterface
|
||||||
|
|
||||||
# https://github.com/tony19/logback-android/issues/29
|
# 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
|
# To avoid any stacktrace ambiguity
|
||||||
-keepattributes SourceFile,LineNumberTable
|
-keepattributes SourceFile,LineNumberTable
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.devices;
|
package nodomain.freeyourgadget.gadgetbridge.devices;
|
||||||
|
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.GBApplication.getPrefs;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.bluetooth.BluetoothClass;
|
import android.bluetooth.BluetoothClass;
|
||||||
import android.bluetooth.BluetoothDevice;
|
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.SleepRespiratoryRateSample;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.Spo2Sample;
|
import nodomain.freeyourgadget.gadgetbridge.model.Spo2Sample;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.StressSample;
|
import nodomain.freeyourgadget.gadgetbridge.model.StressSample;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||||
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.GBApplication.getPrefs;
|
|
||||||
|
|
||||||
public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(AbstractDeviceCoordinator.class);
|
private static final Logger LOG = LoggerFactory.getLogger(AbstractDeviceCoordinator.class);
|
||||||
|
|
||||||
@ -110,13 +109,13 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
|||||||
}
|
}
|
||||||
Prefs prefs = getPrefs();
|
Prefs prefs = getPrefs();
|
||||||
|
|
||||||
String lastDevice = prefs.getPreferences().getString("last_device_address","");
|
String lastDevice = prefs.getPreferences().getString("last_device_address", "");
|
||||||
if (gbDevice.getAddress().equals(lastDevice)) {
|
if (gbDevice.getAddress().equals(lastDevice)) {
|
||||||
LOG.debug("#1605 removing last device");
|
LOG.debug("#1605 removing last device");
|
||||||
prefs.getPreferences().edit().remove("last_device_address").apply();
|
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)) {
|
if (gbDevice.getAddress().equals(macAddress)) {
|
||||||
LOG.debug("#1605 removing devel miband");
|
LOG.debug("#1605 removing devel miband");
|
||||||
prefs.getPreferences().edit().remove(MiBandConst.PREF_MIBAND_ADDRESS).apply();
|
prefs.getPreferences().edit().remove(MiBandConst.PREF_MIBAND_ADDRESS).apply();
|
||||||
@ -201,7 +200,13 @@ public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHealthWearable(BluetoothDevice device) {
|
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) {
|
if (bluetoothClass == null) {
|
||||||
LOG.warn("unable to determine bluetooth device class of " + device);
|
LOG.warn("unable to determine bluetooth device class of " + device);
|
||||||
return false;
|
return false;
|
||||||
|
@ -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.app.Activity;
|
||||||
import android.bluetooth.le.ScanFilter;
|
import android.bluetooth.le.ScanFilter;
|
||||||
|
@ -53,7 +53,7 @@ public class AmazfitBand5Coordinator extends HuamiCoordinator {
|
|||||||
if (name != null && name.equalsIgnoreCase(HuamiConst.AMAZFIT_BAND5_NAME)) {
|
if (name != null && name.equalsIgnoreCase(HuamiConst.AMAZFIT_BAND5_NAME)) {
|
||||||
return DeviceType.AMAZFITBAND5;
|
return DeviceType.AMAZFITBAND5;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (SecurityException ex) {
|
||||||
LOG.error("unable to check device support", ex);
|
LOG.error("unable to check device support", ex);
|
||||||
}
|
}
|
||||||
return DeviceType.UNKNOWN;
|
return DeviceType.UNKNOWN;
|
||||||
|
@ -46,7 +46,7 @@ public class AmazfitBand7Coordinator extends Huami2021Coordinator {
|
|||||||
if (name != null && name.startsWith(HuamiConst.AMAZFIT_BAND7_NAME)) {
|
if (name != null && name.startsWith(HuamiConst.AMAZFIT_BAND7_NAME)) {
|
||||||
return DeviceType.AMAZFITBAND7;
|
return DeviceType.AMAZFITBAND7;
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (SecurityException e) {
|
||||||
LOG.error("unable to check device support", e);
|
LOG.error("unable to check device support", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.devices.smaq2oss;
|
package nodomain.freeyourgadget.gadgetbridge.devices.smaq2oss;
|
||||||
|
|
||||||
import android.annotation.TargetApi;
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.le.ScanFilter;
|
import android.bluetooth.le.ScanFilter;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.ParcelUuid;
|
import android.os.ParcelUuid;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
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.ActivitySample;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.smaq2oss.SMAQ2OSSSupport;
|
|
||||||
|
|
||||||
public class SMAQ2OSSCoordinator extends AbstractBLEDeviceCoordinator {
|
public class SMAQ2OSSCoordinator extends AbstractBLEDeviceCoordinator {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(SMAQ2OSSCoordinator.class);
|
private static final Logger LOG = LoggerFactory.getLogger(SMAQ2OSSCoordinator.class);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.smaq2oss;
|
package nodomain.freeyourgadget.gadgetbridge.devices.smaq2oss;
|
||||||
|
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGatt;
|
import android.bluetooth.BluetoothGatt;
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.util;
|
package nodomain.freeyourgadget.gadgetbridge.util;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ContentUris;
|
import android.content.ContentUris;
|
||||||
@ -124,6 +125,7 @@ public class AndroidUtils {
|
|||||||
dynamicColorContext = DynamicColors.wrapContextIfAvailable(context, R.style.GadgetbridgeThemeDynamicLight);
|
dynamicColorContext = DynamicColors.wrapContextIfAvailable(context, R.style.GadgetbridgeThemeDynamicLight);
|
||||||
}
|
}
|
||||||
int[] attrsToResolve = {R.attr.colorOnSurface};
|
int[] attrsToResolve = {R.attr.colorOnSurface};
|
||||||
|
@SuppressLint("ResourceType")
|
||||||
TypedArray ta = dynamicColorContext.obtainStyledAttributes(attrsToResolve);
|
TypedArray ta = dynamicColorContext.obtainStyledAttributes(attrsToResolve);
|
||||||
color = ta.getColor(0, 0);
|
color = ta.getColor(0, 0);
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
@ -149,6 +151,7 @@ public class AndroidUtils {
|
|||||||
dynamicColorContext = DynamicColors.wrapContextIfAvailable(context, R.style.GadgetbridgeThemeDynamicLight);
|
dynamicColorContext = DynamicColors.wrapContextIfAvailable(context, R.style.GadgetbridgeThemeDynamicLight);
|
||||||
}
|
}
|
||||||
int[] attrsToResolve = {R.attr.colorSurface};
|
int[] attrsToResolve = {R.attr.colorSurface};
|
||||||
|
@SuppressLint("ResourceType")
|
||||||
TypedArray ta = dynamicColorContext.obtainStyledAttributes(attrsToResolve);
|
TypedArray ta = dynamicColorContext.obtainStyledAttributes(attrsToResolve);
|
||||||
color = ta.getColor(0, 0);
|
color = ta.getColor(0, 0);
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
|
@ -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.sony.headphones.coordinators.SonyWH1000XM4Coordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.sonyswr12.SonySWR12DeviceCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.sonyswr12.SonySWR12DeviceCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.tlw64.TLW64Coordinator;
|
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.um25.Coordinator.UM25Coordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.vesc.VescCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.vesc.VescCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.vibratissimo.VibratissimoCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.vibratissimo.VibratissimoCoordinator;
|
||||||
|
@ -18,7 +18,6 @@ package nodomain.freeyourgadget.gadgetbridge.util.dialogs;
|
|||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -33,7 +32,7 @@ public class MaterialDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireActivity());
|
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(requireActivity());
|
||||||
theDialogView = onCreateView(LayoutInflater.from(requireContext()), null, savedInstanceState);
|
theDialogView = onCreateView(getLayoutInflater(), null, savedInstanceState);
|
||||||
builder.setView(theDialogView);
|
builder.setView(theDialogView);
|
||||||
|
|
||||||
return builder.create();
|
return builder.create();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -87,10 +87,10 @@
|
|||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
<android.support.constraint.Guideline
|
<androidx.constraintlayout.widget.Guideline
|
||||||
android:id="@+id/guideline"
|
android:id="@+id/guideline"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
app:layout_constraintGuide_percent="0.5" />
|
app:layout_constraintGuide_percent="0.5" />
|
||||||
</androidx.support.constraint.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<Space
|
<android.widget.Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="20dp" />
|
android:layout_height="20dp" />
|
||||||
|
|
||||||
|
@ -372,7 +372,7 @@
|
|||||||
android:padding="4dp"
|
android:padding="4dp"
|
||||||
android:scaleType="fitXY"
|
android:scaleType="fitXY"
|
||||||
card_view:srcCompat="@drawable/ic_device_set_reminders"
|
card_view:srcCompat="@drawable/ic_device_set_reminders"
|
||||||
android:tint="@color/secondarytext" />
|
app:tint="@color/secondarytext" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/device_action_show_activity_graphs"
|
android:id="@+id/device_action_show_activity_graphs"
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
android:layout_height="1.5dp"
|
android:layout_height="1.5dp"
|
||||||
android:background="#000" />
|
android:background="#000" />
|
||||||
|
|
||||||
<Space
|
<android.widget.Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="1dp"
|
android:layout_marginBottom="1dp"
|
||||||
@ -43,7 +43,7 @@
|
|||||||
android:layout_height="1.5dp"
|
android:layout_height="1.5dp"
|
||||||
android:background="#000" />
|
android:background="#000" />
|
||||||
|
|
||||||
<Space
|
<android.widget.Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="5dp"
|
android:layout_marginBottom="5dp"
|
||||||
@ -77,7 +77,7 @@
|
|||||||
android:layout_height="1.5dp"
|
android:layout_height="1.5dp"
|
||||||
android:background="#000" />
|
android:background="#000" />
|
||||||
|
|
||||||
<Space
|
<android.widget.Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
@ -119,7 +119,7 @@
|
|||||||
android:layout_height="1.5dp"
|
android:layout_height="1.5dp"
|
||||||
android:background="#000" />
|
android:background="#000" />
|
||||||
|
|
||||||
<Space
|
<android.widget.Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
@ -175,7 +175,7 @@
|
|||||||
android:layout_height="1.5dp"
|
android:layout_height="1.5dp"
|
||||||
android:background="#000" />
|
android:background="#000" />
|
||||||
|
|
||||||
<Space
|
<android.widget.Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
@ -217,7 +217,7 @@
|
|||||||
android:layout_height="1.5dp"
|
android:layout_height="1.5dp"
|
||||||
android:background="#000" />
|
android:background="#000" />
|
||||||
|
|
||||||
<Space
|
<android.widget.Space
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="15dp"
|
android:layout_marginBottom="15dp"
|
||||||
|
Loading…
Reference in New Issue
Block a user