Commit e13789bf by eguven Committed by Oliver Woodman

Hide internal DownloadManager states

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188481259
parent a58bffbe
...@@ -607,8 +607,7 @@ public class DownloadManagerTest { ...@@ -607,8 +607,7 @@ public class DownloadManagerTest {
} }
private FakeDownloadAction assertStopped() { private FakeDownloadAction assertStopped() {
assertState(DownloadState.STATE_STOPPING); return assertState(DownloadState.STATE_QUEUED);
return assertState(DownloadState.STATE_WAITING);
} }
private FakeDownloadAction assertState(@State int expectedState) { private FakeDownloadAction assertState(@State int expectedState) {
......
...@@ -67,12 +67,16 @@ public final class DownloadNotificationUtil { ...@@ -67,12 +67,16 @@ public final class DownloadNotificationUtil {
int titleStringId = getTitleStringId(downloadState); int titleStringId = getTitleStringId(downloadState);
notificationBuilder.setContentTitle(context.getResources().getString(titleStringId)); notificationBuilder.setContentTitle(context.getResources().getString(titleStringId));
if (downloadState.isRunning()) { if (downloadState.state == DownloadState.STATE_STARTED) {
notificationBuilder.setOngoing(true); notificationBuilder.setOngoing(true);
float percentage = downloadState.downloadPercentage; float percentage = downloadState.downloadPercentage;
boolean indeterminate = Float.isNaN(percentage); boolean indeterminate = Float.isNaN(percentage);
notificationBuilder.setProgress(100, indeterminate ? 0 : (int) percentage, indeterminate); notificationBuilder.setProgress(100, indeterminate ? 0 : (int) percentage, indeterminate);
} }
if (Util.SDK_INT >= 17) {
// Hide timestamp on the notification while download progresses.
notificationBuilder.setShowWhen(downloadState.state != DownloadState.STATE_STARTED);
}
if (downloadState.error != null && errorMessageProvider != null) { if (downloadState.error != null && errorMessageProvider != null) {
message = errorMessageProvider.getErrorMessage(downloadState.error).second; message = errorMessageProvider.getErrorMessage(downloadState.error).second;
...@@ -90,12 +94,10 @@ public final class DownloadNotificationUtil { ...@@ -90,12 +94,10 @@ public final class DownloadNotificationUtil {
private static int getTitleStringId(DownloadState downloadState) { private static int getTitleStringId(DownloadState downloadState) {
int titleStringId; int titleStringId;
switch (downloadState.state) { switch (downloadState.state) {
case DownloadState.STATE_WAITING: case DownloadState.STATE_QUEUED:
titleStringId = R.string.exo_download_queued; titleStringId = R.string.exo_download_queued;
break; break;
case DownloadState.STATE_STARTED: case DownloadState.STATE_STARTED:
case DownloadState.STATE_STOPPING:
case DownloadState.STATE_CANCELING:
titleStringId = R.string.exo_downloading; titleStringId = R.string.exo_downloading;
break; break;
case DownloadState.STATE_ENDED: case DownloadState.STATE_ENDED:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment