mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 19:32:16 +00:00
Remove: Fragment-related components of PrefsActivityX
This commit is contained in:
parent
7bc334c182
commit
e64c3585ac
@ -35,7 +35,6 @@ import com.machiav3lli.fdroid.utility.isDarkTheme
|
|||||||
import com.machiav3lli.fdroid.utility.setCustomTheme
|
import com.machiav3lli.fdroid.utility.setCustomTheme
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
// TODO clean up the bloat
|
|
||||||
class PrefsActivityX : AppCompatActivity() {
|
class PrefsActivityX : AppCompatActivity() {
|
||||||
companion object {
|
companion object {
|
||||||
const val ACTION_UPDATES = "${BuildConfig.APPLICATION_ID}.intent.action.UPDATES"
|
const val ACTION_UPDATES = "${BuildConfig.APPLICATION_ID}.intent.action.UPDATES"
|
||||||
@ -49,33 +48,17 @@ class PrefsActivityX : AppCompatActivity() {
|
|||||||
class Install(val packageName: String?, val cacheFileName: String?) : SpecialIntent()
|
class Install(val packageName: String?, val cacheFileName: String?) : SpecialIntent()
|
||||||
}
|
}
|
||||||
|
|
||||||
lateinit var binding: ActivityPrefsXBinding
|
|
||||||
lateinit var toolbar: MaterialToolbar
|
|
||||||
lateinit var appBarConfiguration: AppBarConfiguration
|
|
||||||
private lateinit var navController: NavController
|
private lateinit var navController: NavController
|
||||||
|
val syncConnection = Connection(SyncService::class.java)
|
||||||
private val syncConnection = Connection(SyncService::class.java, onBind = { _, _ ->
|
|
||||||
navController.currentDestination?.let {
|
|
||||||
val source = Source.values()[when (it.id) {
|
|
||||||
R.id.updateTab -> 1
|
|
||||||
R.id.otherTab -> 2
|
|
||||||
else -> 0 // R.id.userTab
|
|
||||||
}]
|
|
||||||
updateUpdateNotificationBlocker(source)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
val db
|
val db
|
||||||
get() = (application as MainApplication).db
|
get() = (application as MainApplication).db
|
||||||
|
|
||||||
|
@OptIn(ExperimentalAnimationApi::class, ExperimentalMaterial3Api::class)
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
setCustomTheme()
|
setCustomTheme()
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
binding = ActivityPrefsXBinding.inflate(layoutInflater)
|
|
||||||
binding.lifecycleOwner = this
|
|
||||||
toolbar = binding.toolbar
|
|
||||||
|
|
||||||
if (savedInstanceState == null && (intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
|
if (savedInstanceState == null && (intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
|
||||||
handleIntent(intent)
|
handleIntent(intent)
|
||||||
}
|
}
|
||||||
@ -106,22 +89,6 @@ class PrefsActivityX : AppCompatActivity() {
|
|||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
setSupportActionBar(toolbar)
|
|
||||||
toolbar.isFocusableInTouchMode = true
|
|
||||||
|
|
||||||
val navHostFragment =
|
|
||||||
supportFragmentManager.findFragmentById(R.id.fragment_content) as NavHostFragment
|
|
||||||
navController = navHostFragment.navController
|
|
||||||
binding.bottomNavigation.setupWithNavController(navController)
|
|
||||||
|
|
||||||
appBarConfiguration = AppBarConfiguration(
|
|
||||||
setOf(R.id.userTab, R.id.updateTab, R.id.reposTab, R.id.otherTab)
|
|
||||||
)
|
|
||||||
setupActionBarWithNavController(navController, appBarConfiguration)
|
|
||||||
|
|
||||||
supportFragmentManager.addFragmentOnAttachListener { _, _ ->
|
|
||||||
hideKeyboard()
|
|
||||||
}
|
|
||||||
syncConnection.bind(this)
|
syncConnection.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,11 +96,6 @@ class PrefsActivityX : AppCompatActivity() {
|
|||||||
finishAfterTransition()
|
finishAfterTransition()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideKeyboard() {
|
|
||||||
(getSystemService(INPUT_METHOD_SERVICE) as? InputMethodManager)
|
|
||||||
?.hideSoftInputFromWindow((currentFocus ?: window.decorView).windowToken, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent?) {
|
override fun onNewIntent(intent: Intent?) {
|
||||||
super.onNewIntent(intent)
|
super.onNewIntent(intent)
|
||||||
handleIntent(intent)
|
handleIntent(intent)
|
||||||
@ -196,14 +158,4 @@ class PrefsActivityX : AppCompatActivity() {
|
|||||||
override fun attachBaseContext(newBase: Context) {
|
override fun attachBaseContext(newBase: Context) {
|
||||||
super.attachBaseContext(ContextWrapperX.wrap(newBase))
|
super.attachBaseContext(ContextWrapperX.wrap(newBase))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUpdateNotificationBlocker(activeSource: Source) {
|
|
||||||
val blockerFragment = if (activeSource == Source.UPDATES) {
|
|
||||||
supportFragmentManager.fragments.asSequence().mapNotNull { it as? MainNavFragmentX }
|
|
||||||
.find { it.primarySource == activeSource }
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
syncConnection.binder?.setUpdateNotificationBlocker(blockerFragment)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user