From ff8c1ad1dc3018dedbc681d4f94ce4284424fa67 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 2 Jun 2015 08:48:29 +0300 Subject: add progressbars to offline sync notifications remove some obsolete drawables --- .../fox/ttrss/offline/OfflineDownloadService.java | 32 +- .../fox/ttrss/offline/OfflineUploadService.java | 19 +- .../src/main/res/drawable/s_headline_published.svg | 905 --------------------- .../res/drawable/s_headline_published_special.svg | 905 --------------------- .../main/res/drawable/s_headline_unpublished.svg | 193 ----- org.fox.ttrss/src/main/res/drawable/s_marked.svg | 77 -- .../src/main/res/drawable/s_marked_bw.svg | 93 --- .../src/main/res/drawable/s_marked_bw_full.svg | 93 --- .../main/res/drawable/s_menu_attaches_light.svg | 143 ---- .../src/main/res/drawable/s_menu_marked.svg | 93 --- .../main/res/drawable/s_menu_published_dark.svg | 178 ---- .../main/res/drawable/s_menu_published_light.svg | 189 ----- .../main/res/drawable/s_menu_unpublished_light.svg | 113 --- .../src/main/res/drawable/s_prev_article.svg | 70 -- org.fox.ttrss/src/main/res/values/strings.xml | 1 + 15 files changed, 29 insertions(+), 3075 deletions(-) delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_headline_published.svg delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_headline_published_special.svg delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_headline_unpublished.svg delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_marked.svg delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_marked_bw.svg delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_marked_bw_full.svg delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_menu_attaches_light.svg delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_menu_marked.svg delete mode 100755 org.fox.ttrss/src/main/res/drawable/s_menu_published_dark.svg delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_menu_published_light.svg delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_menu_unpublished_light.svg delete mode 100644 org.fox.ttrss/src/main/res/drawable/s_prev_article.svg 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(); } diff --git a/org.fox.ttrss/src/main/res/drawable/s_headline_published.svg b/org.fox.ttrss/src/main/res/drawable/s_headline_published.svg deleted file mode 100644 index e7e042e0..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_headline_published.svg +++ /dev/null @@ -1,905 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_headline_published_special.svg b/org.fox.ttrss/src/main/res/drawable/s_headline_published_special.svg deleted file mode 100644 index 2789cfa8..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_headline_published_special.svg +++ /dev/null @@ -1,905 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_headline_unpublished.svg b/org.fox.ttrss/src/main/res/drawable/s_headline_unpublished.svg deleted file mode 100644 index 1f709695..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_headline_unpublished.svg +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_marked.svg b/org.fox.ttrss/src/main/res/drawable/s_marked.svg deleted file mode 100644 index 326c9691..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_marked.svg +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_marked_bw.svg b/org.fox.ttrss/src/main/res/drawable/s_marked_bw.svg deleted file mode 100644 index 8bfe6d8f..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_marked_bw.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_marked_bw_full.svg b/org.fox.ttrss/src/main/res/drawable/s_marked_bw_full.svg deleted file mode 100644 index 0e5b2b11..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_marked_bw_full.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_menu_attaches_light.svg b/org.fox.ttrss/src/main/res/drawable/s_menu_attaches_light.svg deleted file mode 100644 index 0396f73f..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_menu_attaches_light.svg +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_menu_marked.svg b/org.fox.ttrss/src/main/res/drawable/s_menu_marked.svg deleted file mode 100644 index 1be0b7f9..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_menu_marked.svg +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_menu_published_dark.svg b/org.fox.ttrss/src/main/res/drawable/s_menu_published_dark.svg deleted file mode 100755 index d19c8e22..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_menu_published_dark.svg +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_menu_published_light.svg b/org.fox.ttrss/src/main/res/drawable/s_menu_published_light.svg deleted file mode 100644 index 752fe0f6..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_menu_published_light.svg +++ /dev/null @@ -1,189 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_menu_unpublished_light.svg b/org.fox.ttrss/src/main/res/drawable/s_menu_unpublished_light.svg deleted file mode 100644 index 6981beaf..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_menu_unpublished_light.svg +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/drawable/s_prev_article.svg b/org.fox.ttrss/src/main/res/drawable/s_prev_article.svg deleted file mode 100644 index 5c83a6b5..00000000 --- a/org.fox.ttrss/src/main/res/drawable/s_prev_article.svg +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/org.fox.ttrss/src/main/res/values/strings.xml b/org.fox.ttrss/src/main/res/values/strings.xml index b6ba6e6d..39246126 100755 --- a/org.fox.ttrss/src/main/res/values/strings.xml +++ b/org.fox.ttrss/src/main/res/values/strings.xml @@ -81,6 +81,7 @@ Downloading articles (%1$d)… Starting download… Downloading feeds… + Downloading categories… Sending data to server… Preparing offline mode Synchronizing offline data -- cgit v1.2.3