Skip to content

Commit

Permalink
Having a check for storage permission, and removed an extra snackbar.
Browse files Browse the repository at this point in the history
  • Loading branch information
xenonnn4w committed Aug 17, 2024
1 parent 1269201 commit 200ad08
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
20 changes: 7 additions & 13 deletions AnkiDroid/src/main/java/com/ichi2/widget/DeckPickerWidgetConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,16 @@ class DeckPickerWidgetConfig : AnkiActivity(), DeckSelectionListener {
private var dueTree: DeckNode? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (showedActivityFailedScreen(savedInstanceState)) {
return
}

super.onCreate(savedInstanceState)
if (!ensureStoragePermissions()) {
sendBroadcast(Intent(this, DeckPickerWidget::class.java))
return
}

setContentView(R.layout.widget_deck_picker_config)

deckPickerWidgetPreferences = WidgetPreferences(this)
Expand Down Expand Up @@ -139,18 +144,7 @@ class DeckPickerWidgetConfig : AnkiActivity(), DeckSelectionListener {

// TODO: Implement multi-select functionality so that user can select desired decks in once.
findViewById<FloatingActionButton>(R.id.fabWidgetDeckPicker).setOnClickListener {
lifecycleScope.launch {
val tree = dueTree
if (tree != null) {
// Check if the default deck is the only available deck and there are no cards
val isEmpty = isCollectionEmpty(tree)
if (isEmpty) {
showSnackbar(R.string.no_decks_available_message)
} else {
showDeckSelectionDialog()
}
}
}
showDeckSelectionDialog()
}

// Load and display saved preferences
Expand Down
1 change: 0 additions & 1 deletion AnkiDroid/src/main/res/values/08-widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
<string name="no_selected_deck_placeholder_title" comment="Placeholder title when no decks are selected">Select decks to display in the widget</string>
<string name="no_selected_deck_placeholder_description" comment="Description for starting to mark decks">Select decks with the + icon.</string>
<string name="deck_removed_from_widget" comment="Snackbar when deck is removed from widget" >Deck Removed</string>
<string name="no_decks_available_message" comment="Snackbar when the collection is empty">No decks available to select</string>"
<string name="deck_already_selected_message" comment="Snackbar when user try to select the same deck again">This deck is already selected</string>
<plurals name="deck_limit_reached">
<item quantity="one">You can select up to %d deck.</item>
Expand Down

0 comments on commit 200ad08

Please sign in to comment.