mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
open story from widget
This commit is contained in:
parent
9424ca68be
commit
ea8f9cfe07
2 changed files with 19 additions and 5 deletions
|
@ -121,8 +121,10 @@ class BlurWidgetRemoteViewsFactory implements RemoteViewsService.RemoteViewsFact
|
|||
// Next, set a fill-intent, which will be used to fill in the pending intent template
|
||||
// that is set on the collection view in StackWidgetProvider.
|
||||
Bundle extras = new Bundle();
|
||||
extras.putInt(NewsBlurWidgetProvider.EXTRA_ITEM_ID, position);
|
||||
extras.putString(NewsBlurWidgetProvider.EXTRA_ITEM_ID, story.storyHash);
|
||||
extras.putString(NewsBlurWidgetProvider.EXTRA_FEED_ID, story.feedId);
|
||||
Intent fillInIntent = new Intent();
|
||||
// fillInIntent.setAction(NewsBlurWidgetProvider.ACTION_OPEN_STORY);
|
||||
fillInIntent.putExtras(extras);
|
||||
// Make it possible to distinguish the individual on-click
|
||||
// action of a given item
|
||||
|
|
|
@ -10,11 +10,16 @@ import android.widget.RemoteViews;
|
|||
import android.widget.Toast;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.FeedReading;
|
||||
import com.newsblur.activity.Reading;
|
||||
import com.newsblur.util.FeedSet;
|
||||
import com.newsblur.util.Log;
|
||||
import com.newsblur.util.UIUtils;
|
||||
|
||||
public class NewsBlurWidgetProvider extends AppWidgetProvider {
|
||||
public static String ACTION_OPEN_STORY = "ACTION_OPEN_STORY";
|
||||
public static String EXTRA_ITEM_ID = "EXTRA_ITEM_ID";
|
||||
public static String EXTRA_FEED_ID = "EXTRA_FEED_ID";
|
||||
|
||||
private static String TAG = "NewsBlurWidgetProvider";
|
||||
// Called when the BroadcastReceiver receives an Intent broadcast.
|
||||
|
@ -27,8 +32,15 @@ public class NewsBlurWidgetProvider extends AppWidgetProvider {
|
|||
if (intent.getAction().equals(ACTION_OPEN_STORY)) {
|
||||
int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID,
|
||||
AppWidgetManager.INVALID_APPWIDGET_ID);
|
||||
int viewIndex = intent.getIntExtra(EXTRA_ITEM_ID, 0);
|
||||
Toast.makeText(context, "Touched view " + viewIndex, Toast.LENGTH_SHORT).show();
|
||||
String storyHash = intent.getStringExtra(EXTRA_ITEM_ID);
|
||||
String feedId = intent.getStringExtra(EXTRA_FEED_ID);
|
||||
FeedSet fs = FeedSet.singleFeed(feedId);
|
||||
Intent i = new Intent(context, FeedReading.class);
|
||||
i.putExtra(Reading.EXTRA_FEEDSET, fs);
|
||||
i.putExtra(Reading.EXTRA_STORY_HASH, storyHash);
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.getApplicationContext().startActivity(i);
|
||||
|
||||
}
|
||||
super.onReceive(context, intent);
|
||||
}
|
||||
|
@ -71,7 +83,7 @@ public class NewsBlurWidgetProvider extends AppWidgetProvider {
|
|||
// cannot set up their own pending intents. Instead, the collection as a whole sets
|
||||
// up a pending intent template, and the individual items set a fillInIntent
|
||||
// to create unique behavior on an item-by-item basis.
|
||||
/*Intent touchIntent = new Intent(context, NewsBlurWidgetProvider.class);
|
||||
Intent touchIntent = new Intent(context, NewsBlurWidgetProvider.class);
|
||||
// Set the action for the intent.
|
||||
// When the user touches a particular view, it will have the effect of
|
||||
// broadcasting TOAST_ACTION.
|
||||
|
@ -80,7 +92,7 @@ public class NewsBlurWidgetProvider extends AppWidgetProvider {
|
|||
intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
|
||||
PendingIntent touchIntentTemplate = PendingIntent.getBroadcast(context, 0, touchIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
rv.setPendingIntentTemplate(R.id.widget_list, touchIntentTemplate);*/
|
||||
rv.setPendingIntentTemplate(R.id.widget_list, touchIntentTemplate);
|
||||
|
||||
|
||||
appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
|
||||
|
|
Loading…
Add table
Reference in a new issue