mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-08 08:49:55 +00:00
add the default tab settings
This commit is contained in:
parent
afd6f21613
commit
41d85d7309
@ -35,6 +35,7 @@ object Preferences {
|
|||||||
Key.RootPermission,
|
Key.RootPermission,
|
||||||
Key.SortOrder,
|
Key.SortOrder,
|
||||||
Key.Theme,
|
Key.Theme,
|
||||||
|
Key.DefaultTab,
|
||||||
Key.UpdateNotify,
|
Key.UpdateNotify,
|
||||||
Key.UpdateUnstable
|
Key.UpdateUnstable
|
||||||
).map { Pair(it.name, it) }.toMap()
|
).map { Pair(it.name, it) }.toMap()
|
||||||
@ -169,6 +170,12 @@ object Preferences {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
object DefaultTab : Key<Preferences.DefaultTab>(
|
||||||
|
"default_tab", Value.EnumerationValue(
|
||||||
|
Preferences.DefaultTab.Explore
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
object UpdateNotify : Key<Boolean>("update_notify", Value.BooleanValue(true))
|
object UpdateNotify : Key<Boolean>("update_notify", Value.BooleanValue(true))
|
||||||
object UpdateUnstable : Key<Boolean>("update_unstable", Value.BooleanValue(false))
|
object UpdateUnstable : Key<Boolean>("update_unstable", Value.BooleanValue(false))
|
||||||
}
|
}
|
||||||
@ -237,6 +244,25 @@ object Preferences {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sealed class DefaultTab(override val valueString: String) : Enumeration<DefaultTab> {
|
||||||
|
override val values: List<DefaultTab>
|
||||||
|
get() = listOf(Explore, Latest, Installed)
|
||||||
|
|
||||||
|
abstract fun getResId(configuration: Configuration): Int
|
||||||
|
|
||||||
|
object Explore : DefaultTab("explore") {
|
||||||
|
override fun getResId(configuration: Configuration): Int = R.id.exploreTab
|
||||||
|
}
|
||||||
|
|
||||||
|
object Latest : DefaultTab("latest") {
|
||||||
|
override fun getResId(configuration: Configuration): Int = R.id.latestTab
|
||||||
|
}
|
||||||
|
|
||||||
|
object Installed : DefaultTab("installed") {
|
||||||
|
override fun getResId(configuration: Configuration): Int = R.id.installedTab
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
operator fun <T> get(key: Key<T>): T {
|
operator fun <T> get(key: Key<T>): T {
|
||||||
return key.default.get(preferences, key.name, key.default)
|
return key.default.get(preferences, key.name, key.default)
|
||||||
}
|
}
|
||||||
|
@ -68,9 +68,11 @@ class MainActivityX : AppCompatActivity() {
|
|||||||
get() = (application as MainApplication).db
|
get() = (application as MainApplication).db
|
||||||
|
|
||||||
var currentTheme by Delegates.notNull<Int>()
|
var currentTheme by Delegates.notNull<Int>()
|
||||||
|
var currentTab by Delegates.notNull<Int>()
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
currentTheme = Preferences[Preferences.Key.Theme].getResId(resources.configuration)
|
currentTheme = Preferences[Preferences.Key.Theme].getResId(resources.configuration)
|
||||||
|
currentTab = Preferences[Preferences.Key.DefaultTab].getResId(resources.configuration)
|
||||||
setTheme(currentTheme)
|
setTheme(currentTheme)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
binding = ActivityMainXBinding.inflate(layoutInflater)
|
binding = ActivityMainXBinding.inflate(layoutInflater)
|
||||||
@ -79,20 +81,7 @@ class MainActivityX : AppCompatActivity() {
|
|||||||
binding.lifecycleOwner = this
|
binding.lifecycleOwner = this
|
||||||
toolbar = binding.toolbar
|
toolbar = binding.toolbar
|
||||||
|
|
||||||
if (savedInstanceState == null && (intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
|
|
||||||
handleIntent(intent)
|
|
||||||
}
|
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onStart() {
|
|
||||||
super.onStart()
|
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
if (Android.sdk(28) && !Android.Device.isHuaweiEmui) {
|
|
||||||
toolbar.menu.setGroupDividerEnabled(true)
|
|
||||||
}
|
|
||||||
toolbar.isFocusableInTouchMode = true
|
|
||||||
toolbar.title = getString(R.string.application_name)
|
|
||||||
|
|
||||||
val navHostFragment =
|
val navHostFragment =
|
||||||
supportFragmentManager.findFragmentById(R.id.fragment_content) as NavHostFragment
|
supportFragmentManager.findFragmentById(R.id.fragment_content) as NavHostFragment
|
||||||
@ -103,6 +92,21 @@ class MainActivityX : AppCompatActivity() {
|
|||||||
setOf(R.id.exploreTab, R.id.latestTab, R.id.installedTab)
|
setOf(R.id.exploreTab, R.id.latestTab, R.id.installedTab)
|
||||||
)
|
)
|
||||||
setupActionBarWithNavController(navController, appBarConfiguration)
|
setupActionBarWithNavController(navController, appBarConfiguration)
|
||||||
|
binding.bottomNavigation.selectedItemId = currentTab
|
||||||
|
|
||||||
|
if (savedInstanceState == null && (intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) {
|
||||||
|
handleIntent(intent)
|
||||||
|
}
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onStart() {
|
||||||
|
super.onStart()
|
||||||
|
if (Android.sdk(28) && !Android.Device.isHuaweiEmui) {
|
||||||
|
toolbar.menu.setGroupDividerEnabled(true)
|
||||||
|
}
|
||||||
|
toolbar.isFocusableInTouchMode = true
|
||||||
|
toolbar.title = getString(R.string.application_name)
|
||||||
|
|
||||||
supportFragmentManager.addFragmentOnAttachListener { _, _ ->
|
supportFragmentManager.addFragmentOnAttachListener { _, _ ->
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
|
@ -37,6 +37,13 @@ class PrefsUserFragment : PrefsNavFragmentX() {
|
|||||||
is Preferences.Theme.Amoled -> getString(R.string.amoled)
|
is Preferences.Theme.Amoled -> getString(R.string.amoled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
addEnumeration(Preferences.Key.DefaultTab, getString(R.string.default_tab)) {
|
||||||
|
when (it) {
|
||||||
|
is Preferences.DefaultTab.Explore -> getString(R.string.explore)
|
||||||
|
is Preferences.DefaultTab.Latest -> getString(R.string.latest)
|
||||||
|
is Preferences.DefaultTab.Installed -> getString(R.string.installed)
|
||||||
|
}
|
||||||
|
}
|
||||||
addSwitch(
|
addSwitch(
|
||||||
Preferences.Key.ListAnimation, getString(R.string.list_animation),
|
Preferences.Key.ListAnimation, getString(R.string.list_animation),
|
||||||
getString(R.string.list_animation_description)
|
getString(R.string.list_animation_description)
|
||||||
|
@ -186,4 +186,5 @@
|
|||||||
<string name="prefs_updated_apps">Number of updated apps to show</string>
|
<string name="prefs_updated_apps">Number of updated apps to show</string>
|
||||||
<string name="prefs_new_apps">Number of new apps to show</string>
|
<string name="prefs_new_apps">Number of new apps to show</string>
|
||||||
<string name="new_repository">New repository</string>
|
<string name="new_repository">New repository</string>
|
||||||
|
<string name="default_tab">Default Tab</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user