mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
add sync api icon on navigation bar and rail
This commit is contained in:
parent
b9746c2b17
commit
7a66fd01dd
2 changed files with 34 additions and 16 deletions
|
@ -165,10 +165,10 @@ dependencies {
|
||||||
|
|
||||||
// Android Core & Lifecycle
|
// Android Core & Lifecycle
|
||||||
implementation("androidx.core:core-ktx:1.13.1")
|
implementation("androidx.core:core-ktx:1.13.1")
|
||||||
implementation("androidx.appcompat:appcompat:1.6.1")
|
implementation("androidx.appcompat:appcompat:1.7.0")
|
||||||
implementation("androidx.navigation:navigation-ui-ktx:2.7.7")
|
implementation("androidx.navigation:navigation-ui-ktx:2.7.7")
|
||||||
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.7.0")
|
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.8.2")
|
||||||
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.7.0")
|
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.2")
|
||||||
implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")
|
implementation("androidx.navigation:navigation-fragment-ktx:2.7.7")
|
||||||
|
|
||||||
// Design & UI
|
// Design & UI
|
||||||
|
|
|
@ -44,9 +44,6 @@ import androidx.preference.PreferenceManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearSnapHelper
|
import androidx.recyclerview.widget.LinearSnapHelper
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
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.CastContext
|
import com.google.android.gms.cast.framework.CastContext
|
||||||
import com.google.android.gms.cast.framework.Session
|
import com.google.android.gms.cast.framework.Session
|
||||||
import com.google.android.gms.cast.framework.SessionManager
|
import com.google.android.gms.cast.framework.SessionManager
|
||||||
|
@ -101,6 +98,8 @@ import com.lagradost.cloudstream3.ui.SyncWatchType
|
||||||
import com.lagradost.cloudstream3.ui.WatchType
|
import com.lagradost.cloudstream3.ui.WatchType
|
||||||
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO
|
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO
|
||||||
import com.lagradost.cloudstream3.ui.home.HomeViewModel
|
import com.lagradost.cloudstream3.ui.home.HomeViewModel
|
||||||
|
import com.lagradost.cloudstream3.ui.library.LAST_SYNC_API_KEY
|
||||||
|
import com.lagradost.cloudstream3.ui.library.LibraryViewModel
|
||||||
import com.lagradost.cloudstream3.ui.player.BasicLink
|
import com.lagradost.cloudstream3.ui.player.BasicLink
|
||||||
import com.lagradost.cloudstream3.ui.player.GeneratorPlayer
|
import com.lagradost.cloudstream3.ui.player.GeneratorPlayer
|
||||||
import com.lagradost.cloudstream3.ui.player.LinkGenerator
|
import com.lagradost.cloudstream3.ui.player.LinkGenerator
|
||||||
|
@ -146,6 +145,7 @@ import com.lagradost.cloudstream3.utils.DataStore.getKey
|
||||||
import com.lagradost.cloudstream3.utils.DataStore.setKey
|
import com.lagradost.cloudstream3.utils.DataStore.setKey
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
import com.lagradost.cloudstream3.utils.DataStoreHelper
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.accounts
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.accounts
|
||||||
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.currentAccount
|
||||||
import com.lagradost.cloudstream3.utils.DataStoreHelper.migrateResumeWatching
|
import com.lagradost.cloudstream3.utils.DataStoreHelper.migrateResumeWatching
|
||||||
import com.lagradost.cloudstream3.utils.Event
|
import com.lagradost.cloudstream3.utils.Event
|
||||||
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
|
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
|
||||||
|
@ -162,8 +162,6 @@ import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
||||||
import com.lagradost.cloudstream3.utils.USER_PROVIDER_API
|
import com.lagradost.cloudstream3.utils.USER_PROVIDER_API
|
||||||
import com.lagradost.cloudstream3.utils.USER_SELECTED_HOMEPAGE_API
|
import com.lagradost.cloudstream3.utils.USER_SELECTED_HOMEPAGE_API
|
||||||
import com.lagradost.cloudstream3.utils.fcast.FcastManager
|
import com.lagradost.cloudstream3.utils.fcast.FcastManager
|
||||||
import com.lagradost.nicehttp.Requests
|
|
||||||
import com.lagradost.nicehttp.ResponseParser
|
|
||||||
import com.lagradost.safefile.SafeFile
|
import com.lagradost.safefile.SafeFile
|
||||||
import kotlinx.coroutines.sync.Mutex
|
import kotlinx.coroutines.sync.Mutex
|
||||||
import kotlinx.coroutines.sync.withLock
|
import kotlinx.coroutines.sync.withLock
|
||||||
|
@ -570,18 +568,38 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
binding?.apply {
|
binding?.apply {
|
||||||
navView.isVisible = isNavVisible && !landscape
|
|
||||||
navRailView.isVisible = isNavVisible && landscape
|
navRailView.isVisible = isNavVisible && landscape
|
||||||
|
navView.isVisible = isNavVisible && !landscape
|
||||||
|
|
||||||
// Hide library on TV since it is not supported yet :(
|
// Change library icon with logo of current api in sync
|
||||||
//val isTrueTv = isTrueTvSettings()
|
val libraryViewModel = ViewModelProvider(this@MainActivity)[LibraryViewModel::class.java]
|
||||||
//navView.menu.findItem(R.id.navigation_library)?.isVisible = !isTrueTv
|
val lastAPI = getKey<String>("$currentAccount/$LAST_SYNC_API_KEY").toString()
|
||||||
//navRailView.menu.findItem(R.id.navigation_library)?.isVisible = !isTrueTv
|
|
||||||
|
|
||||||
// Hide downloads on TV
|
fun setLibraryIcon(drawable: Int) {
|
||||||
//navView.menu.findItem(R.id.navigation_downloads)?.isVisible = !isTrueTv
|
navRailView.apply {
|
||||||
//navRailView.menu.findItem(R.id.navigation_downloads)?.isVisible = !isTrueTv
|
menu.findItem(R.id.navigation_library)?.setIcon(drawable)
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
|
navView.apply {
|
||||||
|
menu.findItem(R.id.navigation_library)?.setIcon(drawable)
|
||||||
|
invalidate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeLibraryIcon() {
|
||||||
|
when (lastAPI) {
|
||||||
|
"MAL" -> setLibraryIcon(R.drawable.mal_logo)
|
||||||
|
"AniList" -> setLibraryIcon(R.drawable.ic_anilist_icon)
|
||||||
|
"Simkl" -> setLibraryIcon(R.drawable.simkl_logo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// observing library vm changes icon without needing app restart
|
||||||
|
libraryViewModel.currentApiName.observe(this@MainActivity) {
|
||||||
|
changeLibraryIcon()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue