This commit is contained in:
Bnyro 2022-09-20 19:03:18 +02:00
parent d9c7e937c6
commit 1ff7306063
3 changed files with 20 additions and 24 deletions

View File

@ -1,19 +0,0 @@
package com.github.libretube.constants
import com.github.libretube.R
import com.github.libretube.obj.NavBarItem
val navBarItems = listOf(
NavBarItem(
R.id.homeFragment,
R.string.startpage
),
NavBarItem(
R.id.subscriptionsFragment,
R.string.subscriptions
),
NavBarItem(
R.id.libraryFragment,
R.string.library
)
)

View File

@ -2,7 +2,6 @@ package com.github.libretube.dialogs
import android.app.Dialog import android.app.Dialog
import android.os.Bundle import android.os.Bundle
import android.util.Log
import androidx.fragment.app.DialogFragment import androidx.fragment.app.DialogFragment
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -64,6 +63,8 @@ class NavBarOptionsDialog : DialogFragment() {
.setView(binding.root) .setView(binding.root)
.setPositiveButton(R.string.okay) { _, _ -> .setPositiveButton(R.string.okay) { _, _ ->
NavBarHelper.setNavBarItems(adapter.items) NavBarHelper.setNavBarItems(adapter.items)
RequireRestartDialog()
.show(requireParentFragment().childFragmentManager, null)
} }
.setNegativeButton(R.string.cancel, null) .setNegativeButton(R.string.cancel, null)
.show() .show()

View File

@ -1,19 +1,33 @@
package com.github.libretube.util package com.github.libretube.util
import android.util.Log
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import com.fasterxml.jackson.core.type.TypeReference import com.fasterxml.jackson.core.type.TypeReference
import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.ObjectMapper
import com.github.libretube.R
import com.github.libretube.constants.PreferenceKeys import com.github.libretube.constants.PreferenceKeys
import com.github.libretube.constants.navBarItems
import com.github.libretube.extensions.TAG
import com.github.libretube.obj.NavBarItem import com.github.libretube.obj.NavBarItem
import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.navigation.NavigationBarView import com.google.android.material.navigation.NavigationBarView
object NavBarHelper { object NavBarHelper {
val preferenceKey = "nav_bar_items" val preferenceKey = "nav_bar_items"
val defaultNavBarItems = listOf(
NavBarItem(
R.id.homeFragment,
R.string.startpage
),
NavBarItem(
R.id.subscriptionsFragment,
R.string.subscriptions
),
NavBarItem(
R.id.libraryFragment,
R.string.library
)
)
val mapper = ObjectMapper() val mapper = ObjectMapper()
fun getNavBarItems(): List<NavBarItem> { fun getNavBarItems(): List<NavBarItem> {
@ -27,7 +41,7 @@ object NavBarHelper {
type type
) )
} catch (e: Exception) { } catch (e: Exception) {
return navBarItems return defaultNavBarItems
} }
} }