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

Commit f37a0a06 authored by Selim Cinek's avatar Selim Cinek Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'groups'

* changes:
  Changed the appearance of the notification children
  Removed the devider above the actions
  Collapsing groups now on the lockscreen
  Fixed a bug where groups were layouted too small
  Fixed a small measuring but with the notification header
  Fixed a bug where legacy icons where incorrectly colored
  Removed duplicate content from group notification header
parents 7ed26b10 7b83639c
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.NotificationHeaderView;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.RemoteViews;
@@ -3000,6 +3001,7 @@ public class Notification implements Parcelable
         */
        private void resetNotificationHeader(RemoteViews contentView) {
            contentView.setImageViewResource(R.id.icon, 0);
            contentView.setBoolean(R.id.notification_header, "setExpanded", false);
            contentView.setTextViewText(R.id.app_name_text, null);
            contentView.setViewVisibility(R.id.chronometer, View.GONE);
            contentView.setViewVisibility(R.id.header_sub_text, View.GONE);
@@ -3134,6 +3136,8 @@ public class Notification implements Parcelable
        private void bindExpandButton(RemoteViews contentView) {
            contentView.setDrawableParameters(R.id.expand_button, false, -1, resolveColor(),
                    PorterDuff.Mode.SRC_ATOP, -1);
            contentView.setInt(R.id.notification_header, "setOriginalNotificationColor",
                    resolveColor());
        }

        private void bindHeaderChronometerAndTime(RemoteViews contentView) {
@@ -3197,7 +3201,6 @@ public class Notification implements Parcelable

        private void resetStandardTemplateWithActions(RemoteViews big) {
            big.setViewVisibility(R.id.actions, View.GONE);
            big.setViewVisibility(R.id.action_divider, View.GONE);
            big.removeAllViews(R.id.actions);
        }

@@ -3209,7 +3212,6 @@ public class Notification implements Parcelable
            int N = mActions.size();
            if (N > 0) {
                big.setViewVisibility(R.id.actions, View.VISIBLE);
                big.setViewVisibility(R.id.action_divider, View.VISIBLE);
                if (N>MAX_ACTION_BUTTONS) N=MAX_ACTION_BUTTONS;
                for (int i=0; i<N; i++) {
                    final RemoteViews button = generateActionButton(mActions.get(i));
@@ -3276,11 +3278,7 @@ public class Notification implements Parcelable
        }

        private void adaptNotificationHeaderForBigContentView(RemoteViews result) {
            // We have to set the collapse button instead
            result.setImageViewResource(R.id.expand_button, R.drawable.ic_arrow_up_14dp);
            // Apply the color again
            result.setDrawableParameters(R.id.expand_button, false, -1, resolveColor(),
                    PorterDuff.Mode.SRC_ATOP, -1);
            result.setBoolean(R.id.notification_header, "setExpanded", true);
        }

        /**
@@ -3352,10 +3350,14 @@ public class Notification implements Parcelable
         * Apply any necessariy colors to the small icon
         */
        private void processSmallIconColor(Icon smallIcon, RemoteViews contentView) {
            if (!isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon)) {
            boolean colorable = !isLegacy() || getColorUtil().isGrayscaleIcon(mContext, smallIcon);
            if (colorable) {
                contentView.setDrawableParameters(R.id.icon, false, -1, resolveColor(),
                        PorterDuff.Mode.SRC_ATOP, -1);

            }
            contentView.setInt(R.id.notification_header, "setOriginalIconColor",
                    colorable ? resolveColor() : NotificationHeaderView.NO_COLOR);
        }

        /**
+62 −4
Original line number Diff line number Diff line
@@ -17,10 +17,10 @@
package android.view;

import android.annotation.Nullable;
import android.app.Notification;
import android.content.Context;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RemoteViews;
import android.widget.TextView;
@@ -34,14 +34,20 @@ import java.util.ArrayList;
 */
@RemoteViews.RemoteView
public class NotificationHeaderView extends LinearLayout {
    public static final int NO_COLOR = -1;
    private final int mHeaderMinWidth;
    private final int mExpandTopPadding;
    private View mAppName;
    private View mSubTextView;
    private OnClickListener mExpandClickListener;
    private HeaderTouchListener mTouchListener = new HeaderTouchListener();
    private View mExpandButton;
    private ImageView mExpandButton;
    private View mIcon;
    private TextView mChildCount;
    private int mIconColor;
    private int mOriginalNotificationColor;
    private boolean mGroupHeader;
    private boolean mExpanded;

    public NotificationHeaderView(Context context) {
        this(context, null);
@@ -59,6 +65,7 @@ public class NotificationHeaderView extends LinearLayout {
        super(context, attrs, defStyleAttr, defStyleRes);
        mHeaderMinWidth = getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.notification_header_shrink_min_width);
        mExpandTopPadding = (int) (1 * getResources().getDisplayMetrics().density);
    }

    @Override
@@ -66,7 +73,7 @@ public class NotificationHeaderView extends LinearLayout {
        super.onFinishInflate();
        mAppName = findViewById(com.android.internal.R.id.app_name_text);
        mSubTextView = findViewById(com.android.internal.R.id.header_sub_text);
        mExpandButton = findViewById(com.android.internal.R.id.expand_button);
        mExpandButton = (ImageView) findViewById(com.android.internal.R.id.expand_button);
        mIcon = findViewById(com.android.internal.R.id.icon);
        mChildCount = (TextView) findViewById(com.android.internal.R.id.number_of_children);
    }
@@ -98,7 +105,7 @@ public class NotificationHeaderView extends LinearLayout {
            int overFlow = totalWidth - givenWidth;
            // We are overflowing, lets shrink
            final int appWidth = mAppName.getMeasuredWidth();
            if (appWidth > mHeaderMinWidth) {
            if (mAppName.getVisibility() != GONE && appWidth > mHeaderMinWidth) {
                int newSize = appWidth - Math.min(appWidth - mHeaderMinWidth, overFlow);
                int childWidthSpec = MeasureSpec.makeMeasureSpec(newSize, MeasureSpec.AT_MOST);
                mAppName.measure(childWidthSpec, wrapContentHeightSpec);
@@ -146,6 +153,57 @@ public class NotificationHeaderView extends LinearLayout {
        }
    }

    @RemotableViewMethod
    public void setOriginalIconColor(int color) {
        mIconColor = color;
    }

    public int getOriginalIconColor() {
        return mIconColor;
    }

    @RemotableViewMethod
    public void setOriginalNotificationColor(int color) {
        mOriginalNotificationColor = color;
    }

    public int getOriginalNotificationColor() {
        return mOriginalNotificationColor;
    }

    public void setIsGroupHeader(boolean isGroupHeader) {
        mGroupHeader = isGroupHeader;
        updateExpandButton();
    }

    @RemotableViewMethod
    public void setExpanded(boolean expanded) {
        mExpanded = expanded;
        updateExpandButton();
    }

    private void updateExpandButton() {
        int drawableId;
        int paddingTop = 0;
        if (mGroupHeader) {
            if (mExpanded) {
                drawableId = com.android.internal.R.drawable.ic_collapse_bundle;
            } else {
                drawableId =com.android.internal.R.drawable.ic_expand_bundle;
            }
        } else {
            if (mExpanded) {
                drawableId = com.android.internal.R.drawable.ic_collapse_notification;
            } else {
                drawableId = com.android.internal.R.drawable.ic_expand_notification;
            }
            paddingTop = mExpandTopPadding;
        }
        mExpandButton.setImageDrawable(getContext().getDrawable(drawableId));
        mExpandButton.setColorFilter(mOriginalNotificationColor);
        mExpandButton.setPadding(0, paddingTop, 0, 0);
    }

    public class HeaderTouchListener implements View.OnTouchListener {

        private final ArrayList<Rect> mTouchRects = new ArrayList<>();
+0 −24
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2015 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
  -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="14.0dp"
        android:height="14.0dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:pathData="M12.000000,8.000000l-6.000000,6.000000 1.400000,1.400000 4.600000,-4.599999 4.600000,4.599999 1.400000,-1.400000z"
        android:fillColor="#FF000000"/>
</vector>
+6 −6
Original line number Diff line number Diff line
@@ -20,6 +20,6 @@ Copyright (C) 2015 The Android Open Source Project
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:pathData="M16.600000,8.600000l-4.600000,4.599999 -4.600000,-4.599999 -1.400000,1.400000 6.000000,6.000000 6.000000,-6.000000z"
        android:fillColor="#FF000000"/>
        android:fillColor="#FF000000"
        android:pathData="M12.0,10.0l5.3,-5.2l-1.4,-1.4L12.0,7.2L8.2,3.4L6.8,4.8L12.0,10.0zM6.8,19.2l1.4,1.4l3.8,-3.8l3.9,3.8l1.4,-1.4L12.0,14.0L6.8,19.2z"/>
</vector>
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="14.0dp"
        android:height="14.0dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0">
    <path
        android:fillColor="#FF000000"
        android:pathData="M12.0,8.0l-6.0,6.0l1.4,1.4l4.6,-4.6l4.6,4.6L18.0,14.0L12.0,8.0z"/>
    <path
        android:pathData="M0,0h24v24H0V0z"
        android:fillColor="#00000000"/>
</vector>
Loading