diff --git a/app/src/main/java/org/fedorahosted/freeotp/widget/OtpListWidgetProvider.java b/app/src/main/java/org/fedorahosted/freeotp/widget/OtpListWidgetProvider.java index 76cad27d..1cc2bb9b 100644 --- a/app/src/main/java/org/fedorahosted/freeotp/widget/OtpListWidgetProvider.java +++ b/app/src/main/java/org/fedorahosted/freeotp/widget/OtpListWidgetProvider.java @@ -68,13 +68,7 @@ private RemoteViews getFirstWidget(Context context, int widgetId) { widget.setEmptyView(R.id.list_widget, android.R.id.empty); setTitleIntent(context, widget); - - final Intent showCodeIntent = new Intent(context, OtpListWidgetProvider.class) - .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId); - showCodeIntent.setData(Uri.parse(showCodeIntent.toUri(Intent.URI_INTENT_SCHEME))); - final PendingIntent showCodeIntentTemplate = - PendingIntent.getBroadcast(context, 0, showCodeIntent, PendingIntent.FLAG_UPDATE_CURRENT); - widget.setPendingIntentTemplate(R.id.list_widget, showCodeIntentTemplate); + setCodeClickPendingIntentTemplate(context, widget, widgetId); return widget; } @@ -85,6 +79,15 @@ private void setTitleIntent(final Context context, final RemoteViews widget) { widget.setOnClickPendingIntent(R.id.widget_title_container, pendingIntent); } + private void setCodeClickPendingIntentTemplate(Context context, RemoteViews widget, int widgetId) { + final Intent codeClickIntent = new Intent(context, OtpListWidgetProvider.class) + .putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, widgetId); + codeClickIntent.setData(Uri.parse(codeClickIntent.toUri(Intent.URI_INTENT_SCHEME))); + final PendingIntent showCodeIntentTemplate = + PendingIntent.getBroadcast(context, 0, codeClickIntent, PendingIntent.FLAG_UPDATE_CURRENT); + widget.setPendingIntentTemplate(R.id.list_widget, showCodeIntentTemplate); + } + private String getCodeForTokenId(final Context context, final String id) { final TokenPersistence persistence = new TokenPersistence(context); for (int i = 0; i <= persistence.length(); i++) {