Skip to content

Instantly share code, notes, and snippets.

@luca020400
Last active February 12, 2021 14:16
Show Gist options
  • Save luca020400/d3d52ca9b45dbd1cbd31c8299c7a315e to your computer and use it in GitHub Desktop.
Save luca020400/d3d52ca9b45dbd1cbd31c8299c7a315e to your computer and use it in GitHub Desktop.
diff --git a/app/src/main/java/org/lineageos/recorder/DialogActivity.java b/app/src/main/java/org/lineageos/recorder/DialogActivity.java
index e4be5fd..d2af9f0 100644
--- a/app/src/main/java/org/lineageos/recorder/DialogActivity.java
+++ b/app/src/main/java/org/lineageos/recorder/DialogActivity.java
@@ -162,17 +162,19 @@ public class DialogActivity extends AppCompatActivity implements
dialog.setOnDismissListener(d -> finish());
dialog.show();
}
+
private void setupAsSettingsScreen() {
final View view = createContentView(R.layout.dialog_content_settings);
mLocationSwitch = view.findViewById(R.id.dialog_content_settings_location_switch);
- boolean hasLocationPerm = hasLocationPermission();
- setTagWithLocation(hasLocationPerm);
- mLocationSwitch.setChecked(hasLocationPerm);
+ mLocationSwitch.setChecked(getTagWithLocation());
mLocationSwitch.setOnCheckedChangeListener((button, isChecked) -> {
- if (hasLocationPermission()) {
- setTagWithLocation(isChecked);
- } else if (isChecked) {
- askLocationPermission();
+ if (isChecked) {
+ if (hasLocationPermission()) {
+ setTagWithLocation(true);
+ } else {
+ askLocationPermission();
+ }
} else {
setTagWithLocation(false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment