diff --git a/res/drawable/unread_widget_background.xml b/res/drawable/unread_widget_background.xml
new file mode 100644
index 000000000..52e295f83
--- /dev/null
+++ b/res/drawable/unread_widget_background.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/unread_widget_layout.xml b/res/layout/unread_widget_layout.xml
index ce6684193..4ad2c399e 100644
--- a/res/layout/unread_widget_layout.xml
+++ b/res/layout/unread_widget_layout.xml
@@ -6,6 +6,9 @@
android:layout_height="wrap_content"
android:padding="2dp"
android:orientation="vertical"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="@drawable/unread_widget_background"
android:gravity="bottom|center_horizontal">
Move down
Moving account...
- Unread count
+ K-9 Unread
Show unread count for…
diff --git a/src/com/fsck/k9/provider/UnreadWidgetProvider.java b/src/com/fsck/k9/provider/UnreadWidgetProvider.java
index 8913fb4e7..616707c34 100644
--- a/src/com/fsck/k9/provider/UnreadWidgetProvider.java
+++ b/src/com/fsck/k9/provider/UnreadWidgetProvider.java
@@ -20,6 +20,7 @@ import android.view.View;
import android.widget.RemoteViews;
public class UnreadWidgetProvider extends AppWidgetProvider {
+ private static final int MAX_COUNT = 9999;
/**
* Trigger update for all of our unread widgets.
@@ -71,11 +72,15 @@ public class UnreadWidgetProvider extends AppWidgetProvider {
}
}
- if (unreadCount == 0) {
+ if (unreadCount <= 0) {
// Hide TextView for unread count if there are no unread messages.
remoteViews.setViewVisibility(R.id.unread_count, View.GONE);
} else {
- remoteViews.setTextViewText(R.id.unread_count, String.valueOf(unreadCount));
+ remoteViews.setViewVisibility(R.id.unread_count, View.VISIBLE);
+
+ String displayCount = (unreadCount <= MAX_COUNT) ?
+ String.valueOf(unreadCount) : String.valueOf(MAX_COUNT) + "+";
+ remoteViews.setTextViewText(R.id.unread_count, displayCount);
}
remoteViews.setTextViewText(R.id.account_name, accountName);
@@ -95,7 +100,6 @@ public class UnreadWidgetProvider extends AppWidgetProvider {
remoteViews.setOnClickPendingIntent(R.id.unread_widget_layout, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
-
}