diff --git a/app/src/main/java/com/github/libretube/services/ClosingService.kt b/app/src/main/java/com/github/libretube/services/ClosingService.kt index ad3f48a14..12b16c237 100644 --- a/app/src/main/java/com/github/libretube/services/ClosingService.kt +++ b/app/src/main/java/com/github/libretube/services/ClosingService.kt @@ -5,12 +5,10 @@ import android.app.Service import android.content.Context import android.content.Intent import android.os.IBinder -import androidx.annotation.Nullable import com.github.libretube.constants.PLAYER_NOTIFICATION_ID class ClosingService : Service() { - @Nullable override fun onBind(intent: Intent?): IBinder? { return null } diff --git a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt index 781dab4ba..7b3a88f6c 100644 --- a/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/ui/activities/MainActivity.kt @@ -85,12 +85,6 @@ class MainActivity : BaseActivity() { navController = findNavController(R.id.fragment) binding.bottomNav.setupWithNavController(navController) - // gets the surface color of the bottom navigation view - val color = SurfaceColors.getColorForElevation(this, 10F) - - // sets the navigation bar color to the previously calculated color - window.navigationBarColor = color - // save start tab fragment id and apply navbar style startFragmentId = try { NavBarHelper.applyNavBarStyle(binding.bottomNav) @@ -98,6 +92,11 @@ class MainActivity : BaseActivity() { R.id.homeFragment } + // sets the navigation bar color to the previously calculated color + window.navigationBarColor = if (binding.bottomNav.menu.size() > 0) { + SurfaceColors.getColorForElevation(this, 10F) + } else ThemeHelper.getThemeColor(this, android.R.attr.colorBackground) + // set default tab as start fragment navController.graph.setStartDestination(startFragmentId) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/NavBarOptionsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/NavBarOptionsAdapter.kt index a58ad475d..8c12b0a69 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/NavBarOptionsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/NavBarOptionsAdapter.kt @@ -3,7 +3,6 @@ package com.github.libretube.ui.adapters import android.view.LayoutInflater import android.view.MenuItem import android.view.ViewGroup -import android.widget.Toast import androidx.recyclerview.widget.RecyclerView import com.github.libretube.R import com.github.libretube.databinding.NavOptionsItemBinding @@ -39,10 +38,6 @@ class NavBarOptionsAdapter( if (selectedHomeTabId == item.itemId) { return@setOnClickListener } - if (!item.isVisible) { - Toast.makeText(root.context, R.string.not_enabled, Toast.LENGTH_SHORT).show() - return@setOnClickListener - } val oldSelection = items.indexOfFirst { it.itemId == selectedHomeTabId } selectedHomeTabId = item.itemId listOf(position, oldSelection).forEach { @@ -50,25 +45,8 @@ class NavBarOptionsAdapter( } } checkbox.setOnClickListener { - if (item.itemId == selectedHomeTabId) { - Toast.makeText(root.context, R.string.select_other_start_tab, Toast.LENGTH_SHORT).show() - return@setOnClickListener - } - if (!checkbox.isChecked && getVisibleItemsCount() < 2) { - checkbox.isChecked = true - Toast.makeText( - root.context, - R.string.select_at_least_one, - Toast.LENGTH_SHORT - ).show() - return@setOnClickListener - } item.isVisible = checkbox.isChecked } } } - - private fun getVisibleItemsCount(): Int { - return items.filter { it.isVisible }.size - } } diff --git a/app/src/main/java/com/github/libretube/util/NavBarHelper.kt b/app/src/main/java/com/github/libretube/util/NavBarHelper.kt index f95a2f5fe..4e7d61d96 100644 --- a/app/src/main/java/com/github/libretube/util/NavBarHelper.kt +++ b/app/src/main/java/com/github/libretube/util/NavBarHelper.kt @@ -5,6 +5,7 @@ import android.util.Log import android.view.Menu import android.view.MenuInflater import android.view.MenuItem +import android.view.View import android.widget.PopupMenu import androidx.core.view.forEach import androidx.core.view.get @@ -106,6 +107,8 @@ object NavBarHelper { ).icon = menuItem.icon } } + if (navBarItems.filter { it.isVisible }.isEmpty()) bottomNav.visibility = View.GONE + return getStartFragmentId(bottomNav.context) } @@ -113,7 +116,7 @@ object NavBarHelper { val pref = PreferenceHelper.getInt(PreferenceKeys.START_FRAGMENT, Int.MAX_VALUE) val defaultNavItems = getDefaultNavBarItems(context) return if (pref == Int.MAX_VALUE) { - getNavBarItems(context).first { it.isVisible }.itemId + getNavBarItems(context).firstOrNull { it.isVisible }?.itemId ?: R.id.homeFragment } else { defaultNavItems.get(pref).itemId }