File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,11 +21,11 @@ import kotlinx.coroutines.Dispatchers
2121import kotlinx.coroutines.delay
2222import kotlinx.coroutines.withContext
2323
24- suspend fun performBackupInBackground () {
24+ suspend fun performBackupInBackground (force : Boolean = false ) {
2525 // Wait a second to allow the deck list to finish loading first, or it
2626 // will hang until the first stage of the backup completes.
2727 delay(1000 )
28- createBackup(force = false )
28+ createBackup(force = force )
2929}
3030
3131fun <Activity > Activity.importColpkg (colpkgPath : String ) where Activity : AnkiActivity, Activity : ImportColpkgListener {
Original file line number Diff line number Diff line change @@ -1392,10 +1392,24 @@ open class DeckPicker :
13921392 ExportDialogFragment .newInstance().show(supportFragmentManager, " exportDialog" )
13931393 return true
13941394 }
1395+ R .id.action_create_backup -> {
1396+ Timber .i(" DeckPicker::Create backup" )
1397+ createBackup()
1398+ return true
1399+ }
13951400 else -> return super .onOptionsItemSelected(item)
13961401 }
13971402 }
13981403
1404+ private fun createBackup () {
1405+ launchCatchingTask {
1406+ withProgress(message = TR .profilesCreatingBackup()) {
1407+ performBackupInBackground(true )
1408+ }
1409+ showThemedToast(this @DeckPicker, TR .profilesBackupCreated(), false )
1410+ }
1411+ }
1412+
13991413 private fun showMediaCheckDialog () {
14001414 Timber .i(" showing media check dialog" )
14011415 AlertDialog .Builder (this ).show {
@@ -1564,7 +1578,11 @@ open class DeckPicker :
15641578 return true
15651579 }
15661580 KeyEvent .KEYCODE_B -> {
1567- if (event.isCtrlPressed) {
1581+ if (event.isShiftPressed && event.isCtrlPressed) {
1582+ // shortcut SHIFT + CTRL + B
1583+ Timber .i(" Create backup from keypress" )
1584+ createBackup()
1585+ } else if (event.isCtrlPressed) {
15681586 // Shortcut: CTRL + B
15691587 Timber .i(" show restore backup dialog from keypress" )
15701588 showDatabaseErrorDialog(DatabaseErrorDialogType .DIALOG_CONFIRM_RESTORE_BACKUP )
Original file line number Diff line number Diff line change 4949 android : title =" @string/empty_cards" />
5050 </menu >
5151 </item >
52+ <!-- Backend string TR.qtAccelCreateBackup() has an & in it -->
53+ <item
54+ android : id =" @+id/action_create_backup"
55+ android : menuCategory =" secondary"
56+ android : title =" @string/menu_create_backup"
57+ />
5258 <item
5359 android : id =" @+id/action_restore_backup"
5460 android : menuCategory =" secondary"
Original file line number Diff line number Diff line change 3939 android : title =" @string/empty_cards" />
4040 </menu >
4141 </item >
42+ <!-- Backend string TR.qtAccelCreateBackup() has an & in it -->
43+ <item
44+ android : id =" @+id/action_create_backup"
45+ android : menuCategory =" secondary"
46+ android : title =" @string/menu_create_backup"
47+ />
4248 <item
4349 android : id =" @+id/action_restore_backup"
4450 android : menuCategory =" secondary"
Original file line number Diff line number Diff line change 9999 <string name =" menu_unmark_note" >Unmark note</string >
100100 <string name =" menu_enable_voice_playback" maxLength =" 28" >Enable voice playback</string >
101101 <string name =" menu_disable_voice_playback" >Disable voice playback</string >
102+ <string name =" menu_create_backup" maxLength =" 28" >Create backup</string >
102103 <string name =" new_deck" >Create deck</string >
103104 <string name =" new_dynamic_deck" >Create filtered deck</string >
104105 <string name =" directory_inaccessible" >AnkiDroid directory is inaccessible</string >
You can’t perform that action at this time.
0 commit comments