From 82ca685d3673cf470ae2b7f0f5693f7e4a058323 Mon Sep 17 00:00:00 2001 From: Vansh Bhatnagar <66791357+vansh123456@users.noreply.github.com> Date: Tue, 8 Jun 2021 21:58:02 +0530 Subject: [PATCH] Add Android S style player + screenshot sound toggle (#9) * SystemUI: Redesign Media Player View Design inspired from Android S Co-authored-by: Akash Srivastava * base: Allow disabling screenshot shutter sound [1/2] Includes also: commit b794cab075a38caccbb3c411b8b697426df27653 Co-Authored-By: xyyx Date: Thu Jan 12 21:59:42 2017 +0800 ScreenshotSound: Fix playing screenshot's sound when camera's sounds off. This bug actually because Screenshot uses Camera Shutter Sound @idoybh: Adapt to A11 Change-Id: If6f766e4b581e7c35d36e2e777ce2c37a3843ad4 Co-authored-by: hpnightowl Co-authored-by: Akash Srivastava Co-authored-by: maxwen --- core/java/android/provider/Settings.java | 6 + .../settings/backup/SystemSettings.java | 1 + .../validators/SystemSettingsValidators.java | 1 + packages/SystemUI/res/layout/media_view.xml | 10 -- packages/SystemUI/res/values/dimens.xml | 2 +- .../SystemUI/res/values/revengeos_dimens.xml | 21 ++++ packages/SystemUI/res/xml/media_collapsed.xml | 119 +++++++++--------- packages/SystemUI/res/xml/media_expanded.xml | 74 +++++------ .../systemui/media/MediaControlPanel.java | 5 - .../systemui/media/PlayerViewHolder.kt | 2 - .../systemui/screenshot/GlobalScreenshot.java | 22 +++- .../statusbar/notification/row/DungeonRow.kt | 4 - 12 files changed, 136 insertions(+), 131 deletions(-) create mode 100644 packages/SystemUI/res/values/revengeos_dimens.xml diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 2913e11febd5..6e591cf6fece 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -5034,6 +5034,12 @@ public static void setShowGTalkServiceStatusForUser(ContentResolver cr, boolean public static final String[] LEGACY_RESTORE_SETTINGS = { }; + /** + * Whether to enable screenshot sound + * @hide + */ + public static final String SCREENSHOT_SOUND = "screenshot_sound"; + /** * These are all public system settings * diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java index 60e272a80541..e5ef46c1bf53 100644 --- a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java +++ b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java @@ -89,5 +89,6 @@ public class SystemSettings { Settings.System.VOLUME_ROCKER_WAKE, Settings.System.VOLUME_BUTTON_MUSIC_CONTROL, Settings.System.LOCKSCREEN_MEDIA_ART, + Settings.System.SCREENSHOT_SOUND, }; } diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java index 35284e691c52..e8d2a2ec5c38 100644 --- a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java @@ -221,5 +221,6 @@ public boolean validate(@Nullable String value) { VALIDATORS.put(System.KEY_APP_SWITCH_ACTION, new InclusiveIntegerRangeValidator(0, 9)); VALIDATORS.put(System.KEY_APP_SWITCH_LONG_PRESS_ACTION, new InclusiveIntegerRangeValidator(0, 9)); VALIDATORS.put(System.LOCKSCREEN_MEDIA_ART, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.SCREENSHOT_SOUND, BOOLEAN_VALIDATOR); } } diff --git a/packages/SystemUI/res/layout/media_view.xml b/packages/SystemUI/res/layout/media_view.xml index b43ebfef1f3a..9bc91ff40ce1 100644 --- a/packages/SystemUI/res/layout/media_view.xml +++ b/packages/SystemUI/res/layout/media_view.xml @@ -165,16 +165,6 @@ android:paddingBottom="30dp" android:splitTrack="false" /> - - - 350dp 16dp 16dp - 52dp + 120dp 16dp 10dp @dimen/qs_media_icon_size diff --git a/packages/SystemUI/res/values/revengeos_dimens.xml b/packages/SystemUI/res/values/revengeos_dimens.xml new file mode 100644 index 000000000000..5e9d2f42106f --- /dev/null +++ b/packages/SystemUI/res/values/revengeos_dimens.xml @@ -0,0 +1,21 @@ + + + +4dp + +10dp + +48dp + + \ No newline at end of file diff --git a/packages/SystemUI/res/xml/media_collapsed.xml b/packages/SystemUI/res/xml/media_collapsed.xml index ee958f28c51b..9c7c7c712d6f 100644 --- a/packages/SystemUI/res/xml/media_collapsed.xml +++ b/packages/SystemUI/res/xml/media_collapsed.xml @@ -1,6 +1,6 @@ @@ -102,13 +94,14 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="3dp" - android:layout_marginBottom="24dp" + android:layout_marginBottom="@dimen/qqs_media_spacing" + android:layout_marginEnd="@dimen/qs_media_panel_outer_padding" app:layout_constrainedWidth="true" + app:layout_constraintHorizontal_bias="0" + app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/header_title" app:layout_constraintStart_toStartOf="@id/header_title" - app:layout_constraintEnd_toStartOf="@id/media_action_barrier" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintHorizontal_bias="0"/> + /> @@ -158,10 +151,11 @@ android:layout_height="48dp" android:layout_marginStart="4dp" android:layout_marginEnd="4dp" - android:layout_marginTop="18dp" - app:layout_constraintTop_toBottomOf="@id/app_name" + android:layout_marginBottom="@dimen/qs_media_panel_outer_padding" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toRightOf="@id/action0" app:layout_constraintRight_toLeftOf="@id/action2" + app:layout_constraintTop_toBottomOf="@id/header_artist" > @@ -171,10 +165,11 @@ android:layout_height="48dp" android:layout_marginStart="4dp" android:layout_marginEnd="4dp" - android:layout_marginTop="18dp" - app:layout_constraintTop_toBottomOf="@id/app_name" + android:layout_marginBottom="@dimen/qs_media_panel_outer_padding" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toRightOf="@id/action1" app:layout_constraintRight_toLeftOf="@id/action3" + app:layout_constraintTop_toBottomOf="@id/header_artist" > @@ -182,10 +177,11 @@ android:id="@+id/action3" android:layout_width="48dp" android:layout_height="48dp" + android:layout_marginBottom="@dimen/qs_media_panel_outer_padding" android:layout_marginStart="4dp" android:layout_marginEnd="4dp" - android:layout_marginTop="18dp" - app:layout_constraintTop_toBottomOf="@id/app_name" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@id/header_artist" app:layout_constraintLeft_toRightOf="@id/action2" app:layout_constraintRight_toLeftOf="@id/action4" > @@ -195,13 +191,14 @@ android:id="@+id/action4" android:layout_width="48dp" android:layout_height="48dp" - android:layout_marginStart="4dp" - android:layout_marginEnd="4dp" android:visibility="gone" - android:layout_marginTop="18dp" + android:layout_marginBottom="@dimen/qs_media_panel_outer_padding" + android:layout_marginEnd="@dimen/qs_media_panel_outer_padding" + android:layout_marginStart="4dp" app:layout_constraintHorizontal_chainStyle="packed" - app:layout_constraintTop_toBottomOf="@id/app_name" + app:layout_constraintTop_toBottomOf="@id/header_artist" app:layout_constraintLeft_toRightOf="@id/action3" + app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintHorizontal_bias="0" > diff --git a/packages/SystemUI/res/xml/media_expanded.xml b/packages/SystemUI/res/xml/media_expanded.xml index d5a02c2d39d5..dde62a83b0eb 100644 --- a/packages/SystemUI/res/xml/media_expanded.xml +++ b/packages/SystemUI/res/xml/media_expanded.xml @@ -1,6 +1,6 @@ @@ -86,10 +76,10 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginEnd="@dimen/qs_media_panel_outer_padding" - android:layout_marginTop="17dp" - android:layout_marginStart="16dp" + android:layout_marginTop="@dimen/qqs_media_spacing" + android:layout_marginStart="@dimen/qqs_media_spacing" app:layout_constrainedWidth="true" - app:layout_constraintTop_toBottomOf="@+id/app_name" + app:layout_constraintTop_toBottomOf="@+id/icon" app:layout_constraintStart_toEndOf="@id/album_art" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0"/> @@ -112,7 +102,7 @@ android:id="@+id/media_progress_bar" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginTop="3dp" + android:layout_marginTop="35dp" app:layout_constraintTop_toBottomOf="@id/header_artist" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" @@ -122,7 +112,7 @@ android:id="@+id/notification_media_progress_time" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginTop="38dp" + android:layout_marginTop="70dp" android:layout_marginEnd="@dimen/qs_media_panel_outer_padding" android:layout_marginStart="@dimen/qs_media_panel_outer_padding" app:layout_constraintTop_toBottomOf="@id/header_artist" @@ -135,13 +125,12 @@ android:layout_width="48dp" android:layout_height="48dp" android:layout_marginTop="5dp" - android:layout_marginStart="4dp" - android:layout_marginEnd="4dp" + android:layout_marginStart="@dimen/qs_media_panel_outer_padding" android:layout_marginBottom="@dimen/qs_media_panel_outer_padding" app:layout_constraintHorizontal_chainStyle="packed" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toLeftOf="@id/action1" - app:layout_constraintTop_toBottomOf="@id/notification_media_progress_time" + app:layout_constraintTop_toBottomOf="@id/media_progress_bar" app:layout_constraintBottom_toBottomOf="parent"> @@ -154,6 +143,7 @@ android:layout_marginBottom="@dimen/qs_media_panel_outer_padding" app:layout_constraintLeft_toRightOf="@id/action0" app:layout_constraintRight_toLeftOf="@id/action2" + app:layout_constraintTop_toBottomOf="@id/media_progress_bar" app:layout_constraintTop_toTopOf="@id/action0" app:layout_constraintBottom_toBottomOf="parent"> @@ -167,7 +157,7 @@ android:layout_marginBottom="@dimen/qs_media_panel_outer_padding" app:layout_constraintLeft_toRightOf="@id/action1" app:layout_constraintRight_toLeftOf="@id/action3" - app:layout_constraintTop_toTopOf="@id/action0" + app:layout_constraintTop_toBottomOf="@id/media_progress_bar" app:layout_constraintBottom_toBottomOf="parent"> @@ -179,7 +169,7 @@ android:layout_marginEnd="4dp" app:layout_constraintLeft_toRightOf="@id/action2" app:layout_constraintRight_toLeftOf="@id/action4" - app:layout_constraintTop_toTopOf="@id/action0" + app:layout_constraintTop_toBottomOf="@id/media_progress_bar" android:layout_marginBottom="@dimen/qs_media_panel_outer_padding" app:layout_constraintBottom_toBottomOf="parent"> @@ -189,12 +179,12 @@ android:layout_width="48dp" android:layout_height="48dp" android:layout_marginStart="4dp" - android:layout_marginEnd="4dp" + android:layout_marginEnd="@dimen/qs_media_panel_outer_padding" android:layout_marginBottom="@dimen/qs_media_panel_outer_padding" app:layout_constraintHorizontal_chainStyle="packed" app:layout_constraintLeft_toRightOf="@id/action3" app:layout_constraintRight_toRightOf="parent" - app:layout_constraintTop_toTopOf="@id/action0" + app:layout_constraintTop_toBottomOf="@id/media_progress_bar" app:layout_constraintBottom_toBottomOf="parent"> diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java index 149e3dd8cade..eab6035a05a2 100644 --- a/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java +++ b/packages/SystemUI/src/com/android/systemui/media/MediaControlPanel.java @@ -271,11 +271,6 @@ public void bind(@NonNull MediaData data, String key) { titleText.setText(data.getSong()); titleText.setTextColor(mForegroundColor); - // App title - TextView appName = mViewHolder.getAppName(); - appName.setText(data.getApp()); - appName.setTextColor(mForegroundColor); - // Artist name TextView artistText = mViewHolder.getArtistText(); artistText.setText(data.getArtist()); diff --git a/packages/SystemUI/src/com/android/systemui/media/PlayerViewHolder.kt b/packages/SystemUI/src/com/android/systemui/media/PlayerViewHolder.kt index ec9a00dae9ab..37ae07cffda6 100644 --- a/packages/SystemUI/src/com/android/systemui/media/PlayerViewHolder.kt +++ b/packages/SystemUI/src/com/android/systemui/media/PlayerViewHolder.kt @@ -35,7 +35,6 @@ class PlayerViewHolder private constructor(itemView: View) { // Player information val appIcon = itemView.requireViewById(R.id.icon) - val appName = itemView.requireViewById(R.id.app_name) val albumView = itemView.requireViewById(R.id.album_art) val titleText = itemView.requireViewById(R.id.header_title) val artistText = itemView.requireViewById(R.id.header_artist) @@ -106,7 +105,6 @@ class PlayerViewHolder private constructor(itemView: View) { val controlsIds = setOf( R.id.icon, - R.id.app_name, R.id.album_art, R.id.header_title, R.id.header_artist, diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java index 2956e88955c9..2a04b9955f5a 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/GlobalScreenshot.java @@ -51,6 +51,8 @@ import android.graphics.drawable.InsetDrawable; import android.graphics.drawable.LayerDrawable; import android.media.MediaActionSound; +import android.media.Ringtone; +import android.media.RingtoneManager; import android.net.Uri; import android.os.Handler; import android.os.Looper; @@ -221,7 +223,7 @@ abstract static class ActionsReadyListener { private float mCornerSizeX; private float mDismissDeltaY; - private MediaActionSound mCameraSound; + private Ringtone mScreenshotSound; private int mNavMode; private int mLeftInset; @@ -315,9 +317,9 @@ public GlobalScreenshot( mFastOutSlowIn = AnimationUtils.loadInterpolator(mContext, android.R.interpolator.fast_out_slow_in); - // Setup the Camera shutter sound - mCameraSound = new MediaActionSound(); - mCameraSound.load(MediaActionSound.SHUTTER_CLICK); + // Setup the Screenshot sound + mScreenshotSound = RingtoneManager.getRingtone(mContext, + Uri.parse("file://" + "/product/media/audio/ui/camera_click.ogg")); // Store UI background executor mUiBgExecutor = uiBgExecutor; @@ -682,7 +684,11 @@ private void saveScreenshot(Bitmap screenshot, Consumer finisher, Rect scre private void saveScreenshotAndToast(Consumer finisher) { // Play the shutter sound to notify that we've taken a screenshot mScreenshotHandler.post(() -> { - mCameraSound.play(MediaActionSound.SHUTTER_CLICK); + if (Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREENSHOT_SOUND, 1, UserHandle.USER_CURRENT) == 1) { + if (mScreenshotSound != null) { + mScreenshotSound.play(); + } + } }); saveScreenshotInWorkerThread(finisher, new ActionsReadyListener() { @@ -738,7 +744,11 @@ void onActionsReady(SavedImageData imageData) { }); // Play the shutter sound to notify that we've taken a screenshot - mCameraSound.play(MediaActionSound.SHUTTER_CLICK); + if (Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREENSHOT_SOUND, 1, UserHandle.USER_CURRENT) == 1) { + if (mScreenshotSound != null) { + mScreenshotSound.play(); + } + } mScreenshotPreview.setLayerType(View.LAYER_TYPE_HARDWARE, null); mScreenshotPreview.buildLayer(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/DungeonRow.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/DungeonRow.kt index dbfa27f1f68e..5151c38873d8 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/DungeonRow.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/DungeonRow.kt @@ -32,10 +32,6 @@ class DungeonRow(context: Context, attrs: AttributeSet) : LinearLayout(context, } private fun update() { - (findViewById(R.id.app_name) as TextView).apply { - text = entry?.row?.appName - } - (findViewById(R.id.icon) as StatusBarIconView).apply { set(entry?.icons?.statusBarIcon?.statusBarIcon) }