From c57ccf01fe24ce508404c99b449e9097e6d8b270 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 13 Oct 2011 15:04:59 -0700 Subject: [PATCH] Showing notifications after taking a screenshot (Bug: 5333706) - Fixing issue where ticker and swipe-to-remove wasn't working for updated notifications Change-Id: Ib8ef07778a11028c9c2627830ee1dd4561d2ae3b --- .../SystemUI/res/layout/global_screenshot.xml | 6 +- packages/SystemUI/res/values/strings.xml | 18 +- .../systemui/screenshot/GlobalScreenshot.java | 161 ++++++++++++------ .../screenshot/TakeScreenshotService.java | 14 -- .../android/systemui/statusbar/StatusBar.java | 22 +++ .../statusbar/phone/PhoneStatusBar.java | 49 ++---- .../statusbar/tablet/TabletStatusBar.java | 26 +-- 7 files changed, 166 insertions(+), 130 deletions(-) diff --git a/packages/SystemUI/res/layout/global_screenshot.xml b/packages/SystemUI/res/layout/global_screenshot.xml index 6cb8799eaeb37..6d70135d51879 100644 --- a/packages/SystemUI/res/layout/global_screenshot.xml +++ b/packages/SystemUI/res/layout/global_screenshot.xml @@ -25,6 +25,7 @@ android:id="@+id/global_screenshot_container" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:layout_gravity="center" android:background="@drawable/global_screenshot_background" android:visibility="gone"> - diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 65d513853ccfc..a717b5724a317 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -168,10 +168,20 @@ When an app was designed for a smaller screen, a zoom control will appear by the clock. - - Screenshot saved to Gallery - - Could not save screenshot. External storage may be in use. + + Saving... + + Saving screenshot... + + Please wait for screenshot to be saved + + Screenshot captured + + Touch to view your screenshot + + Screenshot failed + + Failed to save screenshot. External storage may be in use. USB file transfer options diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 3fa3078da5666..cf073c46d750b 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -19,27 +19,27 @@ package com.android.systemui.screenshot; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorSet; -import android.animation.ObjectAnimator; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; -import android.app.Activity; +import android.app.Notification; +import android.app.NotificationManager; +import android.app.PendingIntent; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; +import android.content.Intent; +import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Matrix; import android.graphics.PixelFormat; -import android.media.MediaScannerConnection; import android.net.Uri; import android.os.AsyncTask; -import android.os.Binder; import android.os.Environment; import android.os.ServiceManager; import android.provider.MediaStore; import android.util.DisplayMetrics; -import android.util.Log; import android.view.Display; import android.view.IWindowManager; import android.view.LayoutInflater; @@ -50,16 +50,11 @@ import android.view.ViewGroup; import android.view.WindowManager; import android.widget.FrameLayout; import android.widget.ImageView; -import android.widget.TextView; -import android.widget.Toast; import com.android.systemui.R; import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; import java.io.OutputStream; -import java.lang.Thread; import java.text.SimpleDateFormat; import java.util.Date; @@ -83,6 +78,46 @@ class SaveImageInBackgroundTask extends AsyncTask 0) { // Show a message that we've failed to save the image to disk - Toast.makeText(params.context, R.string.screenshot_failed_toast, - Toast.LENGTH_SHORT).show(); + GlobalScreenshot.notifyScreenshotError(params.context, mNotificationManager); } else { - // Show a message that we've saved the screenshot to disk - Toast.makeText(params.context, R.string.screenshot_saving_toast, - Toast.LENGTH_SHORT).show(); + // Show the final notification to indicate screenshot saved + Resources r = params.context.getResources(); + + mNotificationBuilder + .setTicker(r.getString(R.string.screenshot_saved_title)) + .setContentTitle(r.getString(R.string.screenshot_saved_title)) + .setContentText(r.getString(R.string.screenshot_saved_text)) + .setContentIntent(PendingIntent.getActivity(params.context, 0, mLaunchIntent, 0)) + .setWhen(System.currentTimeMillis()) + .setAutoCancel(true); + + Notification n = mNotificationBuilder.getNotification(); + n.flags &= ~Notification.FLAG_NO_CLEAR; + mNotificationManager.notify(mNotificationId, n); } params.finisher.run(); }; @@ -154,22 +191,21 @@ class SaveImageInBackgroundTask extends AsyncTask