Browse Source

fix activity restart when emoji pack changed (#5057)

When the emoji pack changes and `MainActivity` is recreated status bar
and navigation bar turn dark in edge-to-edge mode (Android 15), we would
need [the same workaround as
here](068d884aef/app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt (L71-L75))
in `MainActivity` as well.

But why not handle the restart in `AccountActivity` as we do for all
other preferences that require it.
pull/5064/head
Konrad Pozniak 11 months ago committed by GitHub
parent
commit
8ad5609aef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 20
      app/src/main/java/com/keylesspalace/tusky/MainActivity.kt
  2. 3
      app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt

20
app/src/main/java/com/keylesspalace/tusky/MainActivity.kt

@ -126,7 +126,6 @@ import com.mikepenz.materialdrawer.util.updateBadge
import com.mikepenz.materialdrawer.widget.AccountHeaderView
import dagger.hilt.android.AndroidEntryPoint
import dagger.hilt.android.migration.OptionalInject
import de.c1710.filemojicompat_ui.helpers.EMOJI_PREFERENCE
import javax.inject.Inject
import kotlinx.coroutines.launch
@ -162,9 +161,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
private var onTabSelectedListener: OnTabSelectedListener? = null
// We need to know if the emoji pack has been changed
private var selectedEmojiPack: String? = null
/** Mediate between binding.viewPager and the chosen tab layout */
private var tabLayoutMediator: TabLayoutMediator? = null
@ -215,8 +211,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
viewModel.setupNotifications(this)
}
selectedEmojiPack = preferences.getString(EMOJI_PREFERENCE, "")
var showNotificationTab = false
// check for savedInstanceState in order to not handle intent events more than once
@ -478,20 +472,6 @@ class MainActivity : BottomSheetActivity(), ActionButtonActivity, MenuProvider {
}
}
override fun onResume() {
super.onResume()
val currentEmojiPack = preferences.getString(EMOJI_PREFERENCE, "")
if (currentEmojiPack != selectedEmojiPack) {
Log.d(
TAG,
"onResume: EmojiPack has been changed from %s to %s"
.format(selectedEmojiPack, currentEmojiPack)
)
selectedEmojiPack = currentEmojiPack
recreate()
}
}
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
// Allow software back press to be properly dispatched to drawer layout
val handled = when (event.action) {

3
app/src/main/java/com/keylesspalace/tusky/components/preference/PreferencesActivity.kt

@ -41,6 +41,7 @@ import com.keylesspalace.tusky.util.getNonNullString
import com.keylesspalace.tusky.util.setAppNightMode
import com.keylesspalace.tusky.util.startActivityWithSlideInAnimation
import dagger.hilt.android.AndroidEntryPoint
import de.c1710.filemojicompat_ui.helpers.EMOJI_PREFERENCE
import javax.inject.Inject
import kotlinx.coroutines.launch
@ -159,7 +160,7 @@ class PreferencesActivity :
}
PrefKeys.STATUS_TEXT_SIZE, PrefKeys.ABSOLUTE_TIME_VIEW, PrefKeys.SHOW_BOT_OVERLAY, PrefKeys.ANIMATE_GIF_AVATARS, PrefKeys.USE_BLURHASH,
PrefKeys.SHOW_SELF_USERNAME, PrefKeys.SHOW_CARDS_IN_TIMELINES, PrefKeys.CONFIRM_REBLOGS, PrefKeys.CONFIRM_FAVOURITES,
PrefKeys.ENABLE_SWIPE_FOR_TABS, PrefKeys.MAIN_NAV_POSITION, PrefKeys.HIDE_TOP_TOOLBAR, PrefKeys.SHOW_STATS_INLINE -> {
EMOJI_PREFERENCE, PrefKeys.ENABLE_SWIPE_FOR_TABS, PrefKeys.MAIN_NAV_POSITION, PrefKeys.HIDE_TOP_TOOLBAR, PrefKeys.SHOW_STATS_INLINE -> {
restartActivitiesOnBackPressedCallback.isEnabled = true
}
}

Loading…
Cancel
Save