mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
onCreate, onDestroy
This commit is contained in:
parent
100ff87b43
commit
7ef9b18e00
5 changed files with 36 additions and 1 deletions
|
@ -50,6 +50,7 @@ import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.OAuth2A
|
||||||
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.accountManagers
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.accountManagers
|
||||||
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appString
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appString
|
||||||
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appStringRepo
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appStringRepo
|
||||||
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.githubApi
|
||||||
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.inAppAuths
|
import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.inAppAuths
|
||||||
import com.lagradost.cloudstream3.ui.APIRepository
|
import com.lagradost.cloudstream3.ui.APIRepository
|
||||||
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO
|
import com.lagradost.cloudstream3.ui.download.DOWNLOAD_NAVIGATE_TO
|
||||||
|
@ -64,6 +65,8 @@ import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.loadCache
|
import com.lagradost.cloudstream3.utils.AppUtils.loadCache
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.loadRepository
|
import com.lagradost.cloudstream3.utils.AppUtils.loadRepository
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.loadResult
|
import com.lagradost.cloudstream3.utils.AppUtils.loadResult
|
||||||
|
import com.lagradost.cloudstream3.utils.BackupUtils.backupGithub
|
||||||
|
import com.lagradost.cloudstream3.utils.BackupUtils.restorePromptGithub
|
||||||
import com.lagradost.cloudstream3.utils.BackupUtils.setUpBackup
|
import com.lagradost.cloudstream3.utils.BackupUtils.setUpBackup
|
||||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||||
import com.lagradost.cloudstream3.utils.DataStore.getKey
|
import com.lagradost.cloudstream3.utils.DataStore.getKey
|
||||||
|
@ -399,8 +402,14 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
val broadcastIntent = Intent()
|
val broadcastIntent = Intent()
|
||||||
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
broadcastIntent.action = "restart_service"
|
broadcastIntent.action = "restart_service"
|
||||||
broadcastIntent.setClass(this, VideoDownloadRestartReceiver::class.java)
|
broadcastIntent.setClass(this, VideoDownloadRestartReceiver::class.java)
|
||||||
|
|
||||||
|
if (githubApi.getLatestLoginData() != null && settingsManager.getBoolean(getString(R.string.automatic_cloud_backups), false)) {
|
||||||
|
this@MainActivity.backupGithub()
|
||||||
|
}
|
||||||
|
|
||||||
this.sendBroadcast(broadcastIntent)
|
this.sendBroadcast(broadcastIntent)
|
||||||
afterPluginsLoadedEvent -= ::onAllPluginsLoaded
|
afterPluginsLoadedEvent -= ::onAllPluginsLoaded
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
|
@ -585,6 +594,10 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
|
||||||
initAll()
|
initAll()
|
||||||
// No duplicates (which can happen by registerMainAPI)
|
// No duplicates (which can happen by registerMainAPI)
|
||||||
apis = allProviders.distinctBy { it }
|
apis = allProviders.distinctBy { it }
|
||||||
|
|
||||||
|
if (githubApi.getLatestLoginData() != null && settingsManager.getBoolean(getString(R.string.automatic_cloud_backups), false)){
|
||||||
|
this@MainActivity.restorePromptGithub()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// val navView: BottomNavigationView = findViewById(R.id.nav_view)
|
// val navView: BottomNavigationView = findViewById(R.id.nav_view)
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.lagradost.cloudstream3.syncproviders.providers
|
package com.lagradost.cloudstream3.syncproviders.providers
|
||||||
|
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||||
|
@ -12,7 +13,9 @@ import com.lagradost.cloudstream3.syncproviders.InAppAuthAPIManager
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
import com.lagradost.cloudstream3.utils.AppUtils.toJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||||
|
import com.lagradost.cloudstream3.utils.BackupUtils.restorePromptGithub
|
||||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||||
|
import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread
|
||||||
import com.lagradost.nicehttp.RequestBodyTypes
|
import com.lagradost.nicehttp.RequestBodyTypes
|
||||||
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
||||||
import okhttp3.RequestBody.Companion.toRequestBody
|
import okhttp3.RequestBody.Companion.toRequestBody
|
||||||
|
@ -108,6 +111,11 @@ class GithubApi(index: Int) : InAppAuthAPIManager(index){
|
||||||
userAvatar = it.owner.userAvatar,
|
userAvatar = it.owner.userAvatar,
|
||||||
gistUrl = it.gistUrl
|
gistUrl = it.gistUrl
|
||||||
))
|
))
|
||||||
|
runOnMainThread {
|
||||||
|
FragmentActivity().restorePromptGithub()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPadd
|
||||||
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
|
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar
|
||||||
import com.lagradost.cloudstream3.utils.BackupUtils.backup
|
import com.lagradost.cloudstream3.utils.BackupUtils.backup
|
||||||
import com.lagradost.cloudstream3.utils.BackupUtils.restorePrompt
|
import com.lagradost.cloudstream3.utils.BackupUtils.restorePrompt
|
||||||
|
import com.lagradost.cloudstream3.utils.BackupUtils.restorePromptGithub
|
||||||
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
|
||||||
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
|
import com.lagradost.cloudstream3.utils.InAppUpdater.Companion.runAutoUpdate
|
||||||
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
|
||||||
|
@ -52,7 +53,7 @@ class SettingsUpdates : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
getPref(R.string.restore_key)?.setOnPreferenceClickListener {
|
getPref(R.string.restore_key)?.setOnPreferenceClickListener {
|
||||||
activity?.restorePrompt()
|
activity?.restorePromptGithub()
|
||||||
return@setOnPreferenceClickListener true
|
return@setOnPreferenceClickListener true
|
||||||
}
|
}
|
||||||
getPref(R.string.show_logcat_key)?.setOnPreferenceClickListener { pref ->
|
getPref(R.string.show_logcat_key)?.setOnPreferenceClickListener { pref ->
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
<string name="filter_sub_lang_key" translatable="false">filter_sub_lang_key</string>
|
<string name="filter_sub_lang_key" translatable="false">filter_sub_lang_key</string>
|
||||||
<string name="pref_filter_search_quality_key" translatable="false">pref_filter_search_quality_key</string>
|
<string name="pref_filter_search_quality_key" translatable="false">pref_filter_search_quality_key</string>
|
||||||
<string name="enable_nsfw_on_providers_key" translatable="false">enable_nsfw_on_providers_key</string>
|
<string name="enable_nsfw_on_providers_key" translatable="false">enable_nsfw_on_providers_key</string>
|
||||||
|
<string name="automatic_cloud_backups" translatable="false">automatic_cloud_backups</string>
|
||||||
|
|
||||||
<!-- FORMAT MIGHT TRANSLATE, WILL CAUSE CRASH IF APPLIED WRONG -->
|
<!-- FORMAT MIGHT TRANSLATE, WILL CAUSE CRASH IF APPLIED WRONG -->
|
||||||
<string name="extra_info_format" formatted="true" translatable="false">%d %s | %s</string>
|
<string name="extra_info_format" formatted="true" translatable="false">%d %s | %s</string>
|
||||||
|
@ -244,6 +245,10 @@
|
||||||
<string name="episode_sync_settings_des">Automatically sync your current episode progress</string>
|
<string name="episode_sync_settings_des">Automatically sync your current episode progress</string>
|
||||||
|
|
||||||
<string name="restore_settings">Restore data from backup</string>
|
<string name="restore_settings">Restore data from backup</string>
|
||||||
|
<string name="automatic_restore_settings">Automatic backup from Github</string>
|
||||||
|
|
||||||
|
<string name="cloud_backups_off">Cloud Backup deactivated</string>
|
||||||
|
<string name="cloud_backups_on">Cloud Backup enabled</string>
|
||||||
|
|
||||||
<string name="backup_settings">Backup data</string>
|
<string name="backup_settings">Backup data</string>
|
||||||
<string name="restore_success">Loaded backup file</string>
|
<string name="restore_success">Loaded backup file</string>
|
||||||
|
|
|
@ -17,6 +17,14 @@
|
||||||
android:key="@string/restore_key"
|
android:key="@string/restore_key"
|
||||||
android:title="@string/restore_settings" />
|
android:title="@string/restore_settings" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:icon="@drawable/baseline_restore_page_24"
|
||||||
|
android:key="@string/automatic_cloud_backups"
|
||||||
|
android:summaryOff="@string/cloud_backups_off"
|
||||||
|
android:summaryOn="@string/cloud_backups_on"
|
||||||
|
android:title="@string/automatic_restore_settings" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:icon="@drawable/baseline_description_24"
|
android:icon="@drawable/baseline_description_24"
|
||||||
android:key="@string/show_logcat_key"
|
android:key="@string/show_logcat_key"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue