Skip to content

Commit

Permalink
Merge branch 'master' into darkmode
Browse files Browse the repository at this point in the history
* master:
  Android v10.0.
  #1161 (android widget) RemoteViews empty state
  • Loading branch information
samuelclay committed Jun 17, 2020
2 parents d3b19f1 + 30a30bc commit 228c67a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions clients/android/NewsBlur/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.newsblur"
android:versionCode="166"
android:versionName="10.0b3" >
android:versionCode="167"
android:versionName="10.0" >

<uses-sdk
android:minSdkVersion="21"
Expand Down
2 changes: 1 addition & 1 deletion clients/android/NewsBlur/res/layout/view_app_widget.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions clients/android/NewsBlur/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import com.newsblur.util.PrefsUtils;
import com.newsblur.util.WidgetBackground;

import java.util.Set;

public class WidgetProvider extends AppWidgetProvider {

private static String TAG = "WidgetProvider";
Expand Down Expand Up @@ -51,6 +53,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
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
Expand Down Expand Up @@ -79,6 +82,10 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] a
// 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ public static boolean hasActiveAppWidgets(Context context) {
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;
}
Expand Down

0 comments on commit 228c67a

Please sign in to comment.