mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Merge branch 'sictiru'
* sictiru: #1161 (android widget) RemoteViews empty state
This commit is contained in:
commit
30a30bc659
5 changed files with 11 additions and 9 deletions
|
@ -45,7 +45,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/title_widget_setup"
|
||||
android:text="@string/title_widget_loading"
|
||||
android:textColor="@color/widget_feed_title" />
|
||||
|
||||
<!-- Note that empty views must be siblings of the collection view
|
||||
|
|
|
@ -243,6 +243,7 @@
|
|||
<string name="widget">Widget</string>
|
||||
<string name="title_widget_setup">Tap to setup in NewsBlur</string>
|
||||
<string name="title_no_subscriptions">No active subscriptions detected</string>
|
||||
<string name="title_widget_loading">Loading...</string>
|
||||
|
||||
<string name="settings_cat_offline">Offline</string>
|
||||
<string name="settings_enable_offline">Download Stories</string>
|
||||
|
|
|
@ -62,8 +62,8 @@ public class WidgetConfig extends NbActivity {
|
|||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
// notify widget to refresh next time it's viewed
|
||||
WidgetUtils.notifyViewDataChanged(this);
|
||||
// notify widget to update next time it's viewed
|
||||
WidgetUtils.updateWidget(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,8 @@ import com.newsblur.util.FeedSet;
|
|||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.WidgetBackground;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class WidgetProvider extends AppWidgetProvider {
|
||||
|
||||
private static String TAG = "WidgetProvider";
|
||||
|
@ -51,6 +53,7 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
Log.d(TAG, "onUpdate");
|
||||
WidgetUtils.checkWidgetUpdateAlarm(context);
|
||||
WidgetBackground widgetBackground = PrefsUtils.getWidgetBackground(context);
|
||||
Set<String> feedIds = PrefsUtils.getWidgetFeedIds(context);
|
||||
for (int appWidgetId : appWidgetIds) {
|
||||
|
||||
// Set up the intent that starts the WidgetRemoteViewService, which will
|
||||
|
@ -79,6 +82,10 @@ public class WidgetProvider extends AppWidgetProvider {
|
|||
// object above.
|
||||
rv.setEmptyView(R.id.widget_list, R.id.widget_empty_view);
|
||||
|
||||
if (feedIds != null && feedIds.isEmpty()) {
|
||||
rv.setTextViewText(R.id.widget_empty_view, context.getString(R.string.title_widget_setup));
|
||||
}
|
||||
|
||||
Intent configIntent = new Intent(context, WidgetProvider.class);
|
||||
configIntent.setAction(WidgetUtils.ACTION_OPEN_CONFIG);
|
||||
PendingIntent configIntentTemplate = PendingIntent.getBroadcast(context, WidgetUtils.RC_WIDGET_CONFIG, configIntent,
|
||||
|
|
|
@ -55,12 +55,6 @@ public class WidgetUtils {
|
|||
return appWidgetIds.length > 0;
|
||||
}
|
||||
|
||||
public static void notifyViewDataChanged(Context context) {
|
||||
AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
|
||||
int[] appWidgetIds = appWidgetManager.getAppWidgetIds(new ComponentName(context, WidgetProvider.class));
|
||||
appWidgetManager.notifyAppWidgetViewDataChanged(appWidgetIds, R.id.widget_list);
|
||||
}
|
||||
|
||||
public static boolean isLoggedIn(Context context) {
|
||||
return PrefsUtils.getUniqueLoginKey(context) != null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue