mirror of
https://github.com/adolfintel/OpenPods.git
synced 2026-09-14 23:06:11 -04:00
Update bg notification, show steps in the allow button
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -2,13 +2,17 @@
|
||||
<resources xmlns:tools="http://schemas.android.com/tools">
|
||||
<string name="app_name" translatable="false">OpenPods</string>
|
||||
|
||||
<string name="bg_noti_channel" translatable="false">Background Notification</string>
|
||||
<string name="bg_noti_title" tools:ignore="MissingTranslation">Running in the background</string>
|
||||
<string name="bg_noti_text" tools:ignore="MissingTranslation">Click to open notification settings</string>
|
||||
|
||||
<string name="intro_title">This app lets you check the status of your AirPods on any Android device</string>
|
||||
<string name="intro_message">To operate, we need permission to use Bluetooth LE (Location) and permission to run in background</string>
|
||||
<string name="intro_allow">Allow</string>
|
||||
<string name="intro_step" translatable="false">Step</string>
|
||||
<string name="intro_bat_perm" translatable="false">Battery Optimization</string>
|
||||
<string name="intro_loc1_perm" translatable="false">Location Permission</string>
|
||||
<string name="intro_loc2_perm" translatable="false">Background Location Permission</string>
|
||||
<string name="intro_step" tools:ignore="MissingTranslation">Step</string>
|
||||
<string name="intro_bat_perm" tools:ignore="MissingTranslation">Battery Optimization</string>
|
||||
<string name="intro_loc1_perm" tools:ignore="MissingTranslation">Location Permission</string>
|
||||
<string name="intro_loc2_perm" tools:ignore="MissingTranslation">Background Location Permission</string>
|
||||
|
||||
<string name="main_description">The app will show a notification when your AirPods are connected</string>
|
||||
<string name="hide_message">You can hide this app if you want</string>
|
||||
@@ -35,7 +39,7 @@
|
||||
|
||||
<string name="about_dev">Developed by Federico Dossena and Itai Levin</string>
|
||||
<string name="website">Website</string>
|
||||
<string name="github" translatable="false">Github</string>
|
||||
<string name="github" tools:ignore="MissingTranslation">Github</string>
|
||||
<string name="donate">Donate</string>
|
||||
<string name="fdroid" translatable="false">F-Droid</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user