Skip to content

Commit

Permalink
Moved chunk of code to different method in OtpListWidgetProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
ericbrandwein committed Nov 18, 2017
1 parent 44a98cc commit b2c799a
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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++) {
Expand Down

0 comments on commit b2c799a

Please sign in to comment.