mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Added safe mode file as a last resort
This commit is contained in:
parent
2771dcb612
commit
9905618a47
3 changed files with 25 additions and 4 deletions
|
@ -347,7 +347,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
}
|
||||
}
|
||||
|
||||
var lastPopup : SearchResponse? = null
|
||||
var lastPopup: SearchResponse? = null
|
||||
fun loadPopup(result: SearchResponse) {
|
||||
lastPopup = result
|
||||
viewModel.load(
|
||||
|
@ -716,7 +716,12 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
|||
|
||||
changeStatusBarState(isEmulatorSettings())
|
||||
|
||||
if (lastError == null) {
|
||||
|
||||
if (PluginManager.checkSafeModeFile()) {
|
||||
normalSafeApiCall {
|
||||
showToast(this, R.string.safe_mode_file, Toast.LENGTH_LONG)
|
||||
}
|
||||
} else if (lastError == null) {
|
||||
ioSafe {
|
||||
getKey<String>(USER_SELECTED_HOMEPAGE_API)?.let { homeApi ->
|
||||
mainPluginsLoadedEvent.invoke(loadSinglePlugin(this@MainActivity, homeApi))
|
||||
|
|
|
@ -144,8 +144,10 @@ object PluginManager {
|
|||
return getKey(PLUGINS_KEY_LOCAL) ?: emptyArray()
|
||||
}
|
||||
|
||||
private val LOCAL_PLUGINS_PATH =
|
||||
Environment.getExternalStorageDirectory().absolutePath + "/Cloudstream3/plugins"
|
||||
private val CLOUD_STREAM_FOLDER =
|
||||
Environment.getExternalStorageDirectory().absolutePath + "/Cloudstream3/"
|
||||
|
||||
private val LOCAL_PLUGINS_PATH = CLOUD_STREAM_FOLDER + "plugins"
|
||||
|
||||
public var currentlyLoading: String? = null
|
||||
|
||||
|
@ -421,6 +423,19 @@ object PluginManager {
|
|||
afterPluginsLoadedEvent.invoke(forceReload)
|
||||
}
|
||||
|
||||
/**
|
||||
* This can be used to override any extension loading to fix crashes!
|
||||
* @return true if safe mode file is present
|
||||
**/
|
||||
fun checkSafeModeFile(): Boolean {
|
||||
val folder = File(CLOUD_STREAM_FOLDER)
|
||||
if (!folder.exists()) return false
|
||||
val files = folder.listFiles { _, name ->
|
||||
name.equals("safe", ignoreCase = true)
|
||||
}
|
||||
return files?.any() ?: false
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if successful, false if not
|
||||
* */
|
||||
|
|
|
@ -630,4 +630,5 @@
|
|||
<string name="open_with">Open with</string>
|
||||
<string name="empty_library_no_accounts_message">Looks like your library is empty :(\nLogin to a library account or add shows to your local library</string>
|
||||
<string name="empty_library_logged_in_message">Looks like this list is empty, try switching to another one</string>
|
||||
<string name="safe_mode_file">Safe mode file found!\nNot loading any extensions on startup until file is removed.</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue