Report missing publisher system services and use current app language

This commit is contained in:
evgeny committed 2026-10-29 13:34:24 +01:00
1 parent 9166268102
commit f1ffd21cda
3 files changed
+11 -6

No files matched your search

@@ -78,20 +78,21 @@ class StreamService : Service() {
id = intent?.getLongExtra("id", 0) ?: 0
val audio = intent?.getBooleanExtra("audio", true) ?: true
try {
val notifications = getSystemService(NotificationManager::class.java)
notifications.createNotificationChannel(NotificationChannel("live_stream", getString(R.string.stream_title), NotificationManager.IMPORTANCE_LOW))
val notifications = checkNotNull(getSystemService(NotificationManager::class.java)) { "NotificationManager unavailable" }
notifications.createNotificationChannel(NotificationChannel("live_stream", AppLanguage.text(R.string.stream_title), NotificationManager.IMPORTANCE_LOW))
val open = PendingIntent.getActivity(this, 0, Intent(this, MainActivity::class.java).setData(Uri.parse("utun-stream:open:$id")),
PendingIntent.FLAG_IMMUTABLE).also { openIntent = it }
val stop = PendingIntent.getService(this, 0, Intent(this, StreamService::class.java).setAction("stop")
.setData(Uri.parse("utun-stream:stop:$id")).putExtra("id", id), PendingIntent.FLAG_IMMUTABLE).also { stopIntent = it }
val notification = NotificationCompat.Builder(this, "live_stream").setSmallIcon(android.R.drawable.ic_menu_camera)
.setContentTitle(getString(R.string.stream_live)).setContentIntent(open).setOngoing(true)
.addAction(android.R.drawable.ic_media_pause, getString(R.string.stream_stop), stop).build()
.setContentTitle(AppLanguage.text(R.string.stream_live)).setContentIntent(open).setOngoing(true)
.addAction(android.R.drawable.ic_media_pause, AppLanguage.text(R.string.stream_stop), stop).build()
val type = if (Build.VERSION.SDK_INT >= 30) ServiceInfo.FOREGROUND_SERVICE_TYPE_CAMERA or
(if (audio) ServiceInfo.FOREGROUND_SERVICE_TYPE_MICROPHONE else 0) else 0
foregroundOwned = true; ServiceCompat.startForeground(this, 1004, notification, type)
if (id == 0L || !StreamController.serviceReady(id, this)) { finish(); return START_NOT_STICKY }
lock = getSystemService(PowerManager::class.java).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "utun:live_stream")
lock = checkNotNull(getSystemService(PowerManager::class.java)) { "PowerManager unavailable" }
.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "utun:live_stream")
lock!!.setReferenceCounted(false); lock!!.acquire()
val group = intent!!.getLongExtra("group", 0)
val publisher = StreamController.state.value ?: error("Missing publisher")
@@ -9,4 +9,7 @@ object Manifest {
}
}
object R { object drawable { const val ic_dialog_info = 1; const val ic_btn_speak_now = 2; const val ic_menu_call = 3 } }
object R { object drawable {
const val ic_dialog_info = 1; const val ic_btn_speak_now = 2; const val ic_menu_call = 3
const val ic_menu_camera = 4; const val ic_media_pause = 5
} }
@@ -6,6 +6,7 @@ import android.content.Context
class Toast private constructor(val text: String) {
companion object {
const val LENGTH_LONG = 1
const val LENGTH_SHORT = 0
val shown = mutableListOf<String>()
fun makeText(context: Context, text: String, duration: Int) = Toast(text)
fun makeText(context: Context, resource: Int, duration: Int) = Toast("resource:$resource")