diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8cb81d31be6badb30819801e661c9a2a1b372d80..6eb46c7219e9d7c2c821cb46ed7869330492165e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -118,6 +118,14 @@
android:name=".install.splitinstall.SplitInstallService"
tools:ignore="ExportedService"
android:exported="true" />
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt b/app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt
index a64f9d2518d485cee4b64480b00793eb0e2fdb1c..651bf3f6b552d65fe87a6fd2ab1f4d285d8200fe 100644
--- a/app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt
+++ b/app/src/main/java/foundation/e/apps/install/splitinstall/SplitInstallBinder.kt
@@ -18,9 +18,23 @@
package foundation.e.apps.install.splitinstall
+import android.Manifest
+import android.app.NotificationChannel
+import android.app.NotificationManager
+import android.app.PendingIntent
+import android.content.BroadcastReceiver
import android.content.Context
+import android.content.Intent
+import android.content.pm.PackageManager
+import android.os.Build
+import androidx.annotation.RequiresApi
+import androidx.core.app.ActivityCompat
+import androidx.core.app.NotificationCompat
+import androidx.core.app.NotificationManagerCompat
import androidx.core.content.pm.PackageInfoCompat
import foundation.e.apps.ISplitInstallService
+import foundation.e.apps.MainActivity
+import foundation.e.apps.R
import foundation.e.apps.data.DownloadManager
import foundation.e.apps.data.application.ApplicationRepository
import foundation.e.apps.data.login.AuthenticatorRepository
@@ -45,12 +59,19 @@ class SplitInstallBinder(
companion object {
const val TAG = "SplitInstallerBinder"
const val AUTH_DATA_ERROR_MESSAGE = "Could not get auth data"
+ const val NOTIFICATION_CHANNEL = "SplitInstallAppLounge"
+ const val NOTIFICATION_ID_KEY = "notification_id_key"
}
override fun installSplitModule(packageName: String, moduleName: String) {
try {
+ coroutineScope.launch {
+ authenticatorRepository.getValidatedAuthData()
+ }
+
if (authenticatorRepository.gplayAuth == null) {
Timber.w(AUTH_DATA_ERROR_MESSAGE)
+ handleError(packageName)
return
}
@@ -59,7 +80,104 @@ class SplitInstallBinder(
}
} catch (exception: GPlayLoginException) {
Timber.w("$AUTH_DATA_ERROR_MESSAGE $exception")
+ handleError(packageName)
+ }
+ }
+
+ private fun handleError(packageName: String) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ return
+ }
+
+ createNotificationChannel(context)
+ showErrorNotification(context, packageName)
+ }
+
+ private fun createNotificationChannel(context: Context) {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ return
+ }
+
+ val descriptionText = context.getString(R.string.notification_channel_desc)
+ val notificationChannel = NotificationChannel(
+ NOTIFICATION_CHANNEL,
+ NOTIFICATION_CHANNEL,
+ NotificationManager.IMPORTANCE_HIGH
+ ).apply {
+ description = descriptionText
+ }
+
+ val notificationManager =
+ context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
+
+ notificationManager.createNotificationChannel(notificationChannel)
+ }
+
+ private fun showErrorNotification(context: Context, packageName: String) {
+ if (ActivityCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS)
+ != PackageManager.PERMISSION_GRANTED
+ ) {
+ return
+ }
+
+ val appInfo = context.packageManager.getPackageInfo(packageName, 0).applicationInfo
+ val appLabel = context.packageManager.getApplicationLabel(appInfo)
+ val callerUid = appInfo.uid
+ val contentText = context.getString(
+ R.string.split_install_warning_text,
+ appLabel
+ )
+
+ val notificationBuilder = NotificationCompat.Builder(context, NOTIFICATION_CHANNEL)
+ .setSmallIcon(R.drawable.app_lounge_notification_icon)
+ .setContentTitle(context.getString(R.string.split_install_warning_title, appLabel))
+ .setContentText(contentText)
+ .setPriority(NotificationCompat.PRIORITY_MAX)
+ .setStyle(NotificationCompat.BigTextStyle().bigText(contentText))
+ .addAction(
+ NotificationCompat.Action.Builder(
+ null,
+ context.getString(R.string.sign_in),
+ buildSignInPendingIntent(callerUid)
+ ).build()
+ )
+ .addAction(
+ NotificationCompat.Action.Builder(
+ null,
+ context.getString(R.string.ignore),
+ buildIgnorePendingIntent(callerUid)
+ ).build()
+ )
+
+ with(NotificationManagerCompat.from(context)) {
+ notify(callerUid, notificationBuilder.build())
+ }
+ }
+
+ private fun buildIgnorePendingIntent(callerUid: Int): PendingIntent {
+ val ignoreIntent = Intent(context, IgnoreReceiver::class.java).apply {
+ putExtra(NOTIFICATION_ID_KEY, callerUid)
+ }
+
+ return PendingIntent.getBroadcast(
+ context,
+ callerUid,
+ ignoreIntent,
+ PendingIntent.FLAG_MUTABLE
+ )
+ }
+
+ private fun buildSignInPendingIntent(callerUid: Int): PendingIntent {
+ val signInIntent = Intent(context, SignInReceiver::class.java).apply {
+ putExtra(NOTIFICATION_ID_KEY, callerUid)
}
+
+ return PendingIntent.getBroadcast(
+ context,
+ callerUid,
+ signInIntent,
+ PendingIntent.FLAG_MUTABLE
+ )
}
fun setService(service: foundation.e.splitinstall.ISplitInstallService) {
@@ -123,4 +241,34 @@ class SplitInstallBinder(
splitInstallSystemService?.installSplitModule(packageName, module)
}
}
+
+ class IgnoreReceiver: BroadcastReceiver() {
+ override fun onReceive(context: Context?, intent: Intent?) {
+ if (context == null || intent == null) {
+ return
+ }
+
+ NotificationManagerCompat.from(context).cancel(
+ intent.getIntExtra(NOTIFICATION_ID_KEY, -1)
+ )
+ }
+ }
+
+ class SignInReceiver: BroadcastReceiver() {
+ override fun onReceive(context: Context?, intent: Intent?) {
+ if (context == null || intent == null) {
+ return
+ }
+
+ NotificationManagerCompat.from(context).cancel(
+ intent.getIntExtra(NOTIFICATION_ID_KEY, -1)
+ )
+
+ val launchAppLoungeIntent = Intent(context, MainActivity::class.java).apply {
+ flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ }
+
+ context.startActivity(launchAppLoungeIntent)
+ }
+ }
}
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 9d41365568be7571ee26aea2b178717e89ff009f..4cb3a2fd6de00cec172ece2e0f2bf82755dcc179 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -170,4 +170,11 @@
Das anonyme Konto, das von Ihnen genutzt wird, ist nicht verfügbar. Bitte erneuern (refresh) Sie die Sitzung, um ein neues anonymes Konto zu erhalten.
SITZUNG ERNEUERN
Bitte etwas Platz auf dem Telefon freimachen, damit die App Lounge ordnungsgemäß funktionieren kann.
+
+
+ Warnung bezüglich %s
+ %s möchte zusätzliche Module installieren. Sie müssen sich erneut bei AppLounge anmelden, um sie installieren zu können.
+ Split-Installationskanal
+ Einloggen
+ Ignorieren
\ No newline at end of file
diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml
index 30717f4dfd184badd611458ac2d4aabe89449e15..dbf849d8ac422fdecdf56eb51c4b5dfcb58c8031 100644
--- a/app/src/main/res/values-es/strings.xml
+++ b/app/src/main/res/values-es/strings.xml
@@ -157,4 +157,9 @@
Libera %1$s en tu teléfono para recibir las últimas actualizaciones.
Por favor, libera algo de espacio en tu teléfono para que App Lounge funcione correctamente.
+ Advertencia sobre %s
+ %s quiere instalar módulos adicionales. Debes iniciar sesión nuevamente en AppLounge para poder instalarlos.
+ Canal de instalación dividida
+ Acceder
+ Ignorar
\ No newline at end of file
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index a0fff91dad577e3e147fe334ce235547a7f6b603..77d6840b6b0410d8f63feff9e2fd229a2ae514b3 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -168,4 +168,9 @@
Libérez %1$s sur votre téléphone afin de bénéficier des dernières mises à jour.
Merci de libérer de l\'espace sur votre téléphone pour qu\'App Lounge puisse fonctionner correctement.
Vérification des mises à jour...
+ Avertissement concernant %s
+ %s souhaite installer des modules supplémentaires. Vous devez vous reconnecter à AppLounge pour pouvoir les installer.
+ Canal d\'installation fractionnée
+ Connexion
+ Ignorer
\ No newline at end of file
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 21908d07f4ad9c8a601f311f4c1190644d774b87..98f2a681fb44a530345b4bd74dd870424b964582 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -168,4 +168,9 @@
Per scaricare l\'aggiornamento, devi liberare %1$s di spazio sullo smartphone.
Ti invitiamo a liberare un pò di spazio sul telefono in modo che App Lounge possa funzionare correttamente.
+ Avviso riguardante %s
+ %s vuole installare moduli aggiuntivi. Devi accedere nuovamente ad AppLounge per poterli installare.
+ Canale di installazione frazionata
+ Login
+ Ignorare
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3b2fd32fa11dc16e4192ba675cb597343560f15d..e85a99fae4f806419b927be304ef15130fcd2511 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -241,4 +241,11 @@
Free up %1$s on your phone to get the latest updates.
Please free up some space on your phone so App Lounge can work properly.
+
+
+ Warning regarding %s
+ %s wants to install extra modules. You must sign in again to AppLounge to be able to install them.
+ Split Install channel
+ Sign in
+ Ignore