Merge "Add hover and pressed states to notification expand button" into udc-qpr-dev
This commit is contained in:
@@ -21,6 +21,8 @@ import android.annotation.Nullable;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.graphics.drawable.LayerDrawable;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.RemotableViewMethod;
|
import android.view.RemotableViewMethod;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -42,7 +44,7 @@ import java.util.Locale;
|
|||||||
@RemoteViews.RemoteView
|
@RemoteViews.RemoteView
|
||||||
public class NotificationExpandButton extends FrameLayout {
|
public class NotificationExpandButton extends FrameLayout {
|
||||||
|
|
||||||
private View mPillView;
|
private Drawable mPillDrawable;
|
||||||
private TextView mNumberView;
|
private TextView mNumberView;
|
||||||
private ImageView mIconView;
|
private ImageView mIconView;
|
||||||
private boolean mExpanded;
|
private boolean mExpanded;
|
||||||
@@ -73,7 +75,10 @@ public class NotificationExpandButton extends FrameLayout {
|
|||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
mPillView = findViewById(R.id.expand_button_pill);
|
|
||||||
|
final View pillView = findViewById(R.id.expand_button_pill);
|
||||||
|
final LayerDrawable layeredPill = (LayerDrawable) pillView.getBackground();
|
||||||
|
mPillDrawable = layeredPill.findDrawableByLayerId(R.id.expand_button_pill_colorized_layer);
|
||||||
mNumberView = findViewById(R.id.expand_button_number);
|
mNumberView = findViewById(R.id.expand_button_number);
|
||||||
mIconView = findViewById(R.id.expand_button_icon);
|
mIconView = findViewById(R.id.expand_button_icon);
|
||||||
}
|
}
|
||||||
@@ -156,7 +161,7 @@ public class NotificationExpandButton extends FrameLayout {
|
|||||||
private void updateColors() {
|
private void updateColors() {
|
||||||
if (shouldShowNumber()) {
|
if (shouldShowNumber()) {
|
||||||
if (mHighlightPillColor != 0) {
|
if (mHighlightPillColor != 0) {
|
||||||
mPillView.setBackgroundTintList(ColorStateList.valueOf(mHighlightPillColor));
|
mPillDrawable.setTintList(ColorStateList.valueOf(mHighlightPillColor));
|
||||||
}
|
}
|
||||||
mIconView.setColorFilter(mHighlightTextColor);
|
mIconView.setColorFilter(mHighlightTextColor);
|
||||||
if (mHighlightTextColor != 0) {
|
if (mHighlightTextColor != 0) {
|
||||||
@@ -164,7 +169,7 @@ public class NotificationExpandButton extends FrameLayout {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mDefaultPillColor != 0) {
|
if (mDefaultPillColor != 0) {
|
||||||
mPillView.setBackgroundTintList(ColorStateList.valueOf(mDefaultPillColor));
|
mPillDrawable.setTintList(ColorStateList.valueOf(mDefaultPillColor));
|
||||||
}
|
}
|
||||||
mIconView.setColorFilter(mDefaultTextColor);
|
mIconView.setColorFilter(mDefaultTextColor);
|
||||||
if (mDefaultTextColor != 0) {
|
if (mDefaultTextColor != 0) {
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright (C) 2023 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="true" android:color="@android:color/system_on_surface_dark" android:alpha="0.06"/>
|
||||||
|
<item android:state_hovered="true" android:color="@android:color/system_on_surface_dark" android:alpha="0.03"/>
|
||||||
|
<item android:color="@android:color/system_on_surface_dark" android:alpha="0.00"/>
|
||||||
|
</selector>
|
||||||
21
core/res/res/color/notification_expand_button_state_tint.xml
Normal file
21
core/res/res/color/notification_expand_button_state_tint.xml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<!--
|
||||||
|
~ Copyright (C) 2023 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:state_pressed="true" android:color="@android:color/system_on_surface_light" android:alpha="0.12"/>
|
||||||
|
<item android:state_hovered="true" android:color="@android:color/system_on_surface_light" android:alpha="0.08"/>
|
||||||
|
<item android:color="@android:color/system_on_surface_light" android:alpha="0.00"/>
|
||||||
|
</selector>
|
||||||
@@ -13,7 +13,17 @@
|
|||||||
~ See the License for the specific language governing permissions and
|
~ See the License for the specific language governing permissions and
|
||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@+id/expand_button_pill_colorized_layer">
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<corners android:radius="@dimen/notification_expand_button_pill_height" />
|
<corners android:radius="@dimen/notification_expand_button_pill_height" />
|
||||||
<solid android:color="@android:color/white" />
|
<solid android:color="@android:color/white" />
|
||||||
</shape>
|
</shape>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<corners android:radius="@dimen/notification_expand_button_pill_height" />
|
||||||
|
<solid android:color="@color/notification_expand_button_state_tint" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
</layer-list>
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
android:background="@drawable/expand_button_pill_bg"
|
android:background="@drawable/expand_button_pill_bg"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
android:duplicateParentState="true"
|
||||||
>
|
>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -3050,6 +3050,7 @@
|
|||||||
<java-symbol type="id" name="header_text_secondary" />
|
<java-symbol type="id" name="header_text_secondary" />
|
||||||
<java-symbol type="id" name="expand_button" />
|
<java-symbol type="id" name="expand_button" />
|
||||||
<java-symbol type="id" name="expand_button_pill" />
|
<java-symbol type="id" name="expand_button_pill" />
|
||||||
|
<java-symbol type="id" name="expand_button_pill_colorized_layer" />
|
||||||
<java-symbol type="id" name="expand_button_number" />
|
<java-symbol type="id" name="expand_button_number" />
|
||||||
<java-symbol type="id" name="expand_button_icon" />
|
<java-symbol type="id" name="expand_button_icon" />
|
||||||
<java-symbol type="id" name="alternate_expand_target" />
|
<java-symbol type="id" name="alternate_expand_target" />
|
||||||
|
|||||||
Reference in New Issue
Block a user