diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/SourceDetailFragment.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/SourceDetailFragment.kt index 7f4ea091..c5f3d430 100644 --- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/SourceDetailFragment.kt +++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/SourceDetailFragment.kt @@ -397,23 +397,43 @@ class SourceDetailFragment : MainFragment() { UIDialogs.Action("Cancel", {}, UIDialogs.ActionStyle.NONE), UIDialogs.Action("Login", { LoginActivity.showLogin(StateApp.instance.context, config) { - StatePlugins.instance.setPluginAuth(config.id, it); - reloadSource(config.id); + try { + StatePlugins.instance.setPluginAuth(config.id, it); + reloadSource(config.id); + } catch (e: Throwable) { + StateApp.instance.scopeOrNull?.launch(Dispatchers.Main) { + context?.let { c -> UIDialogs.showGeneralErrorDialog(c, "Failed to set plugin authentication (loginSource, loginWarning)", e) } + } + Logger.e(TAG, "Failed to set plugin authentication (loginSource, loginWarning)", e) + } }; }, UIDialogs.ActionStyle.PRIMARY)) } else LoginActivity.showLogin(StateApp.instance.context, config) { - StatePlugins.instance.setPluginAuth(config.id, it); - reloadSource(config.id); + try { + StatePlugins.instance.setPluginAuth(config.id, it); + reloadSource(config.id); + } catch (e: Throwable) { + StateApp.instance.scopeOrNull?.launch(Dispatchers.Main) { + context?.let { c -> UIDialogs.showGeneralErrorDialog(c, "Failed to set plugin authentication (loginSource)", e) } + } + Logger.e(TAG, "Failed to set plugin authentication (loginSource)", e) + } }; } private fun logoutSource(clear: Boolean = true) { val config = _config ?: return; - StatePlugins.instance.setPluginAuth(config.id, null); - reloadSource(config.id); - + try { + StatePlugins.instance.setPluginAuth(config.id, null); + reloadSource(config.id); + } catch (e: Throwable) { + StateApp.instance.scopeOrNull?.launch(Dispatchers.Main) { + context?.let { c -> UIDialogs.showGeneralErrorDialog(c, "Failed to clear plugin authentication", e) } + } + Logger.e(TAG, "Failed to clear plugin authentication", e) + } //TODO: Maybe add a dialog option.. if(Settings.instance.plugins.clearCookiesOnLogout && clear) { diff --git a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt index 63b2f556..1530537b 100644 --- a/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt +++ b/app/src/main/java/com/futo/platformplayer/fragment/mainactivity/main/VideoDetailFragment.kt @@ -132,6 +132,8 @@ class VideoDetailFragment : MainFragment { a.requestedOrientation = currentOrientation } else if (currentOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || currentOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { a.requestedOrientation = currentOrientation + } else if (currentRequestedOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE || currentRequestedOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) { + //Don't change anything } else { a.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE } diff --git a/app/src/main/java/com/futo/platformplayer/states/StatePlugins.kt b/app/src/main/java/com/futo/platformplayer/states/StatePlugins.kt index 420a3721..71aa6d6f 100644 --- a/app/src/main/java/com/futo/platformplayer/states/StatePlugins.kt +++ b/app/src/main/java/com/futo/platformplayer/states/StatePlugins.kt @@ -10,6 +10,8 @@ import com.futo.platformplayer.api.media.platforms.js.SourceAuth import com.futo.platformplayer.api.media.platforms.js.SourceCaptchaData import com.futo.platformplayer.api.media.platforms.js.SourcePluginConfig import com.futo.platformplayer.api.media.platforms.js.SourcePluginDescriptor +import com.futo.platformplayer.fragment.mainactivity.main.SourceDetailFragment +import com.futo.platformplayer.fragment.mainactivity.main.SourceDetailFragment.Companion import com.futo.platformplayer.logging.Logger import com.futo.platformplayer.models.ImageVariable import com.futo.platformplayer.stores.FragmentedStorage @@ -128,7 +130,15 @@ class StatePlugins { return false; LoginActivity.showLogin(context, config) { - StatePlugins.instance.setPluginAuth(config.id, it); + try { + StatePlugins.instance.setPluginAuth(config.id, it); + } catch (e: Throwable) { + StateApp.instance.scopeOrNull?.launch(Dispatchers.Main) { + UIDialogs.showGeneralErrorDialog(context, "Failed to set plugin authentication (loginPlugin)", e) + } + Logger.e(SourceDetailFragment.TAG, "Failed to set plugin authentication (loginPlugin)", e) + return@showLogin + } StateApp.instance.scope.launch(Dispatchers.IO) { StatePlatform.instance.reloadClient(context, id);