Merge pull request #1255 from caleb-allen/widget-tap-story

add touch intent to widget initialization instead of only refresh
This commit is contained in:
Samuel Clay 2019-10-19 16:22:52 -04:00 committed by GitHub
commit 1eff2f1e3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,10 +1,12 @@
package com.newsblur.widget;
import android.app.AlertDialog;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@ -106,6 +108,7 @@ public class ConfigureWidgetActivity extends NbActivity {
Intent intent = new Intent(this, BlurWidgetRemoteViewsService.class);
// Add the app widget ID to the intent extras.
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
PrefsUtils.setWidgetFeed(this, appWidgetId, selectedFeed.feedId, selectedFeed.title);
@ -113,6 +116,20 @@ public class ConfigureWidgetActivity extends NbActivity {
rv.setRemoteAdapter(R.id.widget_list, intent);
rv.setEmptyView(R.id.widget_list, R.id.empty_view);
Intent touchIntent = new Intent(this, NewsBlurWidgetProvider.class);
// Set the action for the intent.
// When the user touches a particular view, it will have the effect of
// broadcasting TOAST_ACTION.
touchIntent.setAction(NewsBlurWidgetProvider.ACTION_OPEN_STORY);
touchIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
PendingIntent touchIntentTemplate = PendingIntent.getBroadcast(this, 0, touchIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
rv.setPendingIntentTemplate(R.id.widget_list, touchIntentTemplate);
appWidgetManager.updateAppWidget(appWidgetId, rv);
Intent resultValue = new Intent();