summaryrefslogtreecommitdiff
path: root/org.fox.ttrss/src/main/java
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2015-06-02 08:48:29 +0300
committerAndrew Dolgov <[email protected]>2015-06-02 08:48:29 +0300
commitff8c1ad1dc3018dedbc681d4f94ce4284424fa67 (patch)
treea59bbf8e1902994da8454e95bd38e2dc10cf50ba /org.fox.ttrss/src/main/java
parentdd9dfcb57f8118ba6448d54792b3cc9cbfa84c50 (diff)
add progressbars to offline sync notifications
remove some obsolete drawables
Diffstat (limited to 'org.fox.ttrss/src/main/java')
-rw-r--r--org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineDownloadService.java32
-rw-r--r--org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineUploadService.java19
2 files changed, 28 insertions, 23 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineDownloadService.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineDownloadService.java
index bf641ad0..f389add2 100644
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineDownloadService.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineDownloadService.java
@@ -92,7 +92,7 @@ public class OfflineDownloadService extends Service {
}
@SuppressWarnings("deprecation")
- private void updateNotification(String msg) {
+ private void updateNotification(String msg, int progress, int max, boolean showProgress) {
Intent intent = new Intent(this, OnlineActivity.class);
intent.setAction(INTENT_ACTION_CANCEL);
@@ -104,12 +104,14 @@ public class OfflineDownloadService extends Service {
.setContentTitle(getString(R.string.notify_downloading_title))
.setContentIntent(contentIntent)
.setWhen(System.currentTimeMillis())
- .setSmallIcon(R.drawable.ic_notification)
+ .setSmallIcon(R.drawable.ic_cloud_download)
.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(),
R.drawable.ic_launcher))
.setOngoing(true)
.setOnlyAlertOnce(true);
+ if (showProgress) builder.setProgress(max, progress, max == 0);
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setCategory(Notification.CATEGORY_PROGRESS)
.setVibrate(new long[0])
@@ -121,8 +123,8 @@ public class OfflineDownloadService extends Service {
m_nmgr.notify(NOTIFY_DOWNLOADING, builder.build());
}
- private void updateNotification(int msgResId) {
- updateNotification(getString(msgResId));
+ private void updateNotification(int msgResId, int progress, int max, boolean showProgress) {
+ updateNotification(getString(msgResId), progress, max, showProgress);
}
private void downloadFailed() {
@@ -168,7 +170,7 @@ public class OfflineDownloadService extends Service {
sendBroadcast(intent);
}
} else {
- updateNotification(getString(R.string.notify_downloading_images, 0));
+ updateNotification(getString(R.string.notify_downloading_images, 0), 0, 0, true);
}
m_readableDb.close();
@@ -195,7 +197,7 @@ public class OfflineDownloadService extends Service {
private void downloadArticles() {
Log.d(TAG, "offline: downloading articles... offset=" + m_articleOffset);
- updateNotification(getString(R.string.notify_downloading_articles, m_articleOffset));
+ updateNotification(getString(R.string.notify_downloading_articles, m_articleOffset), m_articleOffset, m_syncMax, true);
OfflineArticlesRequest req = new OfflineArticlesRequest(this);
@@ -217,7 +219,7 @@ public class OfflineDownloadService extends Service {
private void downloadFeeds() {
- updateNotification(R.string.notify_downloading_feeds);
+ updateNotification(R.string.notify_downloading_feeds, 0, 0, true);
getWritableDb().execSQL("DELETE FROM feeds;");
@@ -255,7 +257,7 @@ public class OfflineDownloadService extends Service {
getWritableDb().execSQL("DELETE FROM articles;");
} catch (Exception e) {
e.printStackTrace();
- updateNotification(R.string.offline_switch_error);
+ updateNotification(R.string.offline_switch_error, 0, 0, false);
downloadFailed();
}
}
@@ -272,7 +274,7 @@ public class OfflineDownloadService extends Service {
downloadFailed();
}
} else {
- updateNotification(getErrorMessage());
+ updateNotification(getErrorMessage(), 0, 0, false);
downloadFailed();
}
}
@@ -294,7 +296,7 @@ public class OfflineDownloadService extends Service {
private void downloadCategories() {
- updateNotification(R.string.notify_downloading_feeds);
+ updateNotification(R.string.notify_downloading_categories, 0, 0, true);
getWritableDb().execSQL("DELETE FROM categories;");
@@ -324,7 +326,7 @@ public class OfflineDownloadService extends Service {
} catch (Exception e) {
e.printStackTrace();
- updateNotification(R.string.offline_switch_error);
+ updateNotification(R.string.offline_switch_error, 0, 0, false);
downloadFailed();
}
}
@@ -340,7 +342,7 @@ public class OfflineDownloadService extends Service {
downloadFailed();
}
} else {
- updateNotification(getErrorMessage());
+ updateNotification(getErrorMessage(), 0, 0, false);
downloadFailed();
}
}
@@ -456,7 +458,7 @@ public class OfflineDownloadService extends Service {
stmtInsert.close();
} catch (Exception e) {
- updateNotification(R.string.offline_switch_error);
+ updateNotification(R.string.offline_switch_error, 0, 0, false);
Log.d(TAG, "offline: failed: exception when loading articles");
e.printStackTrace();
downloadFailed();
@@ -483,7 +485,7 @@ public class OfflineDownloadService extends Service {
} else {
Log.d(TAG, "offline: failed: " + getErrorMessage());
- updateNotification(getErrorMessage());
+ updateNotification(getErrorMessage(), 0, 0, false);
downloadFailed();
}
}
@@ -502,7 +504,7 @@ public class OfflineDownloadService extends Service {
if (!m_downloadInProgress) {
if (m_downloadImages) ImageCacheService.cleanupCache(this, false);
- updateNotification(R.string.notify_downloading_init);
+ updateNotification(R.string.notify_downloading_init, 0, 0, true);
m_downloadInProgress = true;
downloadCategories();
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineUploadService.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineUploadService.java
index 0e200553..b7f66188 100644
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineUploadService.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineUploadService.java
@@ -55,7 +55,7 @@ public class OfflineUploadService extends IntentService {
}
@SuppressWarnings("deprecation")
- private void updateNotification(String msg) {
+ private void updateNotification(String msg, int progress, int max, boolean showProgress) {
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent(this, OnlineActivity.class), 0);
@@ -64,13 +64,16 @@ public class OfflineUploadService extends IntentService {
.setContentTitle(getString(R.string.notify_uploading_title))
.setContentIntent(contentIntent)
.setWhen(System.currentTimeMillis())
- .setSmallIcon(R.drawable.ic_notification)
+ .setProgress(0, 0, true)
+ .setSmallIcon(R.drawable.ic_cloud_upload)
.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(),
R.drawable.ic_launcher))
.setOngoing(true)
.setOnlyAlertOnce(true)
.setVibrate(new long[0]);
+ if (showProgress) builder.setProgress(max, progress, max == 0);
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setCategory(Notification.CATEGORY_PROGRESS)
.setVisibility(Notification.VISIBILITY_PUBLIC)
@@ -81,8 +84,8 @@ public class OfflineUploadService extends IntentService {
m_nmgr.notify(NOTIFY_UPLOADING, builder.build());
}
- private void updateNotification(int msgResId) {
- updateNotification(getString(msgResId));
+ private void updateNotification(int msgResId, int progress, int max, boolean showProgress) {
+ updateNotification(getString(msgResId), progress, max, showProgress);
}
private void initDatabase() {
@@ -111,7 +114,7 @@ public class OfflineUploadService extends IntentService {
if (result != null) {
uploadMarked();
} else {
- updateNotification(getErrorMessage());
+ updateNotification(getErrorMessage(), 0, 0, false);
uploadFailed();
}
}
@@ -182,7 +185,7 @@ public class OfflineUploadService extends IntentService {
if (result != null) {
uploadPublished();
} else {
- updateNotification(getErrorMessage());
+ updateNotification(getErrorMessage(), 0, 0, false);
uploadFailed();
}
}
@@ -251,7 +254,7 @@ public class OfflineUploadService extends IntentService {
if (result != null) {
uploadSuccess();
} else {
- updateNotification(getErrorMessage());
+ updateNotification(getErrorMessage(), 0, 0, false);
uploadFailed();
}
}
@@ -288,7 +291,7 @@ public class OfflineUploadService extends IntentService {
if (!m_uploadInProgress) {
m_uploadInProgress = true;
- updateNotification(R.string.notify_uploading_sending_data);
+ updateNotification(R.string.notify_uploading_sending_data, 0, 0, true);
uploadRead();
}