|
51 | 51 | import android.graphics.drawable.InsetDrawable; |
52 | 52 | import android.graphics.drawable.LayerDrawable; |
53 | 53 | import android.media.MediaActionSound; |
54 | | -import android.media.Ringtone; |
55 | | -import android.media.RingtoneManager; |
56 | 54 | import android.net.Uri; |
57 | 55 | import android.os.Handler; |
58 | 56 | import android.os.Looper; |
@@ -223,7 +221,7 @@ abstract static class ActionsReadyListener { |
223 | 221 | private float mCornerSizeX; |
224 | 222 | private float mDismissDeltaY; |
225 | 223 |
|
226 | | - private Ringtone mScreenshotSound; |
| 224 | + private MediaActionSound mCameraSound; |
227 | 225 |
|
228 | 226 | private int mNavMode; |
229 | 227 | private int mLeftInset; |
@@ -317,9 +315,9 @@ public GlobalScreenshot( |
317 | 315 | mFastOutSlowIn = |
318 | 316 | AnimationUtils.loadInterpolator(mContext, android.R.interpolator.fast_out_slow_in); |
319 | 317 |
|
320 | | - // Setup the Screenshot sound |
321 | | - mScreenshotSound = RingtoneManager.getRingtone(mContext, |
322 | | - Uri.parse("file://" + "/product/media/audio/ui/camera_click.ogg")); |
| 318 | + // Setup the Camera shutter sound |
| 319 | + mCameraSound = new MediaActionSound(); |
| 320 | + mCameraSound.load(MediaActionSound.SHUTTER_CLICK); |
323 | 321 |
|
324 | 322 | // Store UI background executor |
325 | 323 | mUiBgExecutor = uiBgExecutor; |
@@ -684,11 +682,7 @@ private void saveScreenshot(Bitmap screenshot, Consumer<Uri> finisher, Rect scre |
684 | 682 | private void saveScreenshotAndToast(Consumer<Uri> finisher) { |
685 | 683 | // Play the shutter sound to notify that we've taken a screenshot |
686 | 684 | mScreenshotHandler.post(() -> { |
687 | | - if (Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREENSHOT_SOUND, 1, UserHandle.USER_CURRENT) == 1) { |
688 | | - if (mScreenshotSound != null) { |
689 | | - mScreenshotSound.play(); |
690 | | - } |
691 | | - } |
| 685 | + mCameraSound.play(MediaActionSound.SHUTTER_CLICK); |
692 | 686 | }); |
693 | 687 |
|
694 | 688 | saveScreenshotInWorkerThread(finisher, new ActionsReadyListener() { |
@@ -744,11 +738,7 @@ void onActionsReady(SavedImageData imageData) { |
744 | 738 | }); |
745 | 739 |
|
746 | 740 | // Play the shutter sound to notify that we've taken a screenshot |
747 | | - if (Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREENSHOT_SOUND, 1, UserHandle.USER_CURRENT) == 1) { |
748 | | - if (mScreenshotSound != null) { |
749 | | - mScreenshotSound.play(); |
750 | | - } |
751 | | - } |
| 741 | + mCameraSound.play(MediaActionSound.SHUTTER_CLICK); |
752 | 742 |
|
753 | 743 | mScreenshotPreview.setLayerType(View.LAYER_TYPE_HARDWARE, null); |
754 | 744 | mScreenshotPreview.buildLayer(); |
|
0 commit comments