-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO Scoped Storage: Sync before migration
* Adds optional continuation to `sync` which displays a notification if executed in the background * Adds a dialog box, triggered from the 'scoped storage' menu item Issue 5304
- Loading branch information
1 parent
c37dae5
commit 5c9861c
Showing
6 changed files
with
144 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
AnkiDroid/src/main/java/com/ichi2/anki/dialogs/AsyncOperation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright (c) 2023 David Allison <davidallisongithub@gmail.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License as published by the Free Software | ||
* Foundation; either version 3 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package com.ichi2.anki.dialogs | ||
|
||
import android.content.res.Resources | ||
import com.ichi2.anki.DeckPicker | ||
import com.ichi2.anki.R | ||
|
||
abstract class AsyncOperation { | ||
abstract val notificationMessage: String? | ||
abstract val notificationTitle: String | ||
abstract val handlerMessage: DialogHandlerMessage | ||
} | ||
|
||
/** | ||
* Called from [DeckPicker.showDialogThatOffersToMigrateStorage] | ||
*/ | ||
class MigrateStorageOnSyncSuccess(res: Resources) : AsyncOperation() { | ||
override val notificationMessage = res.getString(R.string.storage_migration_sync_notification) | ||
override val notificationTitle = res.getString(R.string.sync_database_acknowledge) | ||
|
||
override val handlerMessage: DialogHandlerMessage | ||
get() = MigrateOnSyncSuccessHandler() | ||
|
||
class MigrateOnSyncSuccessHandler : DialogHandlerMessage( | ||
which = WhichDialogHandler.MSG_MIGRATE_ON_SYNC_SUCCESS, | ||
analyticName = "SyncSuccessHandler" | ||
) { | ||
override fun handleAsyncMessage(deckPicker: DeckPicker) { | ||
deckPicker.migrate() | ||
} | ||
|
||
override fun toMessage() = emptyMessage(this.what) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters