mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
small fix for android tv and dark theme
This commit is contained in:
parent
37d402d7b3
commit
696f38e746
9 changed files with 52 additions and 21 deletions
|
@ -12,10 +12,12 @@ import android.content.res.Resources
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.*
|
import android.view.*
|
||||||
|
import android.view.KeyEvent.ACTION_DOWN
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.navigation.findNavController
|
import androidx.navigation.findNavController
|
||||||
import androidx.navigation.ui.setupWithNavController
|
import androidx.navigation.ui.setupWithNavController
|
||||||
|
@ -50,6 +52,7 @@ import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.requestRW
|
import com.lagradost.cloudstream3.utils.UIHelper.requestRW
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.shouldShowPIPMode
|
import com.lagradost.cloudstream3.utils.UIHelper.shouldShowPIPMode
|
||||||
|
import com.lagradost.cloudstream3.utils.UIHelper.showInputMethod
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
import com.lagradost.cloudstream3.utils.UIHelper.toPx
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
import kotlinx.android.synthetic.main.activity_main.*
|
||||||
import kotlinx.android.synthetic.main.fragment_result.*
|
import kotlinx.android.synthetic.main.fragment_result.*
|
||||||
|
@ -142,6 +145,33 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun dispatchKeyEvent(event: KeyEvent?): Boolean {
|
||||||
|
event?.keyCode?.let { keyCode ->
|
||||||
|
when (event.action) {
|
||||||
|
ACTION_DOWN -> {
|
||||||
|
when (keyCode) {
|
||||||
|
KeyEvent.KEYCODE_DPAD_CENTER -> {
|
||||||
|
println("DPAD PRESSED $currentFocus")
|
||||||
|
if (currentFocus is SearchView || currentFocus is SearchView.SearchAutoComplete) {
|
||||||
|
println("current PRESSED")
|
||||||
|
showInputMethod(currentFocus?.findFocus())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//println("Keycode: $keyCode")
|
||||||
|
//showToast(
|
||||||
|
// this,
|
||||||
|
// "Got Keycode $keyCode | ${KeyEvent.keyCodeToString(keyCode)} \n ${event?.action}",
|
||||||
|
// Toast.LENGTH_LONG
|
||||||
|
//)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.dispatchKeyEvent(event)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||||
//println("Keycode: $keyCode")
|
//println("Keycode: $keyCode")
|
||||||
//showToast(
|
//showToast(
|
||||||
|
@ -206,7 +236,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
|
|
||||||
//when (keyCode) {
|
//when (keyCode) {
|
||||||
// KeyEvent.KEYCODE_DPAD_CENTER -> {
|
// KeyEvent.KEYCODE_DPAD_CENTER -> {
|
||||||
// println("DPAD PRESSED ${this.isKeyboardOpen()}")
|
// println("DPAD PRESSED")
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
@ -385,6 +415,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
"Black" -> R.style.AppTheme
|
"Black" -> R.style.AppTheme
|
||||||
"Light" -> R.style.LightMode
|
"Light" -> R.style.LightMode
|
||||||
"Amoled" -> R.style.AmoledMode
|
"Amoled" -> R.style.AmoledMode
|
||||||
|
"AmoledLight" -> R.style.AmoledModeLight
|
||||||
else -> R.style.AppTheme
|
else -> R.style.AppTheme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,12 +159,12 @@ class QuickSearchFragment(var isMainApis: Boolean = false) : Fragment() {
|
||||||
quick_search_master_recycler.adapter = masterAdapter
|
quick_search_master_recycler.adapter = masterAdapter
|
||||||
quick_search_master_recycler.layoutManager = GridLayoutManager(context, 1)
|
quick_search_master_recycler.layoutManager = GridLayoutManager(context, 1)
|
||||||
|
|
||||||
quick_search.setOnQueryTextFocusChangeListener { _, b ->
|
//quick_search.setOnQueryTextFocusChangeListener { _, b ->
|
||||||
if (b) {
|
// if (b) {
|
||||||
// https://stackoverflow.com/questions/12022715/unable-to-show-keyboard-automatically-in-the-searchview
|
// // https://stackoverflow.com/questions/12022715/unable-to-show-keyboard-automatically-in-the-searchview
|
||||||
UIHelper.showInputMethod(view.findFocus())
|
// UIHelper.showInputMethod(view.findFocus())
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
quick_search_back.setOnClickListener {
|
quick_search_back.setOnClickListener {
|
||||||
activity?.popCurrentPage()
|
activity?.popCurrentPage()
|
||||||
|
|
|
@ -36,7 +36,6 @@ import com.lagradost.cloudstream3.utils.SEARCH_PROVIDER_TOGGLE
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact
|
import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.showInputMethod
|
|
||||||
import kotlinx.android.synthetic.main.fragment_search.*
|
import kotlinx.android.synthetic.main.fragment_search.*
|
||||||
import java.util.concurrent.locks.ReentrantLock
|
import java.util.concurrent.locks.ReentrantLock
|
||||||
|
|
||||||
|
@ -373,12 +372,12 @@ class SearchFragment : Fragment() {
|
||||||
typesActive = it.getApiTypeSettings()
|
typesActive = it.getApiTypeSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
main_search.setOnQueryTextFocusChangeListener { _, b ->
|
/*main_search.setOnQueryTextFocusChangeListener { _, b ->
|
||||||
if (b) {
|
if (b) {
|
||||||
// https://stackoverflow.com/questions/12022715/unable-to-show-keyboard-automatically-in-the-searchview
|
// https://stackoverflow.com/questions/12022715/unable-to-show-keyboard-automatically-in-the-searchview
|
||||||
showInputMethod(view.findFocus())
|
showInputMethod(view.findFocus())
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
//main_search.onActionViewExpanded()*/
|
//main_search.onActionViewExpanded()*/
|
||||||
|
|
||||||
val masterAdapter: RecyclerView.Adapter<RecyclerView.ViewHolder> = ParentItemAdapter(listOf(), { callback ->
|
val masterAdapter: RecyclerView.Adapter<RecyclerView.ViewHolder> = ParentItemAdapter(listOf(), { callback ->
|
||||||
|
|
|
@ -300,7 +300,8 @@ object UIHelper {
|
||||||
inputMethodManager?.hideSoftInputFromWindow(view.windowToken, 0)
|
inputMethodManager?.hideSoftInputFromWindow(view.windowToken, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showInputMethod(view: View) {
|
fun showInputMethod(view: View?) {
|
||||||
|
if(view == null) return
|
||||||
val inputMethodManager = view.context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager?
|
val inputMethodManager = view.context.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager?
|
||||||
inputMethodManager?.showSoftInput(view, 0)
|
inputMethodManager?.showSoftInput(view, 0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="match_parent">
|
android:layout_width="match_parent">
|
||||||
<com.google.android.material.navigationrail.NavigationRailView
|
<com.google.android.material.navigationrail.NavigationRailView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="62dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/nav_rail_view"
|
android:id="@+id/nav_rail_view"
|
||||||
android:background="?attr/primaryGrayBackground"
|
android:background="?attr/primaryGrayBackground"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="match_parent">
|
android:layout_width="match_parent">
|
||||||
<com.google.android.material.navigationrail.NavigationRailView
|
<com.google.android.material.navigationrail.NavigationRailView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="62dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/nav_rail_view"
|
android:id="@+id/nav_rail_view"
|
||||||
android:background="?attr/primaryGrayBackground"
|
android:background="?attr/primaryGrayBackground"
|
||||||
|
|
|
@ -115,11 +115,13 @@
|
||||||
|
|
||||||
<string-array name="themes_names">
|
<string-array name="themes_names">
|
||||||
<item>Normal</item>
|
<item>Normal</item>
|
||||||
|
<item>Dark</item>
|
||||||
<item>Amoled</item>
|
<item>Amoled</item>
|
||||||
<item>Flashbang</item>
|
<item>Flashbang</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
<string-array name="themes_names_values">
|
<string-array name="themes_names_values">
|
||||||
<item>Black</item>
|
<item>Black</item>
|
||||||
|
<item>AmoledLight</item>
|
||||||
<item>Amoled</item>
|
<item>Amoled</item>
|
||||||
<item>Light</item>
|
<item>Light</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
<color name="black">#000</color>
|
<color name="black">#000</color>
|
||||||
|
|
||||||
<color name="dubColor">#3d50fa</color> <!--3b65f5 f18c82 8294F1-->
|
<color name="dubColor">#3d50fa</color> <!--3b65f5 f18c82 8294F1-->
|
||||||
|
<color name="amoledModeLight">#121213</color>
|
||||||
|
|
||||||
<color name="dubColorBg">#803B65F5</color>
|
<color name="dubColorBg">#803B65F5</color>
|
||||||
<color name="subColor">#F54A3B</color> <!--F53B66 FA3D79-->
|
<color name="subColor">#F54A3B</color> <!--F53B66 FA3D79-->
|
||||||
<color name="subColorBg">#80F53B66</color>
|
<color name="subColorBg">#80F53B66</color>
|
||||||
|
|
|
@ -57,13 +57,9 @@
|
||||||
<item name="white">#FFF</item>
|
<item name="white">#FFF</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- <style name="PreferencesTheme" parent="@style/Base.Theme.AppCompat">
|
<style name="AmoledModeLight" parent="AmoledMode">
|
||||||
<item name="android:textColorPrimary">?attr/textColor</item>
|
<item name="primaryGrayBackground">@color/amoledModeLight</item>
|
||||||
<item name="android:textColorSecondary">?attr/grayTextColor</item>
|
</style>
|
||||||
<item name="android:colorAccent">?attr/colorAccent</item>
|
|
||||||
<item name="android:colorControlHighlight">@color/colorPrimary</item>
|
|
||||||
<item name="android:tint">?attr/textColor</item>
|
|
||||||
</style>-->
|
|
||||||
|
|
||||||
<style name="AmoledMode">
|
<style name="AmoledMode">
|
||||||
<item name="primaryGrayBackground">@color/black</item>
|
<item name="primaryGrayBackground">@color/black</item>
|
||||||
|
|
Loading…
Reference in a new issue