forked from recloudstream/cloudstream
Added better focus on dialogs on TV & fixed stream button on emulator layout
This commit is contained in:
parent
9fd2e84c7a
commit
89c5cb8a46
8 changed files with 31 additions and 12 deletions
|
@ -79,6 +79,7 @@ import com.lagradost.cloudstream3.utils.AppUtils.loadCache
|
|||
import com.lagradost.cloudstream3.utils.AppUtils.loadRepository
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.loadResult
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus
|
||||
import com.lagradost.cloudstream3.utils.BackupUtils.setUpBackup
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||
import com.lagradost.cloudstream3.utils.DataStore.getKey
|
||||
|
@ -511,9 +512,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
setPositiveButton(R.string.yes) { _, _ -> exitProcess(0) }
|
||||
setNegativeButton(R.string.no) { _, _ -> }
|
||||
}
|
||||
builder.show().also {
|
||||
it.getButton(DialogInterface.BUTTON_NEGATIVE).requestFocus()
|
||||
}
|
||||
builder.show().setDefaultFocus()
|
||||
}
|
||||
|
||||
private fun backPressed() {
|
||||
|
@ -706,7 +705,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
|
||||
setNegativeButton("Ok") { _, _ -> }
|
||||
}
|
||||
builder.show()
|
||||
builder.show().setDefaultFocus()
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.lagradost.cloudstream3.mvvm.logError
|
|||
import com.lagradost.cloudstream3.ui.player.DownloadFileGenerator
|
||||
import com.lagradost.cloudstream3.ui.player.GeneratorPlayer
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus
|
||||
import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE
|
||||
import com.lagradost.cloudstream3.utils.ExtractorUri
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||
|
@ -49,7 +50,7 @@ object DownloadButtonSetup {
|
|||
)
|
||||
.setPositiveButton(R.string.delete, dialogClickListener)
|
||||
.setNegativeButton(R.string.cancel, dialogClickListener)
|
||||
.show()
|
||||
.show().setDefaultFocus()
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
// ye you somehow fucked up formatting did you?
|
||||
|
|
|
@ -40,6 +40,7 @@ import kotlinx.android.synthetic.main.stream_input.*
|
|||
import android.text.format.Formatter.formatShortFileSize
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import com.lagradost.cloudstream3.mvvm.normalSafeApiCall
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
||||
import java.net.URI
|
||||
|
||||
|
||||
|
@ -178,7 +179,9 @@ class DownloadFragment : Fragment() {
|
|||
|
||||
download_list?.adapter = adapter
|
||||
download_list?.layoutManager = GridLayoutManager(context, 1)
|
||||
download_stream_button?.isGone = isTvSettings()
|
||||
|
||||
// Should be visible in emulator layout
|
||||
download_stream_button?.isGone = isTrueTvSettings()
|
||||
download_stream_button?.setOnClickListener {
|
||||
val dialog =
|
||||
Dialog(it.context ?: return@setOnClickListener, R.style.AlertDialogCustom)
|
||||
|
|
|
@ -51,6 +51,7 @@ import com.lagradost.cloudstream3.utils.AppUtils.loadResult
|
|||
import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.ownHide
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.ownShow
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||
import com.lagradost.cloudstream3.utils.DataStore.getKey
|
||||
import com.lagradost.cloudstream3.utils.DataStore.setKey
|
||||
|
@ -182,7 +183,7 @@ class HomeFragment : Fragment() {
|
|||
)
|
||||
.setPositiveButton(R.string.delete, dialogClickListener)
|
||||
.setNegativeButton(R.string.cancel, dialogClickListener)
|
||||
.show()
|
||||
.show().setDefaultFocus()
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
// ye you somehow fucked up formatting did you?
|
||||
|
|
|
@ -46,6 +46,7 @@ import com.lagradost.cloudstream3.ui.home.ParentItemAdapter
|
|||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.ownShow
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.main
|
||||
import com.lagradost.cloudstream3.utils.DataStore.getKey
|
||||
import com.lagradost.cloudstream3.utils.DataStore.setKey
|
||||
|
@ -395,7 +396,7 @@ class SearchFragment : Fragment() {
|
|||
)
|
||||
.setPositiveButton(R.string.sort_clear, dialogClickListener)
|
||||
.setNegativeButton(R.string.cancel, dialogClickListener)
|
||||
.show()
|
||||
.show().setDefaultFocus()
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
// ye you somehow fucked up formatting did you?
|
||||
|
|
|
@ -26,6 +26,7 @@ import com.lagradost.cloudstream3.ui.result.setText
|
|||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.downloadAllPluginsDialog
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.main
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
|
@ -107,7 +108,7 @@ class ExtensionsFragment : Fragment() {
|
|||
)
|
||||
.setPositiveButton(R.string.delete, dialogClickListener)
|
||||
.setNegativeButton(R.string.cancel, dialogClickListener)
|
||||
.show()
|
||||
.show().setDefaultFocus()
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appStri
|
|||
import com.lagradost.cloudstream3.ui.WebviewFragment
|
||||
import com.lagradost.cloudstream3.ui.result.ResultFragment
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
|
||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSettings
|
||||
import com.lagradost.cloudstream3.ui.settings.extensions.PluginsViewModel.Companion.downloadAll
|
||||
import com.lagradost.cloudstream3.ui.settings.extensions.RepositoryData
|
||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||
|
@ -88,7 +89,7 @@ object AppUtils {
|
|||
this?.show()
|
||||
Handler(Looper.getMainLooper()).postDelayed({
|
||||
this?.window?.setWindowAnimations(R.style.Animation_Design_BottomSheetDialog)
|
||||
},200)
|
||||
}, 200)
|
||||
}
|
||||
|
||||
//fun Context.deleteFavorite(data: SearchResponse) {
|
||||
|
@ -345,7 +346,7 @@ object AppUtils {
|
|||
|
||||
setNegativeButton(R.string.no) { _, _ -> }
|
||||
}
|
||||
builder.show()
|
||||
builder.show().setDefaultFocus()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -568,6 +569,17 @@ object AppUtils {
|
|||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the focus to the negative button when in TV and Emulator layout.
|
||||
**/
|
||||
fun AlertDialog.setDefaultFocus(buttonFocus: Int = DialogInterface.BUTTON_NEGATIVE) {
|
||||
if (!isTvSettings()) return
|
||||
this.getButton(buttonFocus).run {
|
||||
isFocusableInTouchMode = true
|
||||
requestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
// Copied from https://github.com/videolan/vlc-android/blob/master/application/vlc-android/src/org/videolan/vlc/util/FileUtils.kt
|
||||
@SuppressLint("Range")
|
||||
fun Context.getUri(data: Uri?): Uri? {
|
||||
|
|
|
@ -23,6 +23,7 @@ import okio.buffer
|
|||
import okio.sink
|
||||
import java.io.File
|
||||
import android.text.TextUtils
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus
|
||||
import java.io.BufferedReader
|
||||
import java.io.IOException
|
||||
import java.io.InputStreamReader
|
||||
|
@ -355,7 +356,7 @@ class InAppUpdater {
|
|||
}
|
||||
}
|
||||
}
|
||||
builder.show()
|
||||
builder.show().setDefaultFocus()
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue