Show queued upload count only when it is > 1

This commit is contained in:
YuviPanda 2013-01-30 16:31:08 +05:30
parent 31f8aa4888
commit 420ec8061c
4 changed files with 7 additions and 6 deletions

View file

@ -51,7 +51,6 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:singleLine="true" android:singleLine="true"
android:focusable="true" android:focusable="true"
android:text="1 left"
android:focusableInTouchMode="true" android:focusableInTouchMode="true"
style="@style/NotificationText" style="@style/NotificationText"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"

View file

@ -28,7 +28,7 @@
<string name="upload_progress_notification_title_finishing">Finishing uploading %1$s</string> <string name="upload_progress_notification_title_finishing">Finishing uploading %1$s</string>
<string name="upload_failed_notification_title">Uploading %1$s failed</string> <string name="upload_failed_notification_title">Uploading %1$s failed</string>
<string name="upload_failed_notification_subtitle">Tap to retry</string> <string name="upload_failed_notification_subtitle">Tap to retry</string>
<string name="uploads_pending_notification_indicator">%d</string> <string name="uploads_pending_notification_indicator">%d left</string>
<string name="transcoding_progress_title_start">Starting %1$s Transcoding</string> <string name="transcoding_progress_title_start">Starting %1$s Transcoding</string>
<string name="transcoding_progress_title_in_progress">Transcoding %1$s</string> <string name="transcoding_progress_title_in_progress">Transcoding %1$s</string>

View file

@ -6,7 +6,7 @@
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
</style> </style>
<style name="NotificationText"> <style name="NotificationText" parent="android:TextAppearance.DeviceDefault.Small">
<item name="android:textColor">?android:attr/textColorPrimary</item> <item name="android:textColor">?android:attr/textColorPrimary</item>
</style> </style>

View file

@ -77,8 +77,10 @@ public class UploadService extends IntentService {
RemoteViews curView = curNotification.contentView; RemoteViews curView = curNotification.contentView;
if(!notificationTitleChanged) { if(!notificationTitleChanged) {
curView.setTextViewText(R.id.uploadNotificationTitle, notificationProgressTitle); curView.setTextViewText(R.id.uploadNotificationTitle, notificationProgressTitle);
curView.setTextViewText(R.id.uploadNotificationsCount, String.format(getString(R.string.uploads_pending_notification_indicator), toUpload)); if(toUpload != 1) {
Log.d("Commons", String.format("%d uploads left", toUpload)); curView.setTextViewText(R.id.uploadNotificationsCount, String.format(getString(R.string.uploads_pending_notification_indicator), toUpload));
Log.d("Commons", String.format("%d uploads left", toUpload));
}
notificationTitleChanged = true; notificationTitleChanged = true;
Intent mediaUploadStartedEvent = new Intent(INTENT_UPLOAD_STARTED); Intent mediaUploadStartedEvent = new Intent(INTENT_UPLOAD_STARTED);
mediaUploadStartedEvent.putExtra(EXTRA_MEDIA, media); mediaUploadStartedEvent.putExtra(EXTRA_MEDIA, media);
@ -156,7 +158,7 @@ public class UploadService extends IntentService {
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
toUpload++; toUpload++;
if(curProgressNotification != null) { if(curProgressNotification != null && toUpload != 1) {
curProgressNotification.contentView.setTextViewText(R.id.uploadNotificationsCount, String.format(getString(R.string.uploads_pending_notification_indicator), toUpload)); curProgressNotification.contentView.setTextViewText(R.id.uploadNotificationsCount, String.format(getString(R.string.uploads_pending_notification_indicator), toUpload));
Log.d("Commons", String.format("%d uploads left", toUpload)); Log.d("Commons", String.format("%d uploads left", toUpload));
notificationManager.notify(NOTIFICATION_DOWNLOAD_IN_PROGRESS, curProgressNotification); notificationManager.notify(NOTIFICATION_DOWNLOAD_IN_PROGRESS, curProgressNotification);