Merge "Update screen record icons" into rvc-dev am: ec5ab8b1d4

Change-Id: Idd43bf1f69d4df5204b920c7ba9577e2ac82079c
This commit is contained in:
TreeHugger Robot
2020-05-13 01:23:57 +00:00
committed by Automerger Merge Worker
7 changed files with 53 additions and 34 deletions

View File

@@ -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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?android:attr/colorError"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M10,0L14,0A10,10 0,0 1,24 10L24,10A10,10 0,0 1,14 20L10,20A10,10 0,0 1,0 10L0,10A10,10 0,0 1,10 0z"
android:fillColor="@android:color/white"/>
</vector>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@color/screenrecord_status_color"
android:width="@dimen/screenrecord_status_icon_width"
android:height="@dimen/screenrecord_status_icon_height" />
<corners android:radius="@dimen/screenrecord_status_icon_bg_radius" />
</shape>

View File

@@ -1,7 +1,7 @@
<!--
Copyright (C) 2020 The Android Open Source Project
Copyright (C) 2020 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@@ -14,12 +14,12 @@
limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
android:pathData="M12,12m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0"
android:fillColor="#FFFFFFFF"/>
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"/>
</vector>

View File

@@ -257,4 +257,6 @@
<!-- Docked misalignment message -->
<color name="misalignment_text_color">#F28B82</color>
<color name="screenrecord_status_color">#E94235</color>
</resources>

View File

@@ -1323,7 +1323,10 @@
<dimen name="screenrecord_dialog_padding">18dp</dimen>
<dimen name="screenrecord_logo_size">24dp</dimen>
<dimen name="screenrecord_status_text_size">14sp</dimen>
<dimen name="screenrecord_status_icon_radius">5dp</dimen>
<dimen name="screenrecord_status_icon_radius">7dp</dimen>
<dimen name="screenrecord_status_icon_width">21dp</dimen>
<dimen name="screenrecord_status_icon_height">17.5dp</dimen>
<dimen name="screenrecord_status_icon_bg_radius">8dp</dimen>
<dimen name="kg_user_switcher_text_size">16sp</dimen>

View File

@@ -79,19 +79,15 @@ public class ScreenRecordTile extends QSTileImpl<QSTile.BooleanState>
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)

View File

@@ -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;
}

View File

@@ -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);
}