Merge branch 'master' into darkmode

* master:
  Android v10.0.
  #1161 (android widget) RemoteViews empty state
This commit is contained in:
Samuel Clay 2020-06-17 17:23:51 -04:00
commit 228c67ae0b
6 changed files with 13 additions and 11 deletions

View file

@ -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"

View file

@ -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

View file

@ -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>

View file

@ -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

View file

@ -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,

View file

@ -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;
}