diff options
author | Bobby Georgescu <georgescu@google.com> | 2013-04-25 18:10:18 -0700 |
---|---|---|
committer | Bobby Georgescu <georgescu@google.com> | 2013-04-25 18:32:13 -0700 |
commit | 13fec90b6a03e21a88cb8b8425e65289904d4186 (patch) | |
tree | a3b85bef3dd67546e091036e554dc325ebe4b112 /src/com/android/gallery3d/ingest | |
parent | bdc9421fb87cf60500b1d137a70a82f189dc320e (diff) | |
download | android_packages_apps_Gallery2-13fec90b6a03e21a88cb8b8425e65289904d4186.tar.gz android_packages_apps_Gallery2-13fec90b6a03e21a88cb8b8425e65289904d4186.tar.bz2 android_packages_apps_Gallery2-13fec90b6a03e21a88cb8b8425e65289904d4186.zip |
Show notification to relaunch MTP importer
Bug: 8158516
Change-Id: I98a57f9ac6e6935595b44e1277ddffa378065068
Diffstat (limited to 'src/com/android/gallery3d/ingest')
-rw-r--r-- | src/com/android/gallery3d/ingest/IngestService.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/ingest/IngestService.java b/src/com/android/gallery3d/ingest/IngestService.java index fa421e771..28d721157 100644 --- a/src/com/android/gallery3d/ingest/IngestService.java +++ b/src/com/android/gallery3d/ingest/IngestService.java @@ -37,7 +37,6 @@ import android.widget.Adapter; import com.android.gallery3d.R; import com.android.gallery3d.app.NotificationIds; import com.android.gallery3d.data.MtpClient; -import com.android.gallery3d.ingest.data.MtpBitmapFetch; import com.android.gallery3d.util.BucketNames; import java.util.ArrayList; @@ -70,6 +69,7 @@ public class IngestService extends Service implements ImportTask.Listener, private NotificationManager mNotificationManager; private NotificationCompat.Builder mNotificationBuilder; private long mLastProgressIndexTime = 0; + private boolean mNeedRelaunchNotification = false; @Override public void onCreate() { @@ -139,7 +139,15 @@ public class IngestService extends Service implements ImportTask.Listener, protected void setClientActivity(IngestActivity activity) { if (mClientActivity == activity) return; mClientActivity = activity; - if (mClientActivity == null) return; + if (mClientActivity == null) { + if (mNeedRelaunchNotification) { + mNotificationBuilder.setProgress(0, 0, false) + .setContentText(getResources().getText(R.string.ingest_scanning_done)); + mNotificationManager.notify(NotificationIds.INGEST_NOTIFICATION_SCANNING, + mNotificationBuilder.build()); + } + return; + } mNotificationManager.cancel(NotificationIds.INGEST_NOTIFICATION_IMPORTING); mNotificationManager.cancel(NotificationIds.INGEST_NOTIFICATION_SCANNING); if (mRedeliverImportFinish) { @@ -187,6 +195,7 @@ public class IngestService extends Service implements ImportTask.Listener, public void deviceRemoved(MtpDevice device) { if (device == mDevice) { setDevice(null); + mNeedRelaunchNotification = false; } } @@ -196,6 +205,7 @@ public class IngestService extends Service implements ImportTask.Listener, if (pathIfSuccessful != null) { mScannerClient.scanPath(pathIfSuccessful); } + mNeedRelaunchNotification = false; if (mClientActivity != null) { mClientActivity.onImportProgress(visitedCount, totalCount, pathIfSuccessful); } @@ -208,6 +218,7 @@ public class IngestService extends Service implements ImportTask.Listener, @Override public void onImportFinish(Collection<MtpObjectInfo> objectsNotImported) { stopForeground(true); + mNeedRelaunchNotification = true; if (mClientActivity != null) { mClientActivity.onImportFinish(objectsNotImported); } else { @@ -222,6 +233,7 @@ public class IngestService extends Service implements ImportTask.Listener, @Override public void onObjectIndexed(MtpObjectInfo object, int numVisited) { + mNeedRelaunchNotification = false; if (mClientActivity != null) { mClientActivity.onObjectIndexed(object, numVisited); } else { @@ -244,6 +256,7 @@ public class IngestService extends Service implements ImportTask.Listener, @Override public void onIndexFinish() { + mNeedRelaunchNotification = true; if (mClientActivity != null) { mClientActivity.onIndexFinish(); } else { |