Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
xenonnn4w committed Aug 11, 2024
1 parent e007c44 commit d5fc262
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions AnkiDroid/src/main/java/com/ichi2/widget/DeckPickerWidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import com.ichi2.anki.AnkiDroidApp
import com.ichi2.anki.CollectionManager.withCol
import com.ichi2.anki.CrashReportService
import com.ichi2.anki.R
import com.ichi2.anki.Reviewer
import com.ichi2.anki.analytics.UsageAnalytics
import kotlinx.coroutines.launch
import timber.log.Timber
Expand Down Expand Up @@ -109,6 +110,19 @@ class DeckPickerWidget : AnalyticsWidgetProvider() {
deckView.setTextViewText(R.id.deckDue, deck.reviewCount.toString())
deckView.setTextViewText(R.id.deckLearn, deck.learnCount.toString())

// Set up the intent to open the deck when clicked
val intent = Intent(context, Reviewer::class.java).apply {
action = Intent.ACTION_VIEW
putExtra("deckId", deck.deckId)
}
val pendingIntent = PendingIntent.getActivity(
context,
deck.deckId.toInt(),
intent,
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
)
deckView.setOnClickPendingIntent(R.id.deckName, pendingIntent)

remoteViews.addView(R.id.deckCollection, deckView)
}
appWidgetManager.updateAppWidget(appWidgetId, remoteViews)
Expand Down

0 comments on commit d5fc262

Please sign in to comment.