add auto backup on permissions granted (#1632)

* add auto backup on permissions granted

* change to set and add logic to else

* no longer need counter

---------

Co-authored-by: Seishirou <Seishirou@sol-horizon.xyz>
This commit is contained in:
Seishirou-J2K 2023-10-12 00:08:36 -05:00 committed by GitHub
parent 2e7fbf2059
commit 60dd9716ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 2 deletions

View file

@ -246,7 +246,6 @@ class PreferencesHelper(val context: Context) {
fun numberOfBackups() = flowPrefs.getInt(Keys.numberOfBackups, 2)
fun backupInterval() = flowPrefs.getInt(Keys.backupInterval, 0)
fun removeAfterReadSlots() = flowPrefs.getInt(Keys.removeAfterReadSlots, -1)
fun removeAfterMarkedAsRead() = prefs.getBoolean(Keys.removeAfterMarkedAsRead, false)

View file

@ -39,7 +39,6 @@ class SettingsBackupController : SettingsController() {
* Flags containing information of what to backup.
*/
private var backupFlags = 0
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
requestFilePermissionsSafe(500, preferences)

View file

@ -46,6 +46,7 @@ import com.bluelinelabs.conductor.ControllerChangeType
import com.bluelinelabs.conductor.Router
import com.bluelinelabs.conductor.RouterTransaction
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.backup.BackupCreatorJob
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.databinding.MainActivityBinding
import eu.kanade.tachiyomi.ui.base.SmallToolbarInterface
@ -774,6 +775,9 @@ fun Controller.requestFilePermissionsSafe(
}
.setNegativeButton(android.R.string.cancel, null)
.show()
} else if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.R || Environment.isExternalStorageManager()) && preferences.backupInterval().isNotSet()) {
preferences.backupInterval().set(24)
BackupCreatorJob.setupTask(activity, 24)
}
}