mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 09:01:55 +01:00
Cleanup
This commit is contained in:
parent
42784d94eb
commit
c47d5a4113
@ -104,7 +104,6 @@
|
||||
<uses-permission android:name="android.permission.health.READ_STEPS"/>
|
||||
<uses-permission android:name="android.permission.health.WRITE_STEPS"/>
|
||||
<uses-sdk tools:overrideLibrary="androidx.health.connect.client"/>
|
||||
<!-- <uses-sdk tools:overrideLibrary="androidx.health.connect.client" /> <!– Override the library's minSdkVersion –>-->
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.bluetooth"
|
||||
|
@ -327,7 +327,7 @@ public class SettingsActivity extends AbstractSettingsActivityV2 {
|
||||
pref = findPreference(GBPrefs.EXPORT_HEALTH_CONNECT_ENABLED);
|
||||
if (pref != null) {
|
||||
// (I don't know what Kotlin Continuation are used for, but they are needed
|
||||
Continuation<Set<String>> continuationString = new Continuation<Set<String>>() {
|
||||
Continuation<Set<String>> continuationString = new Continuation<Set<String>>() {
|
||||
@NotNull
|
||||
@Override
|
||||
public CoroutineContext getContext() {
|
||||
@ -346,7 +346,7 @@ public class SettingsActivity extends AbstractSettingsActivityV2 {
|
||||
if ((boolean) exportHealthConnectEnabled) {
|
||||
if(!grantedPermissions.containsAll(healthConnectUtils.requiredHealthConnectPermissions)) {
|
||||
// If we weren't enabled at some point already, show Permission screen
|
||||
healthConnectUtils.healthConnectLauncherInit().launch(healthConnectUtils.requiredHealthConnectPermissions);
|
||||
healthConnectUtils.activityResultLauncher.launch(healthConnectUtils.requiredHealthConnectPermissions);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -52,22 +52,26 @@ import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
|
||||
public class HealthConnectUtils {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(HealthConnectUtils.class);
|
||||
private final PreferenceFragmentCompat preferenceFragmentCompat;
|
||||
Class<StepsRecord> stepsRecordJavaClass = StepsRecord.class;
|
||||
Class<HeartRateRecord> heartrateRecordJavaClass = HeartRateRecord.class;
|
||||
KClass<StepsRecord> stepsRecordKClass = JvmClassMappingKt.getKotlinClass(stepsRecordJavaClass);
|
||||
KClass<HeartRateRecord> heartrateRecordKClass = JvmClassMappingKt.getKotlinClass(heartrateRecordJavaClass);
|
||||
public Set<String> requiredHealthConnectPermissions = Set.of(
|
||||
public final ActivityResultLauncher<Set<String>> activityResultLauncher;
|
||||
private final Class<StepsRecord> stepsRecordJavaClass = StepsRecord.class;
|
||||
private final Class<HeartRateRecord> heartrateRecordJavaClass = HeartRateRecord.class;
|
||||
private final KClass<StepsRecord> stepsRecordKClass = JvmClassMappingKt.getKotlinClass(stepsRecordJavaClass);
|
||||
private final KClass<HeartRateRecord> heartrateRecordKClass = JvmClassMappingKt.getKotlinClass(heartrateRecordJavaClass);
|
||||
public final Set<String> requiredHealthConnectPermissions = Set.of(
|
||||
HealthPermission.getReadPermission(stepsRecordKClass),
|
||||
HealthPermission.getWritePermission(stepsRecordKClass),
|
||||
HealthPermission.getReadPermission(heartrateRecordKClass),
|
||||
HealthPermission.getWritePermission(heartrateRecordKClass)
|
||||
);
|
||||
|
||||
|
||||
public ActivityResultContract<Set<String>, Set<String>> requestPermissionResultContract = PermissionController.createRequestPermissionResultContract();
|
||||
|
||||
public HealthConnectUtils(PreferenceFragmentCompat fragmentCompat) {
|
||||
preferenceFragmentCompat = fragmentCompat;
|
||||
activityResultLauncher = preferenceFragmentCompat.registerForActivityResult(
|
||||
requestPermissionResultContract,
|
||||
this::permissionCallback
|
||||
);
|
||||
}
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
@ -89,13 +93,6 @@ public class HealthConnectUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public ActivityResultLauncher<Set<String>> healthConnectLauncherInit() {
|
||||
return preferenceFragmentCompat.registerForActivityResult(
|
||||
requestPermissionResultContract,
|
||||
this::permissionCallback
|
||||
);
|
||||
}
|
||||
|
||||
public HealthConnectClient healthConnectInit(Context context) {
|
||||
// First check if we can even use Health Connect
|
||||
int availabilityStatus = HealthConnectClient.getSdkStatus(context);
|
||||
|
Loading…
Reference in New Issue
Block a user