diff --git a/OpenPods/app/src/main/java/com/dosse/airpods/IntroActivity.java b/OpenPods/app/src/main/java/com/dosse/airpods/IntroActivity.java index 871dde8..04a10d2 100644 --- a/OpenPods/app/src/main/java/com/dosse/airpods/IntroActivity.java +++ b/OpenPods/app/src/main/java/com/dosse/airpods/IntroActivity.java @@ -75,7 +75,7 @@ public class IntroActivity extends AppCompatActivity { switch (step) { case 1: - msg.setText(String.format(Locale.getDefault(), "Step %d/%d: %s", step, numOfSteps, getString(R.string.intro_bat_perm))); + msg.setText(String.format(Locale.getDefault(), "%s %d/%d: %s", getString(R.string.intro_step), step, numOfSteps, getString(R.string.intro_bat_perm))); btn.setOnClickListener(view -> { Intent intent = new Intent(); getSystemService(Context.POWER_SERVICE); @@ -85,16 +85,18 @@ public class IntroActivity extends AppCompatActivity { }); break; case 2: - msg.setText(String.format(Locale.getDefault(), "Step %d/%d: %s", step, numOfSteps, getString(R.string.intro_loc1_perm))); + msg.setText(String.format(Locale.getDefault(), "%s %d/%d: %s", getString(R.string.intro_step), step, numOfSteps, getString(R.string.intro_loc1_perm))); btn.setOnClickListener(view -> requestPermissions(new String[] {Manifest.permission.ACCESS_FINE_LOCATION}, 101)); // Location (for BLE) break; case 3: - msg.setText(String.format(Locale.getDefault(), "Step %d/%d: %s", step, numOfSteps, getString(R.string.intro_loc2_perm))); + msg.setText(String.format(Locale.getDefault(), "%s %d/%d: %s", getString(R.string.intro_step), step, numOfSteps, getString(R.string.intro_loc2_perm))); btn.setOnClickListener(view -> { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) requestPermissions(new String[] {Manifest.permission.ACCESS_BACKGROUND_LOCATION}, 102); }); break; } + + runOnUiThread(() -> btn.setText(String.format(Locale.getDefault(), "%s (%d/%d)", getString(R.string.intro_allow), step, numOfSteps))); } } diff --git a/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java b/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java index e1329d6..8e4a7a7 100644 --- a/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java +++ b/OpenPods/app/src/main/java/com/dosse/airpods/PodsService.java @@ -420,7 +420,7 @@ public class PodsService extends Service { super.onCreate(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) - startForeground(101, createNotification()); + startForeground(101, createBackgroundNotification()); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction("android.bluetooth.device.action.ACL_CONNECTED"); @@ -587,13 +587,14 @@ public class PodsService extends Service { return START_STICKY; } - // Only for API30+ + // Foreground service background notification (confusing I know). + // Only enabled for API30+ @RequiresApi(api = Build.VERSION_CODES.O) - private Notification createNotification () { + private Notification createBackgroundNotification () { final String notChannelID = "FOREGROUND_ID"; NotificationManager notManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); - NotificationChannel notChannel = new NotificationChannel(notChannelID, "Background Notification", NotificationManager.IMPORTANCE_MIN); + NotificationChannel notChannel = new NotificationChannel(notChannelID, getString(R.string.bg_noti_channel), NotificationManager.IMPORTANCE_LOW); notManager.createNotificationChannel(notChannel); @@ -602,12 +603,12 @@ public class PodsService extends Service { .putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName()) .putExtra(Settings.EXTRA_CHANNEL_ID, notChannelID); - PendingIntent notPendingIntent = PendingIntent.getActivity(this, 1110, notIntent,0); + PendingIntent notPendingIntent = PendingIntent.getActivity(this, 1110, notIntent, 0); Notification.Builder builder = new Notification.Builder(this, notChannelID) .setSmallIcon(R.drawable.pod_case) - .setContentTitle("Running in the background") - .setContentText("Click to open notification Settings") + .setContentTitle(getString(R.string.bg_noti_title)) + .setContentText(getString(R.string.bg_noti_text)) .setContentIntent(notPendingIntent) .setOngoing(true); diff --git a/OpenPods/app/src/main/res/values/strings.xml b/OpenPods/app/src/main/res/values/strings.xml index 9ada3a3..11ef0b7 100644 --- a/OpenPods/app/src/main/res/values/strings.xml +++ b/OpenPods/app/src/main/res/values/strings.xml @@ -2,13 +2,17 @@ OpenPods + Background Notification + Running in the background + Click to open notification settings + This app lets you check the status of your AirPods on any Android device To operate, we need permission to use Bluetooth LE (Location) and permission to run in background Allow - Step - Battery Optimization - Location Permission - Background Location Permission + Step + Battery Optimization + Location Permission + Background Location Permission The app will show a notification when your AirPods are connected You can hide this app if you want @@ -35,7 +39,7 @@ Developed by Federico Dossena and Itai Levin Website - Github + Github Donate F-Droid