Skip to content

Commit

Permalink
Remove predictive back support
Browse files Browse the repository at this point in the history
Reland after #1322 resolved
  • Loading branch information
FooIbar committed Aug 11, 2023
1 parent 2c2fbb3 commit acef542
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
android:allowBackup="true"
android:appCategory="image"
android:dataExtractionRules="@xml/data_extraction_rules"
android:enableOnBackInvokedCallback="true"
android:fullBackupContent="@xml/backup_scheme"
android:hasFragileUserData="true"
android:icon="@mipmap/ic_launcher"
Expand Down
12 changes: 3 additions & 9 deletions app/src/main/java/com/hippo/ehviewer/ui/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,7 @@ class MainActivity : EhActivity() {
supportFragmentManager.findFragmentById(R.id.fragment_container) as NavHostFragment
navController = navHostFragment.navController
if (!EhUtils.needSignedIn()) setNavGraph()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
binding.drawView.addDrawerListener(
mDrawerOnBackPressedCallback,
)
}
binding.drawView.addDrawerListener(mDrawerOnBackPressedCallback)
binding.navView.setupWithNavController(navController)

// Trick: Tweak NavigationUI to disable multiple backstack
Expand Down Expand Up @@ -323,10 +319,8 @@ class MainActivity : EhActivity() {
super.onResume()
lifecycleScope.launch {
delay(300)
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
mDrawerOnBackPressedCallback.remove()
onBackPressedDispatcher.addCallback(mDrawerOnBackPressedCallback)
}
mDrawerOnBackPressedCallback.remove()
onBackPressedDispatcher.addCallback(mDrawerOnBackPressedCallback)
checkClipboardUrl()
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.hippo.ehviewer.ui.scene

import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
Expand Down Expand Up @@ -103,10 +102,8 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {
onCreateViewWithToolbar(inflater, binding.root, savedInstanceState)
// This has to be placed after onCreateViewWithToolbar() since
// callbacks are invoked in the reverse order in which they are added
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
binding.searchview.addTransitionListener(mSearchViewOnBackPressedCallback)
requireActivity().onBackPressedDispatcher.addCallback(mSearchViewOnBackPressedCallback)
}
binding.searchview.addTransitionListener(mSearchViewOnBackPressedCallback)
requireActivity().onBackPressedDispatcher.addCallback(mSearchViewOnBackPressedCallback)
binding.appbar.bringToFront()
return binding.root
}
Expand All @@ -125,7 +122,7 @@ abstract class SearchBarScene : BaseScene(), ToolBarScene {

override fun onDestroyView() {
super.onDestroyView()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) mSearchViewOnBackPressedCallback.remove()
mSearchViewOnBackPressedCallback.remove()
_binding = null
}

Expand Down

0 comments on commit acef542

Please sign in to comment.