diff --git a/res/layout/layout_upload_progress.xml b/res/layout/layout_upload_progress.xml index b6568db02..a1a646d08 100644 --- a/res/layout/layout_upload_progress.xml +++ b/res/layout/layout_upload_progress.xml @@ -28,7 +28,9 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:indeterminate="false" - > + android:indeterminateOnly="false" + android:progressDrawable="@android:drawable/progress_horizontal" > + diff --git a/src/org/wikimedia/commons/UploadService.java b/src/org/wikimedia/commons/UploadService.java index 470c82b24..f73420b27 100644 --- a/src/org/wikimedia/commons/UploadService.java +++ b/src/org/wikimedia/commons/UploadService.java @@ -42,7 +42,7 @@ public class UploadService extends IntentService { } @Override public void onProgress(long transferred, long total) { - double percent = transferred/total * 100; + double percent = (double)transferred / (double)total * 100; Log.d("Commons", "Uploaded " + percent + "% (" + transferred + " of " + total + ")"); curNotification.contentView.setProgressBar(R.id.uploadNotificationProgress, 100, (int)percent, false); notificationManager.notify(NOTIFICATION_DOWNLOAD_IN_PROGRESS, curNotification); @@ -98,6 +98,7 @@ public class UploadService extends IntentService { notificationView = new RemoteViews(getPackageName(), R.layout.layout_upload_progress); notificationView.setTextViewText(R.id.uploadNotificationTitle, "Uploading " + filename); + notificationView.setProgressBar(R.id.uploadNotificationProgress, 100, 0, false); Log.d("Commons", "Before execution!"); Notification curNotification = new NotificationCompat.Builder(this).setAutoCancel(true) @@ -105,12 +106,11 @@ public class UploadService extends IntentService { .setAutoCancel(true) .setContent(notificationView) .setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0)) + .setOngoing(true) .getNotification(); notificationManager.notify(NOTIFICATION_DOWNLOAD_IN_PROGRESS, curNotification); - Toast startingToast = Toast.makeText(this, R.string.uploading_started, Toast.LENGTH_LONG); - startingToast.show(); Log.d("Commons", "Just before"); try { result = api.upload(filename, file, length, pageContents, editSummary, new NotificationUpdateProgressListener(curNotification));