From 47811b478d7e52f4cb6e5e22dad727662fce1403 Mon Sep 17 00:00:00 2001 From: Beth Thibodeau Date: Wed, 22 Apr 2020 01:22:39 -0400 Subject: [PATCH] Update screen record icons Replace icon drawable and add content descriptions for the status bar icon Bug: 152412892 Fixes: 153518579 Test: manual Change-Id: I0ee6f0856d96a8e56fcd04ff33512076cc491c8d --- .../drawable/ic_screen_record_background.xml | 18 +++++------ .../SystemUI/res/drawable/ic_screenrecord.xml | 18 +++++------ packages/SystemUI/res/values/colors.xml | 2 ++ packages/SystemUI/res/values/dimens.xml | 5 ++- .../systemui/qs/tiles/ScreenRecordTile.java | 6 +--- .../statusbar/ScreenRecordDrawable.java | 32 +++++++++++++++---- .../statusbar/phone/PhoneStatusBarPolicy.java | 6 ++-- 7 files changed, 53 insertions(+), 34 deletions(-) diff --git a/packages/SystemUI/res/drawable/ic_screen_record_background.xml b/packages/SystemUI/res/drawable/ic_screen_record_background.xml index 9195305e6681d..59eb023d937df 100644 --- a/packages/SystemUI/res/drawable/ic_screen_record_background.xml +++ b/packages/SystemUI/res/drawable/ic_screen_record_background.xml @@ -13,13 +13,11 @@ Copyright (C) 2020 The Android Open Source Project See the License for the specific language governing permissions and limitations under the License. --> - - - + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/ic_screenrecord.xml b/packages/SystemUI/res/drawable/ic_screenrecord.xml index 6d8bd0dd66fb3..d4f807a4700e2 100644 --- a/packages/SystemUI/res/drawable/ic_screenrecord.xml +++ b/packages/SystemUI/res/drawable/ic_screenrecord.xml @@ -1,7 +1,7 @@ + android:width="24dp" + android:height="24dp" + android:viewportWidth="24.0" + android:viewportHeight="24.0" + android:tint="?android:attr/colorControlNormal"> + android:fillColor="#FFFFFFFF" + android:pathData="M12,16c-2.21,0 -4,-1.79 -4,-4c0,-2.21 1.79,-4 4,-4c2.21,0 4,1.79 4,4C16,14.21 14.21,16 12,16zM11.99,1.99c-2.22,0 -4.26,0.73 -5.92,1.96l1.44,1.44c1.28,-0.87 2.82,-1.39 4.49,-1.39c1.67,0 3.21,0.52 4.5,1.4l1.44,-1.44C16.26,2.72 14.22,1.99 11.99,1.99zM16.48,18.6c-1.28,0.87 -2.82,1.39 -4.49,1.39c-1.66,0 -3.2,-0.52 -4.47,-1.39l-1.44,1.44c1.66,1.22 3.7,1.95 5.91,1.95c2.22,0 4.26,-0.73 5.92,-1.95L16.48,18.6zM5.39,16.49c-0.88,-1.28 -1.4,-2.83 -1.4,-4.5c0,-1.66 0.52,-3.21 1.39,-4.49L3.95,6.07c-1.22,1.66 -1.95,3.7 -1.95,5.92c0,2.22 0.73,4.27 1.96,5.93L5.39,16.49zM20.04,6.08l-1.44,1.44c0.87,1.28 1.39,2.82 1.39,4.47c0,1.66 -0.52,3.2 -1.39,4.49l1.44,1.44c1.22,-1.66 1.96,-3.7 1.96,-5.92C21.99,9.78 21.26,7.73 20.04,6.08z"/> diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index b6776005d83e6..46c6092e799f0 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -257,4 +257,6 @@ #F28B82 + + #E94235 diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 99e347eb1a696..307fb29847b4c 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1318,7 +1318,10 @@ 18dp 24dp 14sp - 5dp + 7dp + 21dp + 17.5dp + 8dp 16sp diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java index da78903249502..d7dd6f24ceb32 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java @@ -79,19 +79,15 @@ public class ScreenRecordTile extends QSTileImpl state.value = isRecording || isStarting; state.state = (isRecording || isStarting) ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE; state.label = mContext.getString(R.string.quick_settings_screen_record_label); + state.icon = ResourceIcon.get(R.drawable.ic_screenrecord); if (isRecording) { - state.icon = ResourceIcon.get(R.drawable.ic_qs_screenrecord); state.secondaryLabel = mContext.getString(R.string.quick_settings_screen_record_stop); } else if (isStarting) { // round, since the timer isn't exact int countdown = (int) Math.floorDiv(mMillisUntilFinished + 500, 1000); - // TODO update icon - state.icon = ResourceIcon.get(R.drawable.ic_qs_screenrecord); state.secondaryLabel = String.format("%d...", countdown); } else { - // TODO update icon - state.icon = ResourceIcon.get(R.drawable.ic_qs_screenrecord); state.secondaryLabel = mContext.getString(R.string.quick_settings_screen_record_start); } state.contentDescription = TextUtils.isEmpty(state.secondaryLabel) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ScreenRecordDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/ScreenRecordDrawable.java index 44ef6b448002b..006b219d8e61c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/ScreenRecordDrawable.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/ScreenRecordDrawable.java @@ -39,10 +39,13 @@ import java.io.IOException; */ public class ScreenRecordDrawable extends DrawableWrapper { private Drawable mFillDrawable; + private Drawable mIconDrawable; private int mHorizontalPadding; private int mLevel; private float mTextSize; - private float mIconRadius; + private int mIconRadius; + private int mWidthPx; + private int mHeightPx; private Paint mPaint; /** No-arg constructor used by drawable inflation. */ @@ -57,6 +60,7 @@ public class ScreenRecordDrawable extends DrawableWrapper { super.inflate(r, parser, attrs, theme); setDrawable(r.getDrawable(R.drawable.ic_screen_record_background, theme).mutate()); mFillDrawable = r.getDrawable(R.drawable.ic_screen_record_background, theme).mutate(); + mIconDrawable = r.getDrawable(R.drawable.ic_screenrecord, theme).mutate(); mHorizontalPadding = r.getDimensionPixelSize(R.dimen.status_bar_horizontal_padding); mTextSize = r.getDimensionPixelSize(R.dimen.screenrecord_status_text_size); @@ -68,6 +72,19 @@ public class ScreenRecordDrawable extends DrawableWrapper { mPaint.setColor(Color.WHITE); mPaint.setTextSize(mTextSize); mPaint.setFakeBoldText(true); + + mWidthPx = r.getDimensionPixelSize(R.dimen.screenrecord_status_icon_width); + mHeightPx = r.getDimensionPixelSize(R.dimen.screenrecord_status_icon_height); + } + + @Override + public int getIntrinsicWidth() { + return mWidthPx; + } + + @Override + public int getIntrinsicHeight() { + return mHeightPx; } @Override @@ -103,10 +120,14 @@ public class ScreenRecordDrawable extends DrawableWrapper { String val = String.valueOf(mLevel); Rect textBounds = new Rect(); mPaint.getTextBounds(val, 0, val.length(), textBounds); - float yOffset = textBounds.height() / 4; // half, and half again since it's centered - canvas.drawText(val, b.centerX(), b.centerY() + yOffset, mPaint); + canvas.drawText(val, b.centerX(), b.centerY() + textBounds.height() / 2, mPaint); } else { - canvas.drawCircle(b.centerX(), b.centerY() - mIconRadius / 2, mIconRadius, mPaint); + Rect iconBounds = new Rect(b.centerX() - mIconRadius, + b.centerY() - mIconRadius, + b.centerX() + mIconRadius, + b.centerY() + mIconRadius); + mIconDrawable.setBounds(iconBounds); + mIconDrawable.draw(canvas); } } @@ -114,9 +135,6 @@ public class ScreenRecordDrawable extends DrawableWrapper { public boolean getPadding(Rect padding) { padding.left += mHorizontalPadding; padding.right += mHorizontalPadding; - padding.top = 0; - padding.bottom = 0; - android.util.Log.d("ScreenRecordDrawable", "set zero top/bottom pad"); return true; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java index d4f4d3bfbb544..a065b74bda997 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java @@ -663,6 +663,7 @@ public class PhoneStatusBarPolicy if (DEBUG) Log.d(TAG, "screenrecord: countdown " + millisUntilFinished); int countdown = (int) Math.floorDiv(millisUntilFinished + 500, 1000); int resourceId = R.drawable.stat_sys_screen_record; + String description = Integer.toString(countdown); switch (countdown) { case 1: resourceId = R.drawable.stat_sys_screen_record_1; @@ -674,7 +675,7 @@ public class PhoneStatusBarPolicy resourceId = R.drawable.stat_sys_screen_record_3; break; } - mIconController.setIcon(mSlotScreenRecord, resourceId, null); + mIconController.setIcon(mSlotScreenRecord, resourceId, description); mIconController.setIconVisibility(mSlotScreenRecord, true); } @@ -688,7 +689,8 @@ public class PhoneStatusBarPolicy public void onRecordingStart() { if (DEBUG) Log.d(TAG, "screenrecord: showing icon"); mIconController.setIcon(mSlotScreenRecord, - R.drawable.stat_sys_screen_record, null); + R.drawable.stat_sys_screen_record, + mResources.getString(R.string.screenrecord_ongoing_screen_only)); mIconController.setIconVisibility(mSlotScreenRecord, true); }