Skip to content

Debloat any Android or Google TV over Wi-Fi and get an Apple TV-style home.

fix(prayer-times): isolate alert task, eliminate duplicate sound, and fix notif id

9E55b787.8a698ca96750
diff --git a/addons/prayer-times/README.md b/addons/prayer-times/README.md
index 4683da236..f98647721 100644
--- a/addons/prayer-times/README.md
+++ b/addons/prayer-times/README.md
@@ -15,8 +15,8 @@ countdown to it, plus today's Gregorian and Hijri dates. Each prayer has its Ara
- **Reminders switch**: In `app/src/main/res/values/config.xml`, `reminders` controls whether to schedule
on-screen alert cards and notifications when a prayer time arrives. It is `false` (off) by default. When
enabled (`true`), an unobtrusive, frameless compact card appears at the top-right corner of the screen
- displaying the localized prayer name, Arabic script, time, and city. It dismisses automatically after 10
- seconds or immediately on any remote button press.
+ displaying the localized prayer name, Arabic script, time, and city, accompanied by a single notification chime.
+ It dismisses automatically after 10 seconds or immediately on any remote button press.
- It reads Aladhan when the page opens and again after midnight. The countdown updates every minute.
Offline, the last times stay on screen.
- 24-hour times, localized prayer names and strings for English, Indonesian (`values-in`), and Arabic (`values-ar`).
@@ -44,6 +44,14 @@ TV_HOST=<tv ip> ../../tools/venv/bin/python -I ../../tools/tv.py --push app/buil
TV_HOST=<tv ip> ../../tools/venv/bin/python -I ../../tools/tv.py 'pm install -r /data/local/tmp/addon.apk; rm -f /data/local/tmp/addon.apk'
```
+If `reminders` is set to `true`, grant the overlay permission so the on-screen alert card can display over playing video and other apps:
+
+```bash
+TV_HOST=<tv ip> ../../tools/venv/bin/python -I ../../tools/tv.py 'appops set com.majnioui.tv.prayer SYSTEM_ALERT_WINDOW allow'
+```
+
+> **Note:** Force-stopping the app (`am force-stop com.majnioui.tv.prayer`) removes all pending alarms scheduled in Android's `AlarmManager`. When testing real alarms, do not force-stop the app.
+
Press Home: the launcher asks once whether to show the card. Change the answer later by holding OK on
Settings, then Module cards.
diff --git a/addons/prayer-times/app/src/main/AndroidManifest.xml b/addons/prayer-times/app/src/main/AndroidManifest.xml
index 38fd81359..595d7b630 100644
--- a/addons/prayer-times/app/src/main/AndroidManifest.xml
+++ b/addons/prayer-times/app/src/main/AndroidManifest.xml
@@ -37,7 +37,10 @@
android:name=".PrayerAlertActivity"
android:exported="true"
android:theme="@android:style/Theme.Material.Dialog.NoActionBar"
- android:launchMode="singleTop" />
+ android:launchMode="singleTop"
+ android:taskAffinity=""
+ android:excludeFromRecents="true"
+ android:noHistory="true" />
<receiver android:name=".PrayerReceiver" android:exported="true" />
diff --git a/addons/prayer-times/app/src/main/java/com/majnioui/tv/prayer/PrayerReceiver.java b/addons/prayer-times/app/src/main/java/com/majnioui/tv/prayer/PrayerReceiver.java
index 27353184c..8aeccf21e 100644
--- a/addons/prayer-times/app/src/main/java/com/majnioui/tv/prayer/PrayerReceiver.java
+++ b/addons/prayer-times/app/src/main/java/com/majnioui/tv/prayer/PrayerReceiver.java
@@ -9,7 +9,6 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.media.AudioAttributes;
-import android.media.Ringtone;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Build;
@@ -18,6 +17,7 @@ import android.util.Log;
public class PrayerReceiver extends BroadcastReceiver {
private static final String TAG = "PrayerReceiver";
private static final String CHANNEL_ID = "prayer_reminder";
+ private static final int NOTIFICATION_ID = 1001;
@Override
public void onReceive(Context context, Intent intent) {
@@ -46,7 +46,7 @@ public class PrayerReceiver extends BroadcastReceiver {
int idx = PrayerScheduler.getPrayerIndex(name);
String localizedName = idx >= 0 ? context.getString(PrayerScheduler.NAME_RES[idx]) : name;
- // 1. Post High-Priority Notification (triggers Heads-Up banner on Android TV)
+ // 1. Post High-Priority Notification (handles sound and tray indicator with fixed ID)
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
if (nm != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
@@ -69,15 +69,12 @@ public class PrayerReceiver extends BroadcastReceiver {
nm.createNotificationChannel(ch);
}
- Intent alertIntent = new Intent(context, PrayerAlertActivity.class);
- alertIntent.putExtra(PrayerScheduler.EXTRA_PRAYER_NAME, name);
- alertIntent.putExtra(PrayerScheduler.EXTRA_PRAYER_TIME, time);
- alertIntent.putExtra(PrayerScheduler.EXTRA_PLACE, place);
- alertIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- PendingIntent alertPi = PendingIntent.getActivity(
+ Intent mainIntent = new Intent(context, MainActivity.class);
+ mainIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ PendingIntent contentPi = PendingIntent.getActivity(
context,
- (int) System.currentTimeMillis(),
- alertIntent,
+ 0,
+ mainIntent,
PendingIntent.FLAG_UPDATE_CURRENT | (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_IMMUTABLE : 0)
);
@@ -95,26 +92,15 @@ public class PrayerReceiver extends BroadcastReceiver {
.setContentText(body)
.setSmallIcon(R.drawable.icon)
.setAutoCancel(true)
- .setContentIntent(alertPi)
- .setFullScreenIntent(alertPi, true)
+ .setContentIntent(contentPi)
.setPriority(Notification.PRIORITY_MAX)
.setCategory(Notification.CATEGORY_ALARM)
.setColor(Color.parseColor("#2BB673"));
- int notifId = (int) System.currentTimeMillis();
- nm.notify(notifId, nb.build());
+ nm.notify(NOTIFICATION_ID, nb.build());
}
- // 2. Play audible notification sound
- try {
- Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
- Ringtone r = RingtoneManager.getRingtone(context.getApplicationContext(), ringtoneUri);
- if (r != null) r.play();
- } catch (Exception e) {
- Log.w(TAG, "Play sound error: " + e);
- }
-
- // 3. Launch floating alert banner on screen
+ // 2. Launch floating alert banner on screen (single launch path)
try {
Intent popup = new Intent(context, PrayerAlertActivity.class);
popup.putExtra(PrayerScheduler.EXTRA_PRAYER_NAME, name);
@@ -126,7 +112,7 @@ public class PrayerReceiver extends BroadcastReceiver {
Log.w(TAG, "Launch alert activity error: " + e);
}
- // 5. Schedule next prayer
+ // 3. Schedule next prayer
PrayerScheduler.scheduleNext(context);
}
}