diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 4a0f0b1f2..2c76716ec 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -17,7 +17,7 @@ android {
defaultConfig {
applicationId = "org.fdroid"
minSdk = 24
- targetSdk = 36
+ targetSdk = 37
versionCode = 2000009
versionName = "2.0-alpha9"
diff --git a/app/src/full/AndroidManifest.xml b/app/src/full/AndroidManifest.xml
index a6b88dcc3..e9521c85d 100644
--- a/app/src/full/AndroidManifest.xml
+++ b/app/src/full/AndroidManifest.xml
@@ -36,6 +36,7 @@
+
requestLocalAccessLauncher =
+ registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
+ if (isGranted) sendFDroidBluetooth();
+ });
+
public static void requestSwap(Context context, String repo) {
requestSwap(context, Uri.parse(repo));
}
@@ -1092,18 +1100,25 @@ public class SwapWorkflowActivity extends AppCompatActivity {
wifiSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> {
Context context = getApplicationContext();
- if (isChecked) {
+ boolean granted = SDK_INT < 37 ||
+ ContextCompat.checkSelfPermission(context, ACCESS_LOCAL_NETWORK) == PERMISSION_GRANTED;
+ if (isChecked && !granted) {
+ requestLocalAccessLauncher.launch(ACCESS_LOCAL_NETWORK);
+ Toast.makeText(this, R.string.swap_bluetooth_permissions, Toast.LENGTH_LONG).show();
+ }
+ boolean activate = isChecked && granted;
+ if (activate) {
if (wifiApControl != null && wifiApControl.isEnabled()) {
setupWifiAP();
} else {
- if (Build.VERSION.SDK_INT <= 28) {
+ if (SDK_INT <= 28) {
wifiManager.setWifiEnabled(true);
}
}
BonjourManager.start(context);
}
- BonjourManager.setVisible(context, isChecked);
- SwapService.putWifiVisibleUserPreference(isChecked);
+ BonjourManager.setVisible(context, activate);
+ SwapService.putWifiVisibleUserPreference(activate);
});
scanQrButton.setOnClickListener(v -> inflateSwapView(R.layout.swap_wifi_qr));
@@ -1143,7 +1158,12 @@ public class SwapWorkflowActivity extends AppCompatActivity {
break;
case BonjourManager.STATUS_STARTED:
textWifiVisible.setText(R.string.swap_not_visible_wifi);
- peopleNearbyText.setText(R.string.swap_scanning_for_peers);
+ if (SDK_INT < 37 ||
+ ContextCompat.checkSelfPermission(context, ACCESS_LOCAL_NETWORK) == PERMISSION_GRANTED) {
+ peopleNearbyText.setText(R.string.swap_scanning_for_peers);
+ } else {
+ peopleNearbyText.setText(R.string.swap_bluetooth_permissions);
+ }
peopleNearbyText.setVisibility(View.VISIBLE);
peopleNearbyProgress.setVisibility(View.VISIBLE);
break;
@@ -1152,7 +1172,12 @@ public class SwapWorkflowActivity extends AppCompatActivity {
break;
case BonjourManager.STATUS_NOT_VISIBLE:
textWifiVisible.setText(R.string.swap_not_visible_wifi);
- peopleNearbyText.setText(R.string.swap_scanning_for_peers);
+ if (SDK_INT < 37 ||
+ ContextCompat.checkSelfPermission(context, ACCESS_LOCAL_NETWORK) == PERMISSION_GRANTED) {
+ peopleNearbyText.setText(R.string.swap_scanning_for_peers);
+ } else {
+ peopleNearbyText.setText(R.string.swap_bluetooth_permissions);
+ }
peopleNearbyText.setVisibility(View.VISIBLE);
peopleNearbyProgress.setVisibility(View.VISIBLE);
break;
@@ -1162,7 +1187,12 @@ public class SwapWorkflowActivity extends AppCompatActivity {
} else {
textWifiVisible.setText(R.string.swap_visible_wifi);
}
- peopleNearbyText.setText(R.string.swap_scanning_for_peers);
+ if (SDK_INT < 37 ||
+ ContextCompat.checkSelfPermission(context, ACCESS_LOCAL_NETWORK) == PERMISSION_GRANTED) {
+ peopleNearbyText.setText(R.string.swap_scanning_for_peers);
+ } else {
+ peopleNearbyText.setText(R.string.swap_bluetooth_permissions);
+ }
peopleNearbyText.setVisibility(View.VISIBLE);
peopleNearbyProgress.setVisibility(View.VISIBLE);
break;