Added default tab on app startup

This commit is contained in:
Bnyro 2022-05-14 00:09:33 +02:00
parent 079fc949f1
commit d9b5c18cac
4 changed files with 30 additions and 0 deletions

View File

@ -18,6 +18,7 @@ import android.view.*
import android.view.inputmethod.InputMethodManager
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Toast
import androidx.appcompat.app.AppCompatDelegate
import androidx.appcompat.widget.Toolbar
import androidx.constraintlayout.motion.widget.MotionLayout
@ -86,6 +87,12 @@ class MainActivity : AppCompatActivity() {
navController = findNavController(R.id.fragment)
bottomNavigationView.setupWithNavController(navController)
when (sharedPreferences.getString("default_tab", "home")!!) {
"home" -> navController.navigate(R.id.home2)
"subscriptions" -> navController.navigate(R.id.subscriptions)
"library" -> navController.navigate(R.id.library)
}
bottomNavigationView.setOnItemSelectedListener {
when (it.itemId) {
R.id.home2 -> {

View File

@ -470,6 +470,19 @@
<item>L</item>
<item>D</item>
</string-array>
<string-array name="tabs">
<item>@string/startpage</item>
<item>@string/subscriptions</item>
<item>@string/library</item>
</string-array>
<string-array name="tabsValue">
<item>home</item>
<item>subscriptions</item>
<item>library</item>
</string-array>
<string-array name="defres">
<item>HLS</item>
<item>1080p</item>

View File

@ -72,4 +72,5 @@
<string name="noInternet">No Internet Connection</string>
<string name="retry">Retry</string>
<string name="comments">Comments</string>
<string name="defaultTab">Default Tab</string>
</resources>

View File

@ -71,6 +71,15 @@
android:icon="@drawable/ic_theme"
/>
<ListPreference
app:title="@string/defaultTab"
app:key="default_tab"
app:entries="@array/tabs"
app:entryValues="@array/tabsValue"
app:defaultValue="home"
android:icon="@drawable/ic_home"
/>
<ListPreference
app:title="@string/defres"
app:key="default_res"