-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Reposition Card Template Dialog [WIP]
Just the UI Not yet implemented due to the logical complexity: the CardTemplateNotetype keeps an in memory log of changes, and a reposition + delete would need to be thoroughly tested to be sure it does not delete incorrect templates Issue 6017 Co-authored-by: Brayan Oliveira <[email protected]>
- Loading branch information
Showing
4 changed files
with
74 additions
and
1 deletion.
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
55 changes: 55 additions & 0 deletions
55
AnkiDroid/src/main/java/com/ichi2/anki/notetype/RepositionCardTemplateDialog.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,55 @@ | ||
/* | ||
* Copyright (c) 2024 David Allison <[email protected]> | ||
* | ||
* 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.notetype | ||
|
||
import android.content.Context | ||
import android.text.InputType | ||
import androidx.appcompat.app.AlertDialog | ||
import com.ichi2.anki.CollectionManager | ||
import com.ichi2.anki.R | ||
import com.ichi2.utils.getInputField | ||
import com.ichi2.utils.input | ||
import com.ichi2.utils.negativeButton | ||
import com.ichi2.utils.positiveButton | ||
import com.ichi2.utils.show | ||
|
||
class RepositionCardTemplateDialog { | ||
|
||
companion object { | ||
fun showInstance(context: Context, numberOfTemplates: Int, result: (Int) -> Unit) { | ||
var displayedDialog: AlertDialog? = null | ||
|
||
displayedDialog = AlertDialog.Builder(context).show { | ||
positiveButton(R.string.dialog_ok) { result(displayedDialog!!.getInputField().text.toString().toInt()) } | ||
negativeButton(R.string.dialog_cancel) | ||
setMessage(CollectionManager.TR.cardTemplatesEnterNewCardPosition1(numberOfTemplates)) | ||
setView(R.layout.dialog_generic_text_input) | ||
}.input( | ||
inputType = InputType.TYPE_CLASS_NUMBER, | ||
displayKeyboard = true, | ||
waitForPositiveButton = false | ||
) { dialog, text: CharSequence -> | ||
val number = text.toString().toIntOrNull() | ||
if (number == null || number < 1 || number > numberOfTemplates) { | ||
dialog.positiveButton.isEnabled = false | ||
return@input | ||
} | ||
dialog.positiveButton.isEnabled = true | ||
} | ||
} | ||
} | ||
} |
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