From b4a913b2d5d160f917489dc45e098e96b7f0922e Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Wed, 13 Apr 2022 19:22:01 +0200 Subject: [PATCH] fix black theme on Android 12 (#2424) * fix black theme on Android 12 * Revert "fix black theme on Android 12" This reverts commit 2286706fdb239e15be72ac8943405ffeb2258219. * bring back SplashActivity --- app/src/main/AndroidManifest.xml | 25 +++++---- .../com/keylesspalace/tusky/MainActivity.kt | 5 -- .../com/keylesspalace/tusky/SplashActivity.kt | 51 +++++++++++++++++++ .../components/preference/EmojiPreference.kt | 4 +- .../tusky/di/ActivitiesModule.kt | 4 ++ 5 files changed, 73 insertions(+), 16 deletions(-) create mode 100644 app/src/main/java/com/keylesspalace/tusky/SplashActivity.kt diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 858f8a37..3b0a977e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -21,6 +21,22 @@ android:theme="@style/TuskyTheme" android:usesCleartextTraffic="false"> + + + + + + + + + + + @@ -29,13 +45,7 @@ - - - - - @@ -83,9 +93,6 @@ - . */ + +package com.keylesspalace.tusky + +import android.annotation.SuppressLint +import android.content.Intent +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import com.keylesspalace.tusky.components.login.LoginActivity +import com.keylesspalace.tusky.components.notifications.NotificationHelper +import com.keylesspalace.tusky.db.AccountManager +import com.keylesspalace.tusky.di.Injectable +import javax.inject.Inject + +@SuppressLint("CustomSplashScreen") +class SplashActivity : AppCompatActivity(), Injectable { + + @Inject + lateinit var accountManager: AccountManager + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + /** delete old notification channels */ + NotificationHelper.deleteLegacyNotificationChannels(this, accountManager) + + /** Determine whether the user is currently logged in, and if so go ahead and load the + * timeline. Otherwise, start the activity_login screen. */ + + val intent = if (accountManager.activeAccount != null) { + Intent(this, MainActivity::class.java) + } else { + LoginActivity.getIntent(this, false) + } + startActivity(intent) + finish() + } +} diff --git a/app/src/main/java/com/keylesspalace/tusky/components/preference/EmojiPreference.kt b/app/src/main/java/com/keylesspalace/tusky/components/preference/EmojiPreference.kt index 2c565a71..47cb37ae 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/preference/EmojiPreference.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/preference/EmojiPreference.kt @@ -13,8 +13,8 @@ import android.widget.Toast import androidx.appcompat.app.AlertDialog import androidx.preference.Preference import androidx.preference.PreferenceManager -import com.keylesspalace.tusky.MainActivity import com.keylesspalace.tusky.R +import com.keylesspalace.tusky.SplashActivity import com.keylesspalace.tusky.components.notifications.NotificationHelper import com.keylesspalace.tusky.databinding.DialogEmojicompatBinding import com.keylesspalace.tusky.databinding.ItemEmojiPrefBinding @@ -216,7 +216,7 @@ class EmojiPreference( .setPositiveButton(R.string.restart) { _, _ -> // Restart the app // From https://stackoverflow.com/a/17166729/5070653 - val launchIntent = Intent(context, MainActivity::class.java) + val launchIntent = Intent(context, SplashActivity::class.java) val mPendingIntent = PendingIntent.getActivity( context, 0x1f973, // This is the codepoint of the party face emoji :D diff --git a/app/src/main/java/com/keylesspalace/tusky/di/ActivitiesModule.kt b/app/src/main/java/com/keylesspalace/tusky/di/ActivitiesModule.kt index b74bac79..d85f6c45 100644 --- a/app/src/main/java/com/keylesspalace/tusky/di/ActivitiesModule.kt +++ b/app/src/main/java/com/keylesspalace/tusky/di/ActivitiesModule.kt @@ -23,6 +23,7 @@ import com.keylesspalace.tusky.FiltersActivity import com.keylesspalace.tusky.LicenseActivity import com.keylesspalace.tusky.ListsActivity import com.keylesspalace.tusky.MainActivity +import com.keylesspalace.tusky.SplashActivity import com.keylesspalace.tusky.StatusListActivity import com.keylesspalace.tusky.TabPreferenceActivity import com.keylesspalace.tusky.ViewMediaActivity @@ -116,4 +117,7 @@ abstract class ActivitiesModule { @ContributesAndroidInjector abstract fun contributesDraftActivity(): DraftsActivity + + @ContributesAndroidInjector + abstract fun contributesSplashActivity(): SplashActivity }