@@ -133,6 +133,8 @@ import com.lagradost.cloudstream3.utils.AppContextUtils.loadResult
133133import com.lagradost.cloudstream3.utils.AppContextUtils.loadSearchResult
134134import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus
135135import com.lagradost.cloudstream3.utils.AppContextUtils.updateHasTrailers
136+ import com.lagradost.cloudstream3.utils.BackPressedCallbackHelper.attachBackPressedCallback
137+ import com.lagradost.cloudstream3.utils.BackPressedCallbackHelper.detachBackPressedCallback
136138import com.lagradost.cloudstream3.utils.BackupUtils.backup
137139import com.lagradost.cloudstream3.utils.BackupUtils.setUpBackup
138140import com.lagradost.cloudstream3.utils.BiometricAuthenticator.BiometricCallback
@@ -151,6 +153,7 @@ import com.lagradost.cloudstream3.utils.DataStoreHelper.migrateResumeWatching
151153import com.lagradost.cloudstream3.utils.Event
152154import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
153155import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
156+ import com.lagradost.cloudstream3.utils.SnackbarHelper.showSnackbar
154157import com.lagradost.cloudstream3.utils.UIHelper.changeStatusBarState
155158import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
156159import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
@@ -1254,17 +1257,12 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
12541257 this .setKey(getString(R .string.jsdelivr_proxy_key), false )
12551258 } else {
12561259 this .setKey(getString(R .string.jsdelivr_proxy_key), true )
1257- val parentView: View = findViewById(android.R .id.content)
1258- Snackbar .make(parentView, R .string.jsdelivr_enabled, Snackbar .LENGTH_LONG )
1259- .let { snackbar ->
1260- snackbar.setAction(R .string.revert) {
1261- setKey(getString(R .string.jsdelivr_proxy_key), false )
1262- }
1263- snackbar.setBackgroundTint(colorFromAttribute(R .attr.primaryGrayBackground))
1264- snackbar.setTextColor(colorFromAttribute(R .attr.textColor))
1265- snackbar.setActionTextColor(colorFromAttribute(R .attr.colorPrimary))
1266- snackbar.show()
1267- }
1260+ showSnackbar(
1261+ this @MainActivity,
1262+ R .string.jsdelivr_enabled,
1263+ Snackbar .LENGTH_LONG ,
1264+ R .string.revert
1265+ ) { setKey(getString(R .string.jsdelivr_proxy_key), false ) }
12681266 }
12691267 }
12701268 }
@@ -1603,7 +1601,12 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
16031601
16041602 if (isLayout(TV or EMULATOR )) {
16051603 if (navDestination.matchDestination(R .id.navigation_home)) {
1606- attachBackPressedCallback()
1604+ attachBackPressedCallback {
1605+ showConfirmExitDialog()
1606+ window?.navigationBarColor =
1607+ colorFromAttribute(R .attr.primaryGrayBackground)
1608+ updateLocale()
1609+ }
16071610 } else detachBackPressedCallback()
16081611 }
16091612 }
@@ -1848,28 +1851,6 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
18481851 finish()
18491852 }
18501853
1851- private var backPressedCallback: OnBackPressedCallback ? = null
1852-
1853- private fun attachBackPressedCallback () {
1854- if (backPressedCallback == null ) {
1855- backPressedCallback = object : OnBackPressedCallback (true ) {
1856- override fun handleOnBackPressed () {
1857- showConfirmExitDialog()
1858- window?.navigationBarColor =
1859- colorFromAttribute(R .attr.primaryGrayBackground)
1860- updateLocale()
1861- }
1862- }
1863- }
1864-
1865- backPressedCallback?.isEnabled = true
1866- onBackPressedDispatcher.addCallback(this , backPressedCallback ? : return )
1867- }
1868-
1869- private fun detachBackPressedCallback () {
1870- backPressedCallback?.isEnabled = false
1871- }
1872-
18731854 suspend fun checkGithubConnectivity (): Boolean {
18741855 return try {
18751856 app.get(
@@ -1880,4 +1861,4 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
18801861 false
18811862 }
18821863 }
1883- }
1864+ }
0 commit comments