Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 544ace4b authored by Julia Tuttle's avatar Julia Tuttle
Browse files

Add hover and pressed states to notification expand button

Fixes: 283804869
Test: manual
Change-Id: I3c1959579f06575ca70e1cf95e24e5721e11fb06
parent bedae25d
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import android.annotation.Nullable;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.util.AttributeSet;
import android.view.RemotableViewMethod;
import android.view.View;
@@ -42,7 +44,7 @@ import java.util.Locale;
@RemoteViews.RemoteView
public class NotificationExpandButton extends FrameLayout {

    private View mPillView;
    private Drawable mPillDrawable;
    private TextView mNumberView;
    private ImageView mIconView;
    private boolean mExpanded;
@@ -73,7 +75,10 @@ public class NotificationExpandButton extends FrameLayout {
    @Override
    protected void 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);
        mIconView = findViewById(R.id.expand_button_icon);
    }
@@ -156,7 +161,7 @@ public class NotificationExpandButton extends FrameLayout {
    private void updateColors() {
        if (shouldShowNumber()) {
            if (mHighlightPillColor != 0) {
                mPillView.setBackgroundTintList(ColorStateList.valueOf(mHighlightPillColor));
                mPillDrawable.setTintList(ColorStateList.valueOf(mHighlightPillColor));
            }
            mIconView.setColorFilter(mHighlightTextColor);
            if (mHighlightTextColor != 0) {
@@ -164,7 +169,7 @@ public class NotificationExpandButton extends FrameLayout {
            }
        } else {
            if (mDefaultPillColor != 0) {
                mPillView.setBackgroundTintList(ColorStateList.valueOf(mDefaultPillColor));
                mPillDrawable.setTintList(ColorStateList.valueOf(mDefaultPillColor));
            }
            mIconView.setColorFilter(mDefaultTextColor);
            if (mDefaultTextColor != 0) {
+21 −0
Original line number Diff line number Diff line
<!--
  ~ 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>
 No newline at end of file
+21 −0
Original line number Diff line number Diff line
<!--
  ~ 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>
 No newline at end of file
+14 −4
Original line number Diff line number Diff line
@@ -13,7 +13,17 @@
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<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" />
            <solid android:color="@android:color/white" />
        </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>
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
        android:background="@drawable/expand_button_pill_bg"
        android:gravity="center_vertical"
        android:layout_gravity="center_vertical"
        android:duplicateParentState="true"
        >

        <TextView
Loading