diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index 1083ad49..b7add6ff 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -1,6 +1,5 @@ package com.lagradost.cloudstream3 -import android.animation.ObjectAnimator import android.animation.ValueAnimator import android.content.ComponentName import android.content.Context @@ -12,7 +11,12 @@ import android.os.Build import android.os.Bundle import android.util.AttributeSet import android.util.Log -import android.view.* +import android.view.KeyEvent +import android.view.Menu +import android.view.MenuItem +import android.view.View +import android.view.ViewGroup +import android.view.WindowManager import android.widget.Toast import androidx.activity.result.ActivityResultLauncher import androidx.annotation.IdRes @@ -20,8 +24,7 @@ import androidx.annotation.MainThread import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import androidx.constraintlayout.widget.ConstraintLayout -import androidx.core.animation.addListener -import androidx.core.view.ViewCompat +import androidx.core.view.children import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.fragment.app.FragmentActivity @@ -37,7 +40,10 @@ import androidx.preference.PreferenceManager import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper -import com.google.android.gms.cast.framework.* +import com.google.android.gms.cast.framework.CastContext +import com.google.android.gms.cast.framework.Session +import com.google.android.gms.cast.framework.SessionManager +import com.google.android.gms.cast.framework.SessionManagerListener import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.navigationrail.NavigationRailView @@ -59,7 +65,11 @@ import com.lagradost.cloudstream3.CommonActivity.updateLocale import com.lagradost.cloudstream3.databinding.ActivityMainBinding import com.lagradost.cloudstream3.databinding.ActivityMainTvBinding import com.lagradost.cloudstream3.databinding.BottomResultviewPreviewBinding -import com.lagradost.cloudstream3.mvvm.* +import com.lagradost.cloudstream3.mvvm.Resource +import com.lagradost.cloudstream3.mvvm.debugAssert +import com.lagradost.cloudstream3.mvvm.logError +import com.lagradost.cloudstream3.mvvm.normalSafeApiCall +import com.lagradost.cloudstream3.mvvm.observeNullable import com.lagradost.cloudstream3.network.initClient import com.lagradost.cloudstream3.plugins.PluginManager import com.lagradost.cloudstream3.plugins.PluginManager.loadAllOnlinePlugins @@ -94,7 +104,7 @@ import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.updateT import com.lagradost.cloudstream3.ui.settings.SettingsGeneral import com.lagradost.cloudstream3.ui.setup.HAS_DONE_SETUP_KEY import com.lagradost.cloudstream3.ui.setup.SetupFragmentExtensions -import com.lagradost.cloudstream3.utils.* +import com.lagradost.cloudstream3.utils.ApkInstaller import com.lagradost.cloudstream3.utils.AppUtils.html import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable import com.lagradost.cloudstream3.utils.AppUtils.isLtr @@ -111,6 +121,8 @@ import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.setKey import com.lagradost.cloudstream3.utils.DataStoreHelper.migrateResumeWatching +import com.lagradost.cloudstream3.utils.Event +import com.lagradost.cloudstream3.utils.IOnBackPressed import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog import com.lagradost.cloudstream3.utils.UIHelper.changeStatusBarState @@ -122,6 +134,8 @@ import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard import com.lagradost.cloudstream3.utils.UIHelper.navigate import com.lagradost.cloudstream3.utils.UIHelper.requestRW import com.lagradost.cloudstream3.utils.UIHelper.toPx +import com.lagradost.cloudstream3.utils.USER_PROVIDER_API +import com.lagradost.cloudstream3.utils.USER_SELECTED_HOMEPAGE_API import com.lagradost.nicehttp.Requests import com.lagradost.nicehttp.ResponseParser import kotlinx.coroutines.sync.Mutex @@ -1216,6 +1230,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { navController.addOnDestinationChangedListener { _: NavController, navDestination: NavDestination, bundle: Bundle? -> // Intercept search and add a query + updateNavBar(navDestination) if (navDestination.matchDestination(R.id.navigation_search) && !nextSearchQuery.isNullOrBlank()) { bundle?.apply { this.putString(SearchFragment.SEARCH_QUERY, nextSearchQuery) @@ -1234,29 +1249,47 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { .setPopExitAnim(R.anim.nav_pop_exit) .setPopUpTo(navController.graph.startDestination, false) .build()*/ - binding?.navView?.setupWithNavController(navController) - val navRail = findViewById(R.id.nav_rail_view) - navRail?.setupWithNavController(navController) - if (isTvSettings()) { - navRail?.background?.alpha = 200 - } else { - navRail?.background?.alpha = 255 + val rippleColor = ColorStateList.valueOf(getResourceColor(R.attr.colorPrimary, 0.1f)) + + binding?.navView?.apply { + itemRippleColor = rippleColor + itemActiveIndicatorColor = rippleColor + setupWithNavController(navController) + setOnItemSelectedListener { item -> + onNavDestinationSelected( + item, + navController + ) + } } - navRail?.setOnItemSelectedListener { item -> - onNavDestinationSelected( - item, - navController - ) - } - binding?.navView?.setOnItemSelectedListener { item -> - onNavDestinationSelected( - item, - navController - ) - } - navController.addOnDestinationChangedListener { _, destination, _ -> - updateNavBar(destination) + + binding?.navRailView?.apply { + itemRippleColor = rippleColor + itemActiveIndicatorColor = rippleColor + setupWithNavController(navController) + if (isTvSettings()) { + background?.alpha = 200 + } else { + background?.alpha = 255 + } + + setOnItemSelectedListener { item -> + onNavDestinationSelected( + item, + navController + ) + } + + fun noFocus(view: View) { + view.tag = view.context.getString(R.string.tv_no_focus_tag) + (view as? ViewGroup)?.let { + for (child in it.children) { + noFocus(child) + } + } + } + noFocus(this) } loadCache() @@ -1279,11 +1312,6 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener { true }*/ - val rippleColor = ColorStateList.valueOf(getResourceColor(R.attr.colorPrimary, 0.1f)) - binding?.navView?.itemRippleColor = rippleColor - navRail?.itemRippleColor = rippleColor - navRail?.itemActiveIndicatorColor = rippleColor - binding?.navView?.itemActiveIndicatorColor = rippleColor if (!checkWrite()) { requestRW() diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt index f62d7e73..1feb7d88 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt @@ -301,8 +301,8 @@ class ResultFragmentTv : Fragment() { resultEpisodes ) for (requestView in views) { - if (!requestView.isVisible) continue - if (requestView.requestFocus()) break + if (!requestView.isShown) continue + if (requestView.requestFocus()) break // View.FOCUS_RIGHT } } } diff --git a/app/src/main/res/layout/fragment_result_tv.xml b/app/src/main/res/layout/fragment_result_tv.xml index 324935e5..2fec04c6 100644 --- a/app/src/main/res/layout/fragment_result_tv.xml +++ b/app/src/main/res/layout/fragment_result_tv.xml @@ -566,6 +566,7 @@ https://developer.android.com/design/ui/tv/samples/jet-fit tools:visibility="visible"> --> @@ -66,7 +65,7 @@ android:layout_height="match_parent" android:layout_rowWeight="1" android:background="?attr/primaryBlackBackground" - android:listSelector="@drawable/outline_drawable_less" + android:listSelector="@drawable/outline_drawable_forced" android:nextFocusLeft="@id/sort_subtitles" android:nextFocusRight="@id/apply_btt" android:requiresFadingEdge="vertical" @@ -95,8 +94,7 @@ android:layout_height="wrap_content" android:layout_rowWeight="1" android:layout_marginTop="10dp" - android:background="@drawable/outline_drawable_less" - android:foreground="?attr/selectableItemBackgroundBorderless" + android:foreground="@drawable/outline_drawable_forced" android:orientation="horizontal" android:paddingTop="10dp" android:paddingBottom="10dp"> @@ -140,7 +138,7 @@ android:layout_height="match_parent" android:layout_rowWeight="1" android:background="?attr/primaryBlackBackground" - android:listSelector="@drawable/outline_drawable_less" + android:listSelector="@drawable/outline_drawable_forced" android:nextFocusLeft="@id/sort_providers" android:nextFocusRight="@id/cancel_btt" android:requiresFadingEdge="vertical" diff --git a/app/src/main/res/layout/sort_bottom_footer_add_choice.xml b/app/src/main/res/layout/sort_bottom_footer_add_choice.xml index 82937ba1..63d79227 100644 --- a/app/src/main/res/layout/sort_bottom_footer_add_choice.xml +++ b/app/src/main/res/layout/sort_bottom_footer_add_choice.xml @@ -4,5 +4,6 @@ style="@style/CheckLabel" android:id="@android:id/text1" tools:text="hello" + android:foreground="@drawable/outline_drawable_forced" app:drawableStartCompat="@drawable/ic_baseline_add_24" app:drawableTint="?attr/textColor" /> \ No newline at end of file