Fix merge issues

This commit is contained in:
CranberrySoup 2023-10-31 22:33:01 +01:00
parent 3bd7b95350
commit 6fc45f6180
6 changed files with 22 additions and 85 deletions

View file

@ -162,7 +162,7 @@ abstract class BackupAPI<LOGIN_DATA>(defIndex: Int) : IBackupAPI<LOGIN_DATA>,
return
}
val keysToUpdate = getKeysToUpdate(context.getBackup(), newData)
val keysToUpdate = getKeysToUpdate(getBackup(context), newData)
if (keysToUpdate.isEmpty()) {
Log.d(LOG_KEY, "remote data is up to date, sync not needed")
return
@ -267,7 +267,7 @@ abstract class BackupAPI<LOGIN_DATA>(defIndex: Int) : IBackupAPI<LOGIN_DATA>,
private fun shouldUploadBackup(): Boolean {
val ctx = AcraApplication.context ?: return false
val newBackup = ctx.getBackup().toJson()
val newBackup = getBackup(ctx).toJson()
return compareJson(lastBackupJson ?: "", newBackup).failed
}
@ -322,7 +322,7 @@ abstract class BackupAPI<LOGIN_DATA>(defIndex: Int) : IBackupAPI<LOGIN_DATA>,
return
}
val backupFile = context.getBackup().toJson()
val backupFile = getBackup(context).toJson()
lastBackupJson = backupFile
Log.d(LOG_KEY, "${this.name}: uploadFile is now running")
uploadFile(context, backupFile, loginData)

View file

@ -28,10 +28,6 @@ import com.lagradost.cloudstream3.APIHolder.apis
import com.lagradost.cloudstream3.APIHolder.filterProviderByPreferredMedia
import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings
import com.lagradost.cloudstream3.CommonActivity.showToast
import com.lagradost.cloudstream3.MainActivity.Companion.afterBackupRestoreEvent
import com.lagradost.cloudstream3.MainActivity.Companion.afterPluginsLoadedEvent
import com.lagradost.cloudstream3.MainActivity.Companion.bookmarksUpdatedEvent
import com.lagradost.cloudstream3.MainActivity.Companion.mainPluginsLoadedEvent
import com.lagradost.cloudstream3.databinding.FragmentHomeBinding
import com.lagradost.cloudstream3.databinding.HomeEpisodesExpandedBinding
import com.lagradost.cloudstream3.databinding.HomeSelectMainpageBinding
@ -42,7 +38,6 @@ import com.lagradost.cloudstream3.mvvm.observe
import com.lagradost.cloudstream3.mvvm.observeNullable
import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneApi
import com.lagradost.cloudstream3.ui.APIRepository.Companion.randomApi
import com.lagradost.cloudstream3.ui.WatchType
import com.lagradost.cloudstream3.ui.result.txt
import com.lagradost.cloudstream3.ui.search.*
import com.lagradost.cloudstream3.ui.search.SearchHelper.handleSearchClickCallback
@ -55,7 +50,6 @@ 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.DataStoreHelper
import com.lagradost.cloudstream3.utils.DataStoreHelper.currentHomePage
import com.lagradost.cloudstream3.utils.Event
import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso
import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe
@ -485,61 +479,6 @@ class HomeFragment : Fragment() {
fixGrid()
}
fun bookmarksUpdated(_data : Boolean) {
reloadStored()
}
override fun onResume() {
super.onResume()
reloadStored()
bookmarksUpdatedEvent += ::bookmarksUpdated
afterPluginsLoadedEvent += ::afterPluginsLoaded
mainPluginsLoadedEvent += ::afterMainPluginsLoaded
afterBackupRestoreEvent += ::reloadStored
}
override fun onStop() {
bookmarksUpdatedEvent -= ::bookmarksUpdated
afterPluginsLoadedEvent -= ::afterPluginsLoaded
mainPluginsLoadedEvent -= ::afterMainPluginsLoaded
afterBackupRestoreEvent -= ::reloadStored
super.onStop()
}
private fun reloadStored(unused: Unit = Unit) {
homeViewModel.reloadStored()
val list = EnumSet.noneOf(WatchType::class.java)
getKey<IntArray>(HOME_BOOKMARK_VALUE_LIST)?.map { WatchType.fromInternalId(it) }?.let {
list.addAll(it)
}
homeViewModel.loadStoredData(list)
}
private fun afterMainPluginsLoaded(unused: Boolean = false) {
loadHomePage(false)
}
private fun afterPluginsLoaded(forceReload: Boolean) {
loadHomePage(forceReload)
}
private fun loadHomePage(forceReload: Boolean) {
val apiName = currentHomePage
if (homeViewModel.apiName.value != apiName || apiName == null || forceReload) {
//println("Caught home: " + homeViewModel.apiName.value + " at " + apiName)
homeViewModel.loadAndCancel(apiName, forceReload)
}
}
private fun homeHandleSearch(callback: SearchClickCallback) {
if (callback.action == SEARCH_ACTION_FOCUSED) {
//focusCallback(callback.card)
} else {
handleSearchClickCallback(callback)
}
}
private var currentApiName: String? = null
private var toggleRandomButton = false

View file

@ -145,7 +145,8 @@ class LibraryFragment : Fragment() {
}
// Set the color for the search exit icon to the correct theme text color
val searchExitIcon = binding?.mainSearch?.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
val searchExitIcon =
binding?.mainSearch?.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
val searchExitIconColor = TypedValue()
activity?.theme?.resolveAttribute(android.R.attr.textColor, searchExitIconColor, true)
@ -481,6 +482,7 @@ class LibraryFragment : Fragment() {
}
})
}
override fun onConfigurationChanged(newConfig: Configuration) {
(binding?.viewpager?.adapter as? ViewpagerAdapter)?.rebind()
super.onConfigurationChanged(newConfig)
@ -499,6 +501,7 @@ class LibraryFragment : Fragment() {
private fun onNewSyncData(unused: Unit) {
Log.d(BackupAPI.LOG_KEY, "will reload pages")
libraryViewModel.reloadPages(true)
}
private val sortChangeClickListener = View.OnClickListener { view ->
val methods = libraryViewModel.sortingMethods.map {
@ -515,10 +518,10 @@ class LibraryFragment : Fragment() {
libraryViewModel.sort(method)
})
}
}
class MenuSearchView(context: Context) : SearchView(context) {
override fun onActionViewCollapsed() {
super.onActionViewCollapsed()
class MenuSearchView(context: Context) : SearchView(context) {
override fun onActionViewCollapsed() {
super.onActionViewCollapsed()
}
}
}

View file

@ -151,10 +151,8 @@ object BackupUtils {
}
@Suppress("UNCHECKED_CAST")
private fun getBackup(context: Context?): BackupFile? {
if (context == null) return null
val syncDataPrefs = getSyncPrefs().all.filter { it.key.isTransferable() }
fun getBackup(context: Context): BackupFile {
val syncDataPrefs = context.getSyncPrefs().all.filter { it.key.isTransferable() }
val allData = context.getSharedPrefs().all.filter { it.key.isTransferable() }
val allSettings = context.getDefaultSharedPrefs().all.filter { it.key.isTransferable() }
@ -216,9 +214,15 @@ object BackupUtils {
// we must remove keys that are not present
if (!restoreKeys.isNullOrEmpty()) {
Log.d(BackupAPI.LOG_KEY, "successfulRestore for src=[${restoreSource.name}]: ${restoreData.successfulRestore}")
Log.d(
BackupAPI.LOG_KEY,
"successfulRestore for src=[${restoreSource.name}]: ${restoreData.successfulRestore}"
)
val removedKeys = restoreData.wantToRestore - restoreData.successfulRestore
Log.d(BackupAPI.LOG_KEY, "removed keys for src=[${restoreSource.name}]: $removedKeys")
Log.d(
BackupAPI.LOG_KEY,
"removed keys for src=[${restoreSource.name}]: $removedKeys"
)
removedKeys.forEach { removeKeyRaw(it, restoreSource) }
}

View file

@ -7,9 +7,6 @@ import android.util.Log
import com.lagradost.cloudstream3.syncproviders.AccountManager
import com.lagradost.cloudstream3.syncproviders.BackupAPI
import com.lagradost.cloudstream3.syncproviders.BackupAPI.Companion.logHistoryChanged
import com.lagradost.cloudstream3.ui.home.HOME_BOOKMARK_VALUE_LIST
import com.lagradost.cloudstream3.ui.player.PLAYBACK_SPEED_KEY
import com.lagradost.cloudstream3.ui.player.RESIZE_MODE_KEY
import com.lagradost.cloudstream3.utils.BackupUtils.nonTransferableKeys
import com.lagradost.cloudstream3.utils.Coroutines.ioSafe
@ -27,9 +24,6 @@ class Scheduler<INPUT>(
*nonTransferableKeys.toTypedArray(),
VideoDownloadManager.KEY_DOWNLOAD_INFO,
DOWNLOAD_HEADER_CACHE,
PLAYBACK_SPEED_KEY,
HOME_BOOKMARK_VALUE_LIST,
RESIZE_MODE_KEY,
)
private val invalidUploadTriggerKeysRegex = listOf(
// These trigger automatically every time a show is opened, way too often.
@ -100,6 +94,7 @@ class Scheduler<INPUT>(
var lastValue = all
registerOnSharedPreferenceChangeListener { sharedPreferences, storeKey ->
if (storeKey == null) return@registerOnSharedPreferenceChangeListener
ioSafe {
scheduler.work(
BackupAPI.PreferencesSchedulerData(

View file

@ -696,8 +696,6 @@
<string name="qualities">Qualities</string>
<string name="profile_background_des">Profile background</string>
<string name="unable_to_inflate">UI was unable to be created correctly, this is a MAJOR BUG and should be reported immediately %s</string>
<string name="tv_no_focus_tag" translatable="false">tv_no_focus_tag</string>
<string name="already_voted">You have already voted</string>
<string name="example_login_file_name_full">Sync file name (optional)</string>
<string name="example_login_redirect_url_full">Oauth redirect url (optional)</string>
<string name="example_redirect_url" translatable="false">https://recloudstream.github.io/cloudstream-sync/google-drive</string>
@ -732,8 +730,6 @@
<string name="tv_no_focus_tag" translatable="false">tv_no_focus_tag</string>
<string name="enter_pin">Enter PIN</string>
<string name="enter_current_pin">Enter Current PIN</string>
<string name="lock_profile">Lock Profile</string>