Loading packages/SystemUI/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -208,6 +208,10 @@ </intent-filter> </receiver> <!-- Callback for dismissing screenshot notification after a share target is picked --> <receiver android:name=".screenshot.GlobalScreenshot$TargetChosenReceiver" android:exported="false" /> <!-- started from UsbDeviceSettingsManager --> <activity android:name=".usb.UsbConfirmActivity" android:exported="true" Loading packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +27 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.app.Notification; import android.app.Notification.BigPictureStyle; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; Loading Loading @@ -242,7 +243,12 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi sharingIntent.putExtra(Intent.EXTRA_STREAM, uri); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject); Intent chooserIntent = Intent.createChooser(sharingIntent, null); final PendingIntent callback = PendingIntent.getBroadcast(context, 0, new Intent(context, GlobalScreenshot.TargetChosenReceiver.class) .putExtra(GlobalScreenshot.CANCEL_ID, mNotificationId), PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT); Intent chooserIntent = Intent.createChooser(sharingIntent, null, callback.getIntentSender()); chooserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); Loading Loading @@ -341,6 +347,8 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi class GlobalScreenshot { private static final String TAG = "GlobalScreenshot"; static final String CANCEL_ID = "android:cancel_id"; private static final int SCREENSHOT_FLASH_TO_PEAK_DURATION = 130; private static final int SCREENSHOT_DROP_IN_DURATION = 430; private static final int SCREENSHOT_DROP_OUT_DELAY = 500; Loading Loading @@ -732,4 +740,22 @@ class GlobalScreenshot { .build(); nManager.notify(R.id.notification_screenshot, n); } /** * Removes the notification for a screenshot after a share target is chosen. */ public static class TargetChosenReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (!intent.hasExtra(CANCEL_ID)) { return; } final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); final int id = intent.getIntExtra(CANCEL_ID, 0); nm.cancel(id); } } } Loading
packages/SystemUI/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -208,6 +208,10 @@ </intent-filter> </receiver> <!-- Callback for dismissing screenshot notification after a share target is picked --> <receiver android:name=".screenshot.GlobalScreenshot$TargetChosenReceiver" android:exported="false" /> <!-- started from UsbDeviceSettingsManager --> <activity android:name=".usb.UsbConfirmActivity" android:exported="true" Loading
packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +27 −1 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.app.Notification; import android.app.Notification.BigPictureStyle; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; Loading Loading @@ -242,7 +243,12 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi sharingIntent.putExtra(Intent.EXTRA_STREAM, uri); sharingIntent.putExtra(Intent.EXTRA_SUBJECT, subject); Intent chooserIntent = Intent.createChooser(sharingIntent, null); final PendingIntent callback = PendingIntent.getBroadcast(context, 0, new Intent(context, GlobalScreenshot.TargetChosenReceiver.class) .putExtra(GlobalScreenshot.CANCEL_ID, mNotificationId), PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT); Intent chooserIntent = Intent.createChooser(sharingIntent, null, callback.getIntentSender()); chooserIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); Loading Loading @@ -341,6 +347,8 @@ class SaveImageInBackgroundTask extends AsyncTask<SaveImageInBackgroundData, Voi class GlobalScreenshot { private static final String TAG = "GlobalScreenshot"; static final String CANCEL_ID = "android:cancel_id"; private static final int SCREENSHOT_FLASH_TO_PEAK_DURATION = 130; private static final int SCREENSHOT_DROP_IN_DURATION = 430; private static final int SCREENSHOT_DROP_OUT_DELAY = 500; Loading Loading @@ -732,4 +740,22 @@ class GlobalScreenshot { .build(); nManager.notify(R.id.notification_screenshot, n); } /** * Removes the notification for a screenshot after a share target is chosen. */ public static class TargetChosenReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (!intent.hasExtra(CANCEL_ID)) { return; } final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); final int id = intent.getIntExtra(CANCEL_ID, 0); nm.cancel(id); } } }