Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(317)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/download/DownloadUtils.java

Issue 2647343005: [Download Home] Fix for 0 seconds remaining (Closed)
Patch Set: qinmin@ comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.download; 5 package org.chromium.chrome.browser.download;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.app.PendingIntent; 8 import android.app.PendingIntent;
9 import android.content.ActivityNotFoundException; 9 import android.content.ActivityNotFoundException;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 boolean isDownloadPending = 582 boolean isDownloadPending =
583 entry != null && state == DownloadState.INTERRUPTED && entry.isA utoResumable; 583 entry != null && state == DownloadState.INTERRUPTED && entry.isA utoResumable;
584 584
585 if (isDownloadPending) { 585 if (isDownloadPending) {
586 return context.getString(R.string.download_notification_pending); 586 return context.getString(R.string.download_notification_pending);
587 } else if (isDownloadPaused(item)) { 587 } else if (isDownloadPaused(item)) {
588 return context.getString(R.string.download_notification_paused); 588 return context.getString(R.string.download_notification_paused);
589 } 589 }
590 590
591 if (info.getBytesReceived() == 0 591 if (info.getBytesReceived() == 0
592 || (!item.isIndeterminate() && info.getTimeRemainingInMillis() = = 0)) { 592 || (!item.isIndeterminate() && info.getTimeRemainingInMillis() < 0)) {
593 // We lack enough information about the download to display a useful string. 593 // We lack enough information about the download to display a useful string.
594 return context.getString(R.string.download_started); 594 return context.getString(R.string.download_started);
595 } else if (item.isIndeterminate()) { 595 } else if (item.isIndeterminate()) {
596 // Count up the bytes. 596 // Count up the bytes.
597 long bytes = info.getBytesReceived(); 597 long bytes = info.getBytesReceived();
598 return DownloadUtils.getStringForBytes(context, BYTES_DOWNLOADED_STR INGS, bytes); 598 return DownloadUtils.getStringForBytes(context, BYTES_DOWNLOADED_STR INGS, bytes);
599 } else { 599 } else {
600 // Count down the time. 600 // Count down the time.
601 long msRemaining = info.getTimeRemainingInMillis(); 601 long msRemaining = info.getTimeRemainingInMillis();
602 return DownloadNotificationService.formatRemainingTime(context, msRe maining); 602 return DownloadNotificationService.formatRemainingTime(context, msRe maining);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 int extensionLength = fileName.length() - index; 674 int extensionLength = fileName.length() - index;
675 675
676 // If the extension is too long, just use truncate the string from begin ning. 676 // If the extension is too long, just use truncate the string from begin ning.
677 if (extensionLength >= limit) { 677 if (extensionLength >= limit) {
678 return fileName.substring(0, limit) + ELLIPSIS; 678 return fileName.substring(0, limit) + ELLIPSIS;
679 } 679 }
680 int remainingLength = limit - extensionLength; 680 int remainingLength = limit - extensionLength;
681 return fileName.substring(0, remainingLength) + ELLIPSIS + fileName.subs tring(index); 681 return fileName.substring(0, remainingLength) + ELLIPSIS + fileName.subs tring(index);
682 } 682 }
683 } 683 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698