diff --git a/packages/SystemUI/res/drawable/ic_cast.xml b/packages/SystemUI/res/drawable/ic_cast.xml index a2c2eb2806f6b..fe1d99fa4962e 100644 --- a/packages/SystemUI/res/drawable/ic_cast.xml +++ b/packages/SystemUI/res/drawable/ic_cast.xml @@ -14,8 +14,8 @@ Copyright (C) 2017 The Android Open Source Project limitations under the License. --> diff --git a/packages/SystemUI/res/drawable/ic_cast_connected_fill.xml b/packages/SystemUI/res/drawable/ic_cast_connected_fill.xml new file mode 100644 index 0000000000000..61d524daca3a0 --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_cast_connected_fill.xml @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/stat_sys_cast.xml b/packages/SystemUI/res/drawable/stat_sys_cast.xml index de7ec9d628bb6..6186ead6884fd 100644 --- a/packages/SystemUI/res/drawable/stat_sys_cast.xml +++ b/packages/SystemUI/res/drawable/stat_sys_cast.xml @@ -13,7 +13,4 @@ Copyright (C) 2017 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 + \ No newline at end of file diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index ce958ab3f7394..966df66ec3070 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -60,6 +60,9 @@ @*android:dimen/status_bar_icon_size + + 2.5dp + 13.0dp diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CastDrawable.java b/packages/SystemUI/src/com/android/systemui/statusbar/CastDrawable.java new file mode 100644 index 0000000000000..2f385d04c7938 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/statusbar/CastDrawable.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.systemui.statusbar; + +import android.annotation.NonNull; +import android.annotation.Nullable; +import android.content.res.Resources; +import android.graphics.Canvas; +import android.graphics.Rect; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.DrawableWrapper; +import android.util.AttributeSet; + +import com.android.systemui.R; + +import org.xmlpull.v1.XmlPullParser; +import org.xmlpull.v1.XmlPullParserException; + +import java.io.IOException; + +/** + * The status bar cast drawable draws ic_cast and ic_cast_connected_fill to indicate that the + * screen is being recorded. A simple layer-list drawable isn't used here because the record fill + * must not be tinted by the caller. + */ +public class CastDrawable extends DrawableWrapper { + private Drawable mFillDrawable; + private int mHorizontalPadding; + + /** No-arg constructor used by drawable inflation. */ + public CastDrawable() { + super(null); + } + + @Override + public void inflate(@NonNull Resources r, @NonNull XmlPullParser parser, + @NonNull AttributeSet attrs, @Nullable Resources.Theme theme) + throws XmlPullParserException, IOException { + super.inflate(r, parser, attrs, theme); + setDrawable(r.getDrawable(R.drawable.ic_cast, theme).mutate()); + mFillDrawable = r.getDrawable(R.drawable.ic_cast_connected_fill, theme).mutate(); + mHorizontalPadding = r.getDimensionPixelSize(R.dimen.status_bar_horizontal_padding); + } + + @Override + public boolean canApplyTheme() { + return mFillDrawable.canApplyTheme() || super.canApplyTheme(); + } + + @Override + public void applyTheme(Resources.Theme t) { + super.applyTheme(t); + mFillDrawable.applyTheme(t); + } + + @Override + protected void onBoundsChange(Rect bounds) { + super.onBoundsChange(bounds); + mFillDrawable.setBounds(bounds); + } + + @Override + public boolean onLayoutDirectionChanged(int layoutDirection) { + mFillDrawable.setLayoutDirection(layoutDirection); + return super.onLayoutDirectionChanged(layoutDirection); + } + + @Override + public void draw(Canvas canvas) { + super.draw(canvas); + mFillDrawable.draw(canvas); + } + + @Override + public boolean getPadding(Rect padding) { + padding.left += mHorizontalPadding; + padding.right += mHorizontalPadding; + return true; + } + + @Override + public void setAlpha(int alpha) { + super.setAlpha(alpha); + mFillDrawable.setAlpha(alpha); + } + + @Override + public boolean setVisible(boolean visible, boolean restart) { + mFillDrawable.setVisible(visible, restart); + return super.setVisible(visible, restart); + } + + @Override + public Drawable mutate() { + mFillDrawable.mutate(); + return super.mutate(); + } +} diff --git a/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast.xml b/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast.xml index ff20e484b2c20..05b490f781f7f 100644 --- a/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast.xml +++ b/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast.xml @@ -15,10 +15,10 @@ limitations under the License. --> + android:width="17dp" > diff --git a/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast_connected.xml b/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast_connected.xml index cc181a3a1d8c4..a7547db2a8e54 100644 --- a/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast_connected.xml +++ b/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast_connected.xml @@ -15,10 +15,10 @@ limitations under the License. --> + android:width="24dp" > diff --git a/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast_connected_fill.xml b/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast_connected_fill.xml new file mode 100644 index 0000000000000..18f81e76d5836 --- /dev/null +++ b/packages/overlays/IconPackCircularSystemUIOverlay/res/drawable/ic_cast_connected_fill.xml @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file diff --git a/packages/overlays/IconPackFilledSystemUIOverlay/res/drawable/ic_cast.xml b/packages/overlays/IconPackFilledSystemUIOverlay/res/drawable/ic_cast.xml index 14778556620f2..c13bcf9ef7d67 100644 --- a/packages/overlays/IconPackFilledSystemUIOverlay/res/drawable/ic_cast.xml +++ b/packages/overlays/IconPackFilledSystemUIOverlay/res/drawable/ic_cast.xml @@ -15,10 +15,10 @@ limitations under the License. --> + android:width="17dp" > diff --git a/packages/overlays/IconPackFilledSystemUIOverlay/res/drawable/ic_cast_connected_fill.xml b/packages/overlays/IconPackFilledSystemUIOverlay/res/drawable/ic_cast_connected_fill.xml new file mode 100644 index 0000000000000..1b21db0d95d04 --- /dev/null +++ b/packages/overlays/IconPackFilledSystemUIOverlay/res/drawable/ic_cast_connected_fill.xml @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file diff --git a/packages/overlays/IconPackRoundedSystemUIOverlay/res/drawable/ic_cast.xml b/packages/overlays/IconPackRoundedSystemUIOverlay/res/drawable/ic_cast.xml index 9386e7014a490..fed248aea26ac 100644 --- a/packages/overlays/IconPackRoundedSystemUIOverlay/res/drawable/ic_cast.xml +++ b/packages/overlays/IconPackRoundedSystemUIOverlay/res/drawable/ic_cast.xml @@ -15,10 +15,10 @@ limitations under the License. --> + android:width="17dp" > diff --git a/packages/overlays/IconPackRoundedSystemUIOverlay/res/drawable/ic_cast_connected_fill.xml b/packages/overlays/IconPackRoundedSystemUIOverlay/res/drawable/ic_cast_connected_fill.xml new file mode 100644 index 0000000000000..cadef698d7eb6 --- /dev/null +++ b/packages/overlays/IconPackRoundedSystemUIOverlay/res/drawable/ic_cast_connected_fill.xml @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file