emulator layout statusbar fix + fixed #674

This commit is contained in:
LagradOst 2022-02-18 20:54:55 +01:00
parent ddab37c08d
commit 59e318a742
5 changed files with 63 additions and 19 deletions

View file

@ -34,6 +34,7 @@ import com.lagradost.cloudstream3.syncproviders.OAuth2API.Companion.appString
import com.lagradost.cloudstream3.ui.APIRepository
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO
import com.lagradost.cloudstream3.ui.result.ResultFragment
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isEmulatorSettings
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable
import com.lagradost.cloudstream3.utils.AppUtils.loadCache
@ -42,6 +43,7 @@ import com.lagradost.cloudstream3.utils.DataStore.getKey
import com.lagradost.cloudstream3.utils.DataStore.removeKey
import com.lagradost.cloudstream3.utils.DataStoreHelper.setViewPos
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
import com.lagradost.cloudstream3.utils.UIHelper.changeStatusBarState
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
import com.lagradost.cloudstream3.utils.UIHelper.getResourceColor
@ -293,6 +295,8 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
setContentView(R.layout.activity_main)
}
changeStatusBarState(isEmulatorSettings())
// val navView: BottomNavigationView = findViewById(R.id.nav_view)

View file

@ -62,8 +62,6 @@ class GrdLayoutManager(val context: Context, private val spanCoun: Int) : GridLa
}
private fun calcOffsetToNextView(direction: Int): Int {
println("calc")
val spanCount = this.spanCoun
val orientation = this.orientation

View file

@ -53,17 +53,49 @@ object SearchResultBuilder {
cardView.setImageResource(R.drawable.default_cover)
}
bg.setOnClickListener {
fun click(view: View?) {
clickCallback.invoke(
SearchClickCallback(
if (card is DataStoreHelper.ResumeWatchingResult) SEARCH_ACTION_PLAY_FILE else SEARCH_ACTION_LOAD,
it,
view ?: return,
position,
card
)
)
}
fun longClick(view: View?) {
clickCallback.invoke(
SearchClickCallback(
SEARCH_ACTION_SHOW_METADATA,
view ?: return,
position,
card
)
)
}
fun focus(view: View?, focus: Boolean) {
if (focus) {
clickCallback.invoke(
SearchClickCallback(
SEARCH_ACTION_FOCUSED,
view ?: return,
position,
card
)
)
}
}
bg.setOnClickListener {
click(it)
}
itemView.setOnClickListener {
click(it)
}
if (nextFocusUp != null) {
bg.nextFocusUpId = nextFocusUp
}
@ -90,23 +122,23 @@ object SearchResultBuilder {
}
bg.setOnLongClickListener {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, position, card))
longClick(it)
return@setOnLongClickListener true
}
itemView.setOnLongClickListener {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_SHOW_METADATA, it, position, card))
longClick(it)
return@setOnLongClickListener true
}
bg.setOnFocusChangeListener { view, b ->
if (b) {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_FOCUSED, view, position, card))
}
focus(view, b)
}
itemView.setOnFocusChangeListener { view, b ->
if (b) {
clickCallback.invoke(SearchClickCallback(SEARCH_ACTION_FOCUSED, view, position, card))
}
focus(view, b)
}
when (card) {
is DataStoreHelper.ResumeWatchingResult -> {
val pos = card.watchPos?.fixVisual()
@ -119,7 +151,8 @@ object SearchResultBuilder {
playImg?.visibility = View.VISIBLE
if (!card.type.isMovieType()) {
cardText?.text = cardText?.context?.getNameFull(card.name, card.episode, card.season)
cardText?.text =
cardText?.context?.getNameFull(card.name, card.episode, card.season)
}
}
is AnimeSearchResponse -> {
@ -135,7 +168,8 @@ object SearchResultBuilder {
textIsDub?.apply {
val dubText = context.getString(R.string.app_dubbed_text)
text = if (card.dubEpisodes != null && card.dubEpisodes > 0) {
context.getString(R.string.app_dub_sub_episode_text_format).format(dubText, card.dubEpisodes)
context.getString(R.string.app_dub_sub_episode_text_format)
.format(dubText, card.dubEpisodes)
} else {
dubText
}
@ -144,7 +178,8 @@ object SearchResultBuilder {
textIsSub?.apply {
val subText = context.getString(R.string.app_subbed_text)
text = if (card.subEpisodes != null && card.subEpisodes > 0) {
context.getString(R.string.app_dub_sub_episode_text_format).format(subText, card.subEpisodes)
context.getString(R.string.app_dub_sub_episode_text_format)
.format(subText, card.subEpisodes)
} else {
subText
}

View file

@ -74,6 +74,10 @@ class SettingsFragment : PreferenceFragmentCompat() {
return getLayoutInt() == 1
}
fun Context.isEmulatorSettings() : Boolean {
return getLayoutInt() == 2
}
private fun Context.isAutoTv(): Boolean {
val uiModeManager = getSystemService(Context.UI_MODE_SERVICE) as UiModeManager?
return uiModeManager?.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION

View file

@ -39,6 +39,7 @@ import com.bumptech.glide.load.model.GlideUrl
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.mvvm.logError
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isEmulatorSettings
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
import com.lagradost.cloudstream3.utils.GlideOptions.bitmapTransform
import jp.wasabeef.glide.transformations.BlurTransformation
@ -313,10 +314,12 @@ object UIHelper {
// Shows the system bars by removing all the flags
// except for the ones that make the content appear under the system bars.
fun Activity.showSystemUI() {
window.decorView.systemUiVisibility = (
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
) // or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
window.decorView.systemUiVisibility =
(View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN)
changeStatusBarState(isEmulatorSettings())
// window.clearFlags(View.KEEP_SCREEN_ON)
}