forked from recloudstream/cloudstream
fuck android (((also fixes)))
This commit is contained in:
parent
ef91102daf
commit
486cea39c5
16 changed files with 248 additions and 229 deletions
|
@ -31,7 +31,7 @@
|
|||
<activity
|
||||
android:exported="true"
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|keyboard|keyboardHidden|navigation"
|
||||
android:label="@string/app_name"
|
||||
android:resizeableActivity="true"
|
||||
android:supportsPictureInPicture="true">
|
||||
|
|
|
@ -19,6 +19,7 @@ import androidx.annotation.StringRes
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.navigation.NavDestination
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
|
@ -87,6 +88,38 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
updateLocale() // android fucks me by chaining lang when rotating the phone
|
||||
findNavController(R.id.nav_host_fragment).currentDestination?.let { updateNavBar(it) }
|
||||
}
|
||||
|
||||
private fun updateNavBar(destination : NavDestination) {
|
||||
this.hideKeyboard()
|
||||
|
||||
// Fucks up anime info layout since that has its own layout
|
||||
cast_mini_controller_holder?.isVisible =
|
||||
!listOf(R.id.navigation_results, R.id.navigation_player).contains(destination.id)
|
||||
|
||||
val isNavVisible = listOf(
|
||||
R.id.navigation_home,
|
||||
R.id.navigation_search,
|
||||
R.id.navigation_downloads,
|
||||
R.id.navigation_settings,
|
||||
R.id.navigation_download_child
|
||||
).contains(destination.id)
|
||||
|
||||
val landscape = when(resources.configuration.orientation) {
|
||||
Configuration.ORIENTATION_LANDSCAPE -> {
|
||||
true
|
||||
}
|
||||
Configuration.ORIENTATION_PORTRAIT -> {
|
||||
false
|
||||
}
|
||||
else -> {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
nav_view?.isVisible = isNavVisible && !landscape
|
||||
nav_rail_view?.isVisible = isNavVisible && landscape
|
||||
}
|
||||
|
||||
//private var mCastSession: CastSession? = null
|
||||
|
@ -553,30 +586,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
val navRail = findViewById<NavigationRailView?>(R.id.nav_rail_view)
|
||||
navRail?.setupWithNavController(navController)
|
||||
navController.addOnDestinationChangedListener { _, destination, _ ->
|
||||
this.hideKeyboard()
|
||||
// nav_view.hideKeyboard()
|
||||
/*if (destination.id != R.id.navigation_player) {
|
||||
requestedOrientation = if (settingsManager?.getBoolean("force_landscape", false) == true) {
|
||||
ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
} else {
|
||||
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||
}
|
||||
}*/
|
||||
|
||||
// Fucks up anime info layout since that has its own layout
|
||||
cast_mini_controller_holder?.isVisible =
|
||||
!listOf(R.id.navigation_results, R.id.navigation_player).contains(destination.id)
|
||||
|
||||
val isNavVisible = listOf(
|
||||
R.id.navigation_home,
|
||||
R.id.navigation_search,
|
||||
R.id.navigation_downloads,
|
||||
R.id.navigation_settings,
|
||||
R.id.navigation_download_child
|
||||
).contains(destination.id)
|
||||
|
||||
nav_view?.isVisible = isNavVisible
|
||||
navRail?.isVisible = isNavVisible
|
||||
updateNavBar(destination)
|
||||
}
|
||||
|
||||
/*nav_view.setOnNavigationItemSelectedListener { item ->
|
||||
|
|
|
@ -30,6 +30,7 @@ import com.lagradost.cloudstream3.utils.CastHelper.awaitLinks
|
|||
import com.lagradost.cloudstream3.utils.CastHelper.getMediaInfo
|
||||
import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
import org.json.JSONObject
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
|
@ -156,7 +157,7 @@ class SelectSourceController(val view: ImageView, val activity: ControllerActivi
|
|||
}
|
||||
}
|
||||
}
|
||||
bottomSheetDialog.dismiss()
|
||||
bottomSheetDialog.dismissSafe(activity)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,9 +221,8 @@ class SelectSourceController(val view: ImageView, val activity: ControllerActivi
|
|||
}
|
||||
loadMirror(which)
|
||||
|
||||
bottomSheetDialog.dismiss()
|
||||
bottomSheetDialog.dismissSafe(activity)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.widget.Toast
|
|||
import androidx.appcompat.app.AlertDialog
|
||||
import com.lagradost.cloudstream3.MainActivity
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.mvvm.logError
|
||||
import com.lagradost.cloudstream3.ui.player.PlayerFragment
|
||||
import com.lagradost.cloudstream3.ui.player.UriData
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.getNameFull
|
||||
|
@ -34,6 +35,7 @@ object DownloadButtonSetup {
|
|||
}
|
||||
}
|
||||
|
||||
try {
|
||||
builder.setTitle(R.string.delete_file)
|
||||
.setMessage(
|
||||
ctx.getString(R.string.delete_message).format(
|
||||
|
@ -47,6 +49,10 @@ object DownloadButtonSetup {
|
|||
.setPositiveButton(R.string.delete, dialogClickListener)
|
||||
.setNegativeButton(R.string.cancel, dialogClickListener)
|
||||
.show()
|
||||
} catch (e : Exception) {
|
||||
logError(e)
|
||||
// ye you somehow fucked up formatting did you?
|
||||
}
|
||||
}
|
||||
}
|
||||
DOWNLOAD_ACTION_PAUSE_DOWNLOAD -> {
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.lagradost.cloudstream3.utils.DataStoreHelper.removeLastWatched
|
|||
import com.lagradost.cloudstream3.utils.DataStoreHelper.setResultWatchState
|
||||
import com.lagradost.cloudstream3.utils.Event
|
||||
import com.lagradost.cloudstream3.utils.HOMEPAGE_API
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbarView
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact
|
||||
|
@ -52,6 +53,7 @@ import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIcons
|
|||
import com.lagradost.cloudstream3.utils.UIHelper.popupMenuNoIconsAndNoStringRes
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||
import com.lagradost.cloudstream3.widget.CenterZoomLayoutManager
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.fragment_home.*
|
||||
import java.util.*
|
||||
|
||||
|
@ -72,7 +74,7 @@ class HomeFragment : Fragment() {
|
|||
val titleHolder = bottomSheetDialogBuilder.findViewById<FrameLayout>(R.id.home_expanded_drag_down)!!
|
||||
|
||||
titleHolder.setOnClickListener {
|
||||
bottomSheetDialogBuilder.dismiss()
|
||||
bottomSheetDialogBuilder.dismissSafe(this)
|
||||
}
|
||||
|
||||
// Span settings
|
||||
|
@ -81,7 +83,7 @@ class HomeFragment : Fragment() {
|
|||
recycle.adapter = SearchAdapter(item.list, recycle) { callback ->
|
||||
handleSearchClickCallback(this, callback)
|
||||
if (callback.action == SEARCH_ACTION_LOAD || callback.action == SEARCH_ACTION_PLAY_FILE) {
|
||||
bottomSheetDialogBuilder.dismiss()
|
||||
bottomSheetDialogBuilder.dismissSafe(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ import com.lagradost.cloudstream3.utils.DataStore.setKey
|
|||
import com.lagradost.cloudstream3.utils.DataStoreHelper.setLastWatched
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.getNavigationBarHeight
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.getStatusBarHeight
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||
|
@ -125,12 +126,12 @@ const val OPENING_PERCENTAGE = 50
|
|||
const val AUTOLOAD_NEXT_EPISODE_PERCENTAGE = 80
|
||||
|
||||
enum class PlayerEventType(val value: Int) {
|
||||
Stop(-1),
|
||||
//Stop(-1),
|
||||
Pause(0),
|
||||
Play(1),
|
||||
SeekForward(2),
|
||||
SeekBack(3),
|
||||
SkipCurrentChapter(4),
|
||||
//SkipCurrentChapter(4),
|
||||
NextEpisode(5),
|
||||
PrevEpisode(5),
|
||||
PlayPauseToggle(7),
|
||||
|
@ -1189,11 +1190,11 @@ class PlayerFragment : Fragment() {
|
|||
listOf(0.5f, 0.75f, 0.85f, 1f, 1.15f, 1.25f, 1.4f, 1.5f, 1.75f, 2f)
|
||||
val speedIndex = speedsNumbers.indexOf(playbackSpeed)
|
||||
|
||||
context?.let { ctx ->
|
||||
ctx.showDialog(
|
||||
activity?.let { act ->
|
||||
act.showDialog(
|
||||
speedsText,
|
||||
speedIndex,
|
||||
ctx.getString(R.string.player_speed),
|
||||
act.getString(R.string.player_speed),
|
||||
false,
|
||||
{
|
||||
activity?.hideSystemUI()
|
||||
|
@ -1236,7 +1237,7 @@ class PlayerFragment : Fragment() {
|
|||
autoHide()
|
||||
saveArguments()
|
||||
SubtitlesFragment.push(activity)
|
||||
sourceDialog.dismiss()
|
||||
sourceDialog.dismissSafe(activity)
|
||||
}
|
||||
var sourceIndex = 0
|
||||
var startSource = 0
|
||||
|
@ -1297,7 +1298,7 @@ class PlayerFragment : Fragment() {
|
|||
}
|
||||
|
||||
cancelButton.setOnClickListener {
|
||||
sourceDialog.dismiss()
|
||||
sourceDialog.dismissSafe(activity)
|
||||
}
|
||||
|
||||
applyButton.setOnClickListener {
|
||||
|
@ -1324,7 +1325,7 @@ class PlayerFragment : Fragment() {
|
|||
if (init) {
|
||||
initPlayer(getCurrentUrl())
|
||||
}
|
||||
sourceDialog.dismiss()
|
||||
sourceDialog.dismissSafe(activity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1796,12 +1797,16 @@ class PlayerFragment : Fragment() {
|
|||
}
|
||||
|
||||
private fun getCurrentUrl(): ExtractorLink? {
|
||||
try {
|
||||
val urls = getUrls() ?: return null
|
||||
for (i in urls) {
|
||||
if (i.getId() == playerData.mirrorId) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
} catch (e : Exception) {
|
||||
return null
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
@ -2189,11 +2194,11 @@ class PlayerFragment : Fragment() {
|
|||
setUpstreamDataSourceFactory(getDataSourceFactory())
|
||||
}
|
||||
|
||||
val _exoPlayer =
|
||||
val exoPlayerBuilder =
|
||||
ExoPlayer.Builder(requireContext())
|
||||
.setTrackSelector(trackSelector)
|
||||
|
||||
exoPlayer = _exoPlayer.build().apply {
|
||||
exoPlayer = exoPlayerBuilder.build().apply {
|
||||
playWhenReady = isPlayerPlaying
|
||||
seekTo(currentWindow, playbackPosition)
|
||||
setMediaSource(
|
||||
|
|
|
@ -61,6 +61,7 @@ import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos
|
|||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.checkWrite
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.navigate
|
||||
|
@ -393,7 +394,7 @@ class ResultFragment : Fragment() {
|
|||
|
||||
val data = viewModel.loadEpisode(episodeClick.data, isCasting)
|
||||
if (currentLoadingCount != currentLoad) return false
|
||||
loadingDialog?.dismiss()
|
||||
loadingDialog?.dismissSafe(activity)
|
||||
|
||||
when (data) {
|
||||
is Resource.Success -> {
|
||||
|
@ -627,7 +628,7 @@ class ResultFragment : Fragment() {
|
|||
verifiedOptions.toTypedArray()
|
||||
) { _, which ->
|
||||
handleAction(EpisodeClickEvent(verifiedOptionsValues[which], episodeClick.data))
|
||||
dialog?.dismiss()
|
||||
dialog?.dismissSafe(activity)
|
||||
}
|
||||
|
||||
dialog = builder.create()
|
||||
|
@ -636,6 +637,7 @@ class ResultFragment : Fragment() {
|
|||
}
|
||||
ACTION_COPY_LINK -> {
|
||||
activity?.let { act ->
|
||||
try {
|
||||
acquireSingeExtractorLink(act.getString(R.string.episode_action_copy_link)) { link ->
|
||||
val serviceClipboard =
|
||||
(act.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager?)
|
||||
|
@ -644,6 +646,10 @@ class ResultFragment : Fragment() {
|
|||
serviceClipboard.setPrimaryClip(clip)
|
||||
showToast(act, R.string.copy_link_toast, Toast.LENGTH_SHORT)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
showToast(act, e.toString(), Toast.LENGTH_LONG)
|
||||
logError(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -668,6 +674,7 @@ class ResultFragment : Fragment() {
|
|||
|
||||
ACTION_PLAY_EPISODE_IN_VLC_PLAYER -> {
|
||||
activity?.let { act ->
|
||||
try {
|
||||
if (!act.checkWrite()) {
|
||||
act.requestRW()
|
||||
if (act.checkWrite()) return@main
|
||||
|
@ -720,6 +727,10 @@ class ResultFragment : Fragment() {
|
|||
vlcIntent.component = VLC_COMPONENT
|
||||
act.setKey(VLC_LAST_ID_KEY, episodeClick.data.id)
|
||||
act.startActivityForResult(vlcIntent, VLC_REQUEST_CODE)
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
showToast(act, e.toString(), Toast.LENGTH_LONG)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -786,7 +797,7 @@ class ResultFragment : Fragment() {
|
|||
result_bookmark_button?.text = getString(watchType.stringRes)
|
||||
result_bookmark_fab?.text = getString(watchType.stringRes)
|
||||
|
||||
if(watchType == WatchType.NONE) {
|
||||
if (watchType == WatchType.NONE) {
|
||||
result_bookmark_fab?.context?.colorFromAttribute(R.attr.white)
|
||||
} else {
|
||||
result_bookmark_fab?.context?.colorFromAttribute(R.attr.colorPrimary)
|
||||
|
@ -797,7 +808,7 @@ class ResultFragment : Fragment() {
|
|||
}
|
||||
|
||||
result_bookmark_fab?.setOnClickListener { fab ->
|
||||
fab.context.showBottomDialog(
|
||||
activity?.showBottomDialog(
|
||||
WatchType.values().map { fab.context.getString(it.stringRes) }.toList(),
|
||||
watchType.ordinal,
|
||||
fab.context.getString(R.string.action_add_to_bookmarks),
|
||||
|
|
|
@ -449,6 +449,7 @@ class ResultViewModel : ViewModel() {
|
|||
data: String,
|
||||
isCasting: Boolean,
|
||||
): Resource<EpisodeData> {
|
||||
println("LOAD EPISODE FFS")
|
||||
if (_allEpisodes.value?.contains(id) == true) {
|
||||
_allEpisodes.value?.remove(id)
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTvSet
|
|||
import com.lagradost.cloudstream3.utils.DataStore.getKey
|
||||
import com.lagradost.cloudstream3.utils.DataStore.setKey
|
||||
import com.lagradost.cloudstream3.utils.SEARCH_PROVIDER_TOGGLE
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||
|
@ -255,11 +256,11 @@ class SearchFragment : Fragment() {
|
|||
providersActive = activeApis
|
||||
typesActive = activeTypes
|
||||
|
||||
dialog.dismiss()
|
||||
dialog.dismissSafe(activity)
|
||||
}
|
||||
|
||||
cancelButton.setOnClickListener {
|
||||
dialog.dismiss()
|
||||
dialog.dismissSafe(activity)
|
||||
}
|
||||
|
||||
//listView.setSelection(selectedIndex)
|
||||
|
|
|
@ -45,6 +45,7 @@ import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog
|
|||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog
|
||||
import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog
|
||||
import com.lagradost.cloudstream3.utils.SubtitleHelper
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.setImage
|
||||
import com.lagradost.cloudstream3.utils.VideoDownloadManager.getBasePath
|
||||
|
@ -147,7 +148,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
}
|
||||
api.accountIndex = ogIndex
|
||||
val adapter = AccountAdapter(items, R.layout.account_single) {
|
||||
dialog?.dismiss()
|
||||
dialog?.dismissSafe(activity)
|
||||
api.changeAccount(it.view.context, it.card.accountIndex)
|
||||
}
|
||||
val list = dialog.findViewById<RecyclerView>(R.id.account_list)
|
||||
|
@ -163,14 +164,14 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
dialog.findViewById<TextView>(R.id.account_logout)?.setOnClickListener {
|
||||
it.context?.let { ctx ->
|
||||
api.logOut(ctx)
|
||||
dialog.dismiss()
|
||||
dialog.dismissSafe(activity)
|
||||
}
|
||||
}
|
||||
|
||||
dialog.findViewById<TextView>(R.id.account_name)?.text = info.name ?: context.getString(R.string.no_data)
|
||||
dialog.findViewById<TextView>(R.id.account_site)?.text = api.name
|
||||
dialog.findViewById<TextView>(R.id.account_switch_account)?.setOnClickListener {
|
||||
dialog.dismiss()
|
||||
dialog.dismissSafe(activity)
|
||||
showAccountSwitch(it.context, api)
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +179,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
hideKeyboard()
|
||||
setPreferencesFromResource(R.xml.settings, rootKey)
|
||||
|
||||
val updatePreference = findPreference<Preference>(getString(R.string.manual_check_update_key))!!
|
||||
val localePreference = findPreference<Preference>(getString(R.string.locale_key))!!
|
||||
val benenePreference = findPreference<Preference>(getString(R.string.benene_count))!!
|
||||
|
@ -191,6 +193,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
val colorPrimaryPreference = findPreference<Preference>(getString(R.string.primary_color_key))!!
|
||||
val preferedMediaTypePreference = findPreference<Preference>(getString(R.string.prefer_media_type_key))!!
|
||||
val appThemePreference = findPreference<Preference>(getString(R.string.app_theme_key))!!
|
||||
val subPreference = findPreference<Preference>(getString(R.string.subtitle_settings_key))!!
|
||||
|
||||
subPreference.setOnPreferenceClickListener {
|
||||
SubtitlesFragment.push(activity, false)
|
||||
return@setOnPreferenceClickListener true
|
||||
}
|
||||
|
||||
val syncApis = listOf(Pair(R.string.mal_key, malApi), Pair(R.string.anilist_key, aniListApi))
|
||||
for (sync in syncApis) {
|
||||
|
@ -233,7 +241,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
currentList.add(dublist.indexOf(i))
|
||||
}
|
||||
|
||||
context?.showMultiDialog(
|
||||
activity?.showMultiDialog(
|
||||
names,
|
||||
currentList,
|
||||
getString(R.string.display_subbed_dubbed_settings),
|
||||
|
@ -276,7 +284,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
Pair(it, fullName)
|
||||
}
|
||||
|
||||
context?.showMultiDialog(
|
||||
activity?.showMultiDialog(
|
||||
names.map { it.second },
|
||||
currentList,
|
||||
getString(R.string.provider_lang_settings),
|
||||
|
@ -299,12 +307,16 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
// DOES NOT WORK ON SCOPED STORAGE.
|
||||
val secondaryDir = if (isScopedStorage) null else Environment.getExternalStorageDirectory().absolutePath +
|
||||
File.separator + resources.getString(R.string.app_name_download_path)
|
||||
|
||||
val first = listOf(defaultDir, secondaryDir)
|
||||
return (try {
|
||||
val currentDir = context?.getBasePath()?.let { it.first?.filePath ?: it.second }
|
||||
|
||||
return (listOf(defaultDir, secondaryDir) +
|
||||
(first +
|
||||
requireContext().getExternalFilesDirs("").mapNotNull { it.path } +
|
||||
currentDir).filterNotNull().distinct()
|
||||
currentDir)
|
||||
} catch (e: Exception) {
|
||||
first
|
||||
}).filterNotNull().distinct()
|
||||
}
|
||||
|
||||
downloadPathPreference.setOnPreferenceClickListener {
|
||||
|
@ -314,7 +326,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
val currentDir =
|
||||
settingsManager.getString(getString(R.string.download_path_pref), null) ?: getDownloadDir().toString()
|
||||
|
||||
context?.showBottomDialog(
|
||||
activity?.showBottomDialog(
|
||||
dirs + listOf("Custom"),
|
||||
dirs.indexOf(currentDir),
|
||||
getString(R.string.download_path_pref),
|
||||
|
@ -342,7 +354,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
val currentPrefMedia =
|
||||
settingsManager.getInt(getString(R.string.preferred_media_settings), 0)
|
||||
|
||||
context?.showBottomDialog(
|
||||
activity?.showBottomDialog(
|
||||
prefNames.toList(),
|
||||
prefValues.indexOf(currentPrefMedia),
|
||||
getString(R.string.preferred_media_settings),
|
||||
|
@ -352,7 +364,11 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
.putInt(getString(R.string.preferred_media_settings), prefValues[it])
|
||||
.apply()
|
||||
val apilist = AppUtils.filterProviderByPreferredMedia(apis, prefValues[it])
|
||||
val apiRandom = if (apilist.size > 0) { apilist.random().name } else { "" }
|
||||
val apiRandom = if (apilist.size > 0) {
|
||||
apilist.random().name
|
||||
} else {
|
||||
""
|
||||
}
|
||||
context?.setKey(HOMEPAGE_API, apiRandom)
|
||||
(context ?: AcraApplication.context)?.let { ctx -> app.initClient(ctx) }
|
||||
}
|
||||
|
@ -366,7 +382,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
val currentLayout =
|
||||
settingsManager.getInt(getString(R.string.app_layout_key), -1)
|
||||
context?.showBottomDialog(
|
||||
|
||||
activity?.showBottomDialog(
|
||||
prefNames.toList(),
|
||||
prefValues.indexOf(currentLayout),
|
||||
getString(R.string.app_layout),
|
||||
|
@ -390,7 +407,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
val currentLayout =
|
||||
settingsManager.getString(getString(R.string.primary_color_key), prefValues.first())
|
||||
context?.showBottomDialog(
|
||||
|
||||
activity?.showBottomDialog(
|
||||
prefNames.toList(),
|
||||
prefValues.indexOf(currentLayout),
|
||||
getString(R.string.primary_color_settings),
|
||||
|
@ -414,7 +432,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
val currentLayout =
|
||||
settingsManager.getString(getString(R.string.app_theme_key), prefValues.first())
|
||||
context?.showBottomDialog(
|
||||
|
||||
activity?.showBottomDialog(
|
||||
prefNames.toList(),
|
||||
prefValues.indexOf(currentLayout),
|
||||
getString(R.string.app_theme_settings),
|
||||
|
@ -441,7 +460,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
getString(R.string.watch_quality_pref),
|
||||
Qualities.values().last().value
|
||||
)
|
||||
context?.showBottomDialog(
|
||||
|
||||
activity?.showBottomDialog(
|
||||
prefNames.toList(),
|
||||
prefValues.indexOf(currentQuality),
|
||||
getString(R.string.watch_quality_pref),
|
||||
|
@ -460,7 +480,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
val currentDns =
|
||||
settingsManager.getInt(getString(R.string.dns_pref), 0)
|
||||
context?.showBottomDialog(
|
||||
|
||||
activity?.showBottomDialog(
|
||||
prefNames.toList(),
|
||||
prefValues.indexOf(currentDns),
|
||||
getString(R.string.dns_pref),
|
||||
|
@ -481,6 +502,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
if (beneneCount <= 0) getString(R.string.benene_count_text_none) else getString(R.string.benene_count_text).format(
|
||||
beneneCount
|
||||
)
|
||||
|
||||
benenePreference.setOnPreferenceClickListener {
|
||||
try {
|
||||
beneneCount++
|
||||
|
@ -516,7 +538,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
val languageCodes = tempLangs.map { it.third }
|
||||
val languageNames = tempLangs.map { "${it.first} ${it.second}" }
|
||||
val index = languageCodes.indexOf(current)
|
||||
pref?.context?.showDialog(
|
||||
|
||||
activity?.showDialog(
|
||||
languageNames, index, getString(R.string.app_language), true, { }
|
||||
) { languageIndex ->
|
||||
try {
|
||||
|
@ -540,13 +563,4 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
val conf = res.configuration
|
||||
return conf?.locale?.language ?: "en"
|
||||
}
|
||||
|
||||
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
||||
if (preference != null) {
|
||||
if (preference.key == getString(R.string.subtitle_settings_key)) {
|
||||
SubtitlesFragment.push(activity, false)
|
||||
}
|
||||
}
|
||||
return super.onPreferenceTreeClick(preference)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ class SubtitlesFragment : Fragment() {
|
|||
)
|
||||
|
||||
//showBottomDialog
|
||||
textView.context.showDialog(
|
||||
activity?.showDialog(
|
||||
elevationTypes.map { it.second },
|
||||
elevationTypes.map { it.first }.indexOf(state.elevation),
|
||||
(textView as TextView).text.toString(),
|
||||
|
@ -263,7 +263,7 @@ class SubtitlesFragment : Fragment() {
|
|||
)
|
||||
|
||||
//showBottomDialog
|
||||
textView.context.showDialog(
|
||||
activity?.showDialog(
|
||||
edgeTypes.map { it.second },
|
||||
edgeTypes.map { it.first }.indexOf(state.edgeType),
|
||||
(textView as TextView).text.toString(),
|
||||
|
@ -314,7 +314,7 @@ class SubtitlesFragment : Fragment() {
|
|||
)
|
||||
|
||||
//showBottomDialog
|
||||
textView.context.showDialog(
|
||||
activity?.showDialog(
|
||||
fontSizes.map { it.second },
|
||||
fontSizes.map { it.first }.indexOf(state.fixedTextSize),
|
||||
(textView as TextView).text.toString(),
|
||||
|
@ -353,7 +353,7 @@ class SubtitlesFragment : Fragment() {
|
|||
)
|
||||
|
||||
//showBottomDialog
|
||||
textView.context.showDialog(
|
||||
activity?.showDialog(
|
||||
fontTypes.map { it.second },
|
||||
fontTypes.map { it.first }.indexOf(state.typeface),
|
||||
(textView as TextView).text.toString(),
|
||||
|
@ -379,7 +379,7 @@ class SubtitlesFragment : Fragment() {
|
|||
langMap.addAll(SubtitleHelper.languages)
|
||||
|
||||
val lang639_1 = langMap.map { it.ISO_639_1 }
|
||||
textView.context.showDialog(
|
||||
activity?.showDialog(
|
||||
langMap.map { it.languageName },
|
||||
lang639_1.indexOf(textView.context.getAutoSelectLanguageISO639_1()),
|
||||
(textView as TextView).text.toString(),
|
||||
|
@ -402,7 +402,7 @@ class SubtitlesFragment : Fragment() {
|
|||
val keys = textView.context.getDownloadSubsLanguageISO639_1()
|
||||
val keyMap = keys.map { lang639_1.indexOf(it) }.filter { it >= 0 }
|
||||
|
||||
textView.context.showMultiDialog(
|
||||
activity?.showMultiDialog(
|
||||
langMap.map { it.languageName },
|
||||
keyMap,
|
||||
(textView as TextView).text.toString(),
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.lagradost.cloudstream3.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.widget.*
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.view.isVisible
|
||||
|
@ -10,9 +10,10 @@ import androidx.core.view.marginRight
|
|||
import androidx.core.view.marginTop
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.lagradost.cloudstream3.R
|
||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||
|
||||
object SingleSelectionHelper {
|
||||
fun Context.showDialog(
|
||||
fun Activity.showDialog(
|
||||
dialog: Dialog,
|
||||
items: List<String>,
|
||||
selectedIndex: List<Int>,
|
||||
|
@ -70,7 +71,7 @@ object SingleSelectionHelper {
|
|||
}
|
||||
} else {
|
||||
callback.invoke(listOf(which))
|
||||
dialog.dismiss()
|
||||
dialog.dismissSafe(this)
|
||||
}
|
||||
}
|
||||
if (realShowApply) {
|
||||
|
@ -81,15 +82,15 @@ object SingleSelectionHelper {
|
|||
list.add(index)
|
||||
}
|
||||
callback.invoke(list)
|
||||
dialog.dismiss()
|
||||
dialog.dismissSafe(this)
|
||||
}
|
||||
cancelButton.setOnClickListener {
|
||||
dialog.dismiss()
|
||||
dialog.dismissSafe(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.showMultiDialog(
|
||||
fun Activity.showMultiDialog(
|
||||
items: List<String>,
|
||||
selectedIndex: List<Int>,
|
||||
name: String,
|
||||
|
@ -104,7 +105,7 @@ object SingleSelectionHelper {
|
|||
showDialog(dialog, items, selectedIndex, name, true, true, callback, dismissCallback)
|
||||
}
|
||||
|
||||
fun Context.showDialog(
|
||||
fun Activity.showDialog(
|
||||
items: List<String>,
|
||||
selectedIndex: Int,
|
||||
name: String,
|
||||
|
@ -130,7 +131,7 @@ object SingleSelectionHelper {
|
|||
}
|
||||
|
||||
/** Only for a low amount of items */
|
||||
fun Context.showBottomDialog(
|
||||
fun Activity.showBottomDialog(
|
||||
items: List<String>,
|
||||
selectedIndex: Int,
|
||||
name: String,
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.Manifest
|
|||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.app.AppOpsManager
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.pm.PackageManager
|
||||
import android.content.res.Resources
|
||||
|
@ -293,8 +294,13 @@ object UIHelper {
|
|||
}
|
||||
|
||||
fun Context.shouldShowPIPMode(isInPlayer: Boolean): Boolean {
|
||||
return try {
|
||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
return settingsManager?.getBoolean("pip_enabled", true) ?: true && isInPlayer
|
||||
settingsManager?.getBoolean(getString(R.string.pip_enabled_key), true) ?: true && isInPlayer
|
||||
} catch (e : Exception) {
|
||||
logError(e)
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
|
@ -319,6 +325,12 @@ object UIHelper {
|
|||
inputMethodManager?.showSoftInput(view, 0)
|
||||
}
|
||||
|
||||
fun Dialog?.dismissSafe(activity: Activity?) {
|
||||
if (this?.isShowing == true && activity?.isFinishing == false) {
|
||||
this.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
/**id, stringRes */
|
||||
@SuppressLint("RestrictedApi")
|
||||
fun View.popupMenuNoIcons(
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/homeRoot"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden|keyboard|navigation"
|
||||
android:paddingTop="0dp">
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent">
|
||||
<com.google.android.material.navigationrail.NavigationRailView
|
||||
android:layout_width="62dp"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/nav_rail_view"
|
||||
android:background="?attr/primaryGrayBackground"
|
||||
app:itemTextColor="@color/item_select_color"
|
||||
app:itemIconTint="@color/item_select_color"
|
||||
app:menuGravity="center"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:labelVisibilityMode="unlabeled"
|
||||
app:menu="@menu/bottom_nav_menu">
|
||||
|
||||
</com.google.android.material.navigationrail.NavigationRailView>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintLeft_toRightOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/cast_mini_controller_holder"
|
||||
app:navGraph="@navigation/mobile_navigation"
|
||||
app:layout_constraintStart_toEndOf="@id/nav_rail_view"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
<LinearLayout
|
||||
app:layout_constraintStart_toEndOf="@+id/nav_rail_view"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
tools:layout_height="100dp"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/cast_mini_controller_holder"
|
||||
>
|
||||
<!--com.google.android.gms.cast.framework.media.widget.MiniControllerFragment-->
|
||||
<fragment
|
||||
app:customCastBackgroundColor="?attr/primaryGrayBackground"
|
||||
app:castControlButtons="@array/cast_mini_controller_control_buttons"
|
||||
android:id="@+id/cast_mini_controller"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
class="com.lagradost.cloudstream3.ui.MyMiniControllerFragment"
|
||||
tools:ignore="FragmentTagUsage">
|
||||
</fragment>
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</FrameLayout>
|
|
@ -11,6 +11,22 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent">
|
||||
<com.google.android.material.navigationrail.NavigationRailView
|
||||
android:layout_width="62dp"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/nav_rail_view"
|
||||
android:background="?attr/primaryGrayBackground"
|
||||
app:itemTextColor="@color/item_select_color"
|
||||
app:itemIconTint="@color/item_select_color"
|
||||
app:menuGravity="center"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:labelVisibilityMode="unlabeled"
|
||||
app:menu="@menu/bottom_nav_menu">
|
||||
|
||||
</com.google.android.material.navigationrail.NavigationRailView>
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/nav_view"
|
||||
android:layout_width="0dp"
|
||||
|
@ -28,17 +44,20 @@
|
|||
<fragment
|
||||
android:id="@+id/nav_host_fragment"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/mobile_navigation"
|
||||
app:layout_constraintStart_toEndOf="@+id/nav_rail_view"
|
||||
app:layout_constraintBottom_toTopOf="@+id/cast_mini_controller_holder"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:navGraph="@navigation/mobile_navigation"
|
||||
app:layout_constraintEnd_toEndOf="parent"/>
|
||||
<LinearLayout
|
||||
tools:layout_height="100dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_width="0dp"
|
||||
app:layout_constraintStart_toEndOf="@+id/nav_rail_view"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/nav_view"
|
||||
android:id="@+id/cast_mini_controller_holder"
|
||||
>
|
||||
|
|
|
@ -140,7 +140,7 @@
|
|||
<string name="delete">Verwijderen</string>
|
||||
<string name="pause">Pauze</string>
|
||||
<string name="resume">Hervat</string>
|
||||
<string name="delete_message">Dit wordt zeker permanent verwijderd %a\Weet u het zeker?</string>
|
||||
<string name="delete_message">Dit wordt zeker permanent verwijderd %s\nWeet u het zeker?</string>
|
||||
|
||||
<string name="status_ongoing">Lopend</string>
|
||||
<string name="status_completed">Voltooid</string>
|
||||
|
|
Loading…
Reference in a new issue