From cdcbd1146145fac154d9f0a900937057414e54cd Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Sat, 7 Oct 2023 14:25:51 +0200 Subject: [PATCH] Add android application with onCreate hook --- app/src/main/AndroidManifest.xml | 1 + .../com/github/gotify/GotifyApplication.kt | 31 +++++++++++++++++++ .../gotify/init/InitializationActivity.kt | 19 ------------ 3 files changed, 32 insertions(+), 19 deletions(-) create mode 100644 app/src/main/kotlin/com/github/gotify/GotifyApplication.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6cbd775e..ff4af56d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -12,6 +12,7 @@ = Build.VERSION_CODES.O) { + NotificationSupport.createForegroundChannel( + this, + this.getSystemService(NotificationManager::class.java) + ) + } + + super.onCreate() + } +} diff --git a/app/src/main/kotlin/com/github/gotify/init/InitializationActivity.kt b/app/src/main/kotlin/com/github/gotify/init/InitializationActivity.kt index 547185f6..474c3af9 100644 --- a/app/src/main/kotlin/com/github/gotify/init/InitializationActivity.kt +++ b/app/src/main/kotlin/com/github/gotify/init/InitializationActivity.kt @@ -2,8 +2,6 @@ package com.github.gotify.init import android.Manifest import android.app.AlarmManager -import android.app.NotificationManager -import android.content.Context import android.content.Intent import android.net.Uri import android.os.Build @@ -13,8 +11,6 @@ import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen -import androidx.preference.PreferenceManager -import com.github.gotify.NotificationSupport import com.github.gotify.R import com.github.gotify.Settings import com.github.gotify.api.ApiException @@ -23,12 +19,9 @@ import com.github.gotify.api.Callback.SuccessCallback import com.github.gotify.api.ClientFactory import com.github.gotify.client.model.User import com.github.gotify.client.model.VersionInfo -import com.github.gotify.log.LoggerHelper -import com.github.gotify.log.UncaughtExceptionHandler import com.github.gotify.login.LoginActivity import com.github.gotify.messages.MessagesActivity import com.github.gotify.service.WebSocketService -import com.github.gotify.settings.ThemeHelper import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.livinglifetechway.quickpermissionskotlin.runWithPermissions import com.livinglifetechway.quickpermissionskotlin.util.QuickPermissionsOptions @@ -48,18 +41,6 @@ internal class InitializationActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - LoggerHelper.init(this) - val theme = PreferenceManager.getDefaultSharedPreferences(this) - .getString(getString(R.string.setting_key_theme), getString(R.string.theme_default))!! - ThemeHelper.setTheme(this, theme) - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationSupport.createForegroundChannel( - this, - (this.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager) - ) - } - UncaughtExceptionHandler.registerCurrentThread() settings = Settings(this) Logger.info("Entering ${javaClass.simpleName}")