From 781c71e6392f47393bc2577c41f7617c9ecee2c5 Mon Sep 17 00:00:00 2001 From: Eric Brandwein Date: Wed, 19 Apr 2017 00:57:28 -0300 Subject: [PATCH] Moved chunk of code to different method in OtpListWidgetProvider --- .../freeotp/widget/OtpListWidgetProvider.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) 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++) {