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

Commit eaebc654 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Inline controls redesign" into rvc-dev

parents e8572720 143441a5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -121,7 +121,6 @@
                android:layout_marginEnd="2dp"
                android:ellipsize="end"
                android:text="@string/notification_delegate_header"
                android:layout_toEndOf="@id/pkg_divider"
                android:maxLines="1" />

        </LinearLayout>
+66 −151
Original line number Diff line number Diff line
@@ -27,51 +27,81 @@
    android:paddingStart="@*android:dimen/notification_content_margin_start">

    <!-- Package Info -->
    <RelativeLayout
    <LinearLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_height="@dimen/notification_guts_conversation_header_height"
        android:gravity="center_vertical"
        android:clipChildren="false"
        android:clipToPadding="false">
        <ImageView
            android:id="@+id/pkgicon"
            android:layout_width="@dimen/notification_guts_header_height"
            android:layout_height="@dimen/notification_guts_header_height"
            android:id="@+id/pkg_icon"
            android:layout_width="@dimen/notification_guts_conversation_icon_size"
            android:layout_height="@dimen/notification_guts_conversation_icon_size"
            android:layout_centerVertical="true"
            android:layout_alignParentStart="true"
            android:layout_marginEnd="3dp" />
            android:layout_marginEnd="15dp" />
        <LinearLayout
            android:id="@+id/names"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:orientation="vertical"

            android:layout_height="wrap_content"
            android:minHeight="@dimen/notification_guts_conversation_icon_size"
            android:layout_centerVertical="true"
            android:gravity="center_vertical"
            android:layout_alignEnd="@id/pkg_icon"
            android:layout_toEndOf="@id/pkg_icon"
            android:layout_alignStart="@id/mute">
            <TextView
                android:id="@+id/channel_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/TextAppearance.NotificationImportanceChannel"/>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="start"
                android:orientation="horizontal">
                <TextView
            android:id="@+id/pkgname"
                    android:id="@+id/pkg_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            style="@style/TextAppearance.NotificationImportanceHeader"
            android:layout_marginStart="3dp"
            android:layout_marginEnd="2dp"
            android:layout_toEndOf="@id/pkgicon"
            android:singleLine="true" />
                    style="@style/TextAppearance.NotificationImportanceChannelGroup"
                    android:ellipsize="end"
                    android:maxLines="1"/>
                <TextView
            android:id="@+id/pkg_divider"
                    android:id="@+id/group_divider"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerVertical="true"
                    style="@style/TextAppearance.NotificationImportanceHeader"
                    android:layout_marginStart="2dp"
                    android:layout_marginEnd="2dp"
            android:layout_toEndOf="@id/pkgname"
                    android:text="@*android:string/notification_header_divider_symbol" />
                <TextView
            android:id="@+id/delegate_name"
                    android:id="@+id/group_name"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    style="@style/TextAppearance.NotificationImportanceChannel"/>
            </LinearLayout>
            <TextView
                android:id="@+id/delegate_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                style="@style/TextAppearance.NotificationImportanceHeader"
                android:layout_marginStart="2dp"
                android:layout_marginEnd="2dp"
                android:ellipsize="end"
                android:text="@string/notification_delegate_header"
            android:layout_toEndOf="@id/pkg_divider"
                android:maxLines="1" />

        </LinearLayout>

        <!-- end aligned fields -->
        <!-- Optional link to app. Only appears if the channel is not disabled and the app
asked for it -->
        <ImageButton
@@ -95,91 +125,6 @@ asked for it -->
            android:src="@drawable/ic_settings"
            android:layout_alignParentEnd="true"
            android:tint="@color/notification_guts_link_icon_tint"/>
    </RelativeLayout>

    <!-- Channel Info Block -->
    <LinearLayout
        android:id="@+id/channel_info"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingEnd="@*android:dimen/notification_content_margin_end"
        android:gravity="center"
        android:orientation="vertical">
        <!-- Channel Name -->
        <TextView
            android:id="@+id/channel_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            style="@style/TextAppearance.NotificationImportanceChannel"/>
        <TextView
            android:id="@+id/group_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/TextAppearance.NotificationImportanceChannelGroup"
            android:ellipsize="end"
            android:maxLines="1"/>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/blocking_helper"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/notification_guts_button_spacing"
        android:layout_marginBottom="@dimen/notification_guts_button_spacing"
        android:paddingEnd="@*android:dimen/notification_content_margin_end"
        android:clipChildren="false"
        android:clipToPadding="false"
        android:orientation="vertical">
        <!-- blocking helper text. no need for non-configurable check b/c controls won't be
        activated in that case -->
        <TextView
            android:id="@+id/blocking_helper_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="2dp"
            android:text="@string/inline_blocking_helper"
            style="@*android:style/TextAppearance.DeviceDefault.Notification" />
        <RelativeLayout
            android:id="@+id/block_buttons"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/notification_guts_button_spacing">
            <TextView
                android:id="@+id/blocking_helper_turn_off_notifications"
                android:text="@string/inline_turn_off_notifications"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_alignParentStart="true"
                android:width="110dp"
                android:paddingEnd="15dp"
                android:breakStrategy="simple"
                style="@style/TextAppearance.NotificationInfo.Button"/>
            <TextView
                android:id="@+id/deliver_silently"
                android:text="@string/inline_deliver_silently_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginStart="@dimen/notification_guts_button_horizontal_spacing"
                android:paddingEnd="15dp"
                android:width="110dp"
                android:breakStrategy="simple"
                android:layout_toStartOf="@+id/keep_showing"
                style="@style/TextAppearance.NotificationInfo.Button"/>
            <TextView
                android:id="@+id/keep_showing"
                android:text="@string/inline_keep_button"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_marginStart="@dimen/notification_guts_button_horizontal_spacing"
                android:width="110dp"
                android:breakStrategy="simple"
                android:layout_alignParentEnd="true"
                style="@style/TextAppearance.NotificationInfo.Button"/>
        </RelativeLayout>

    </LinearLayout>

@@ -357,34 +302,4 @@ asked for it -->
        </RelativeLayout>

    </LinearLayout>

    <com.android.systemui.statusbar.notification.row.NotificationUndoLayout
        android:id="@+id/confirmation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:visibility="gone"
        android:orientation="horizontal" >
        <TextView
            android:id="@+id/confirmation_text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="start|center_vertical"
            android:layout_marginStart="@*android:dimen/notification_content_margin_start"
            android:layout_marginEnd="@*android:dimen/notification_content_margin_start"
            android:text="@string/notification_channel_disabled"
            style="@style/TextAppearance.NotificationInfo.Confirmation"/>
        <TextView
            android:id="@+id/undo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:minWidth="@dimen/notification_importance_toggle_size"
            android:minHeight="@dimen/notification_importance_toggle_size"
            android:layout_marginTop="@dimen/notification_guts_button_spacing"
            android:layout_marginBottom="@dimen/notification_guts_button_spacing"
            android:layout_marginStart="@dimen/notification_guts_button_side_margin"
            android:layout_marginEnd="@dimen/notification_guts_button_side_margin"
            android:layout_gravity="end|center_vertical"
            android:text="@string/inline_undo"
            style="@style/TextAppearance.NotificationInfo.Button"/>
    </com.android.systemui.statusbar.notification.row.NotificationUndoLayout>
</com.android.systemui.statusbar.notification.row.NotificationInfo>
+0 −4
Original line number Diff line number Diff line
@@ -315,7 +315,6 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
                    mNotificationActivityStarter.startNotificationGutsIntent(intent, sbn.getUid(),
                            row);
                };
        boolean isForBlockingHelper = row.isBlockingHelperShowing();

        if (!userHandle.equals(UserHandle.ALL)
                || mLockscreenUserManager.getCurrentUserId() == UserHandle.USER_SYSTEM) {
@@ -335,13 +334,10 @@ public class NotificationGutsManager implements Dumpable, NotificationLifetimeEx
                row.getEntry().getChannel(),
                row.getUniqueChannels(),
                row.getEntry(),
                mCheckSaveListener,
                onSettingsClick,
                onAppSettingsClick,
                mDeviceProvisionedController.isDeviceProvisioned(),
                row.getIsNonblockable(),
                isForBlockingHelper,
                row.getEntry().getImportance(),
                mHighPriorityProvider.isHighPriority(row.getEntry()));
    }

+17 −253

File changed.

Preview size limit exceeded, changes collapsed.

+0 −139
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.notification.row;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;

import com.android.systemui.R;

/**
 * Custom view for the NotificationInfo confirmation views so that the confirmation text can
 * occupy the full width of the notification and push the undo button down to the next line if
 * necessary.
 *
 * @see NotificationInfo
 */
public class NotificationUndoLayout extends FrameLayout {
    /**
     * View for the prompt/confirmation text to tell the user the previous action was successful.
     */
    private View mConfirmationTextView;
    /** Undo button (actionable text) view. */
    private View mUndoView;

    /**
     * Whether {@link #mConfirmationTextView} is multiline and will require the full width of the
     * parent (which causes the {@link #mUndoView} to push down).
     */
    private boolean mIsMultiline = false;
    private int mMultilineTopMargin;

    public NotificationUndoLayout(Context context) {
        this(context, null);
    }

    public NotificationUndoLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public NotificationUndoLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }
    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();

        mConfirmationTextView = findViewById(R.id.confirmation_text);
        mUndoView = findViewById(R.id.undo);

        mMultilineTopMargin = getResources().getDimensionPixelOffset(
                com.android.internal.R.dimen.notification_content_margin_start);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        LayoutParams confirmationLayoutParams =
                (LayoutParams) mConfirmationTextView.getLayoutParams();
        LayoutParams undoLayoutParams =(LayoutParams) mUndoView.getLayoutParams();

        int measuredWidth = getMeasuredWidth();
        // Ignore the left margin on the undo button - no need for additional extra space between
        // the text and the button.
        int requiredWidth = mConfirmationTextView.getMeasuredWidth()
                + confirmationLayoutParams.rightMargin
                + confirmationLayoutParams.leftMargin
                + mUndoView.getMeasuredWidth()
                + undoLayoutParams.rightMargin;
        // If the measured width isn't enough to accommodate both the undo button and the text in
        // the same line, we'll need to adjust the view to be multi-line. Otherwise, we're done.
        if (requiredWidth > measuredWidth) {
            mIsMultiline = true;

            // Update height requirement to the text height and the button's height (along with
            // additional spacing for the top of the text).
            int updatedHeight = mMultilineTopMargin
                    + mConfirmationTextView.getMeasuredHeight()
                    + mUndoView.getMeasuredHeight()
                    + undoLayoutParams.topMargin
                    + undoLayoutParams.bottomMargin;

            setMeasuredDimension(measuredWidth, updatedHeight);
        } else {
            mIsMultiline = false;
        }
    }

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        // If the text view and undo view don't fit on the same line, we'll need to manually lay
        // out the content.
        if (mIsMultiline) {
            // Re-align parent right/bottom values. Left and top are considered to be 0.
            int parentBottom = getMeasuredHeight();
            int parentRight = getMeasuredWidth();

            LayoutParams confirmationLayoutParams =
                    (LayoutParams) mConfirmationTextView.getLayoutParams();
            LayoutParams undoLayoutParams = (LayoutParams) mUndoView.getLayoutParams();

            // The confirmation text occupies the full width as computed earlier. Both side margins
            // are equivalent, so we only need to grab the left one here.
            mConfirmationTextView.layout(
                    confirmationLayoutParams.leftMargin,
                    mMultilineTopMargin,
                    confirmationLayoutParams.leftMargin + mConfirmationTextView.getMeasuredWidth(),
                    mMultilineTopMargin + mConfirmationTextView.getMeasuredHeight());

            // The undo button is aligned bottom|end with the parent in the case of multiline text.
            int undoViewLeft = getLayoutDirection() == View.LAYOUT_DIRECTION_RTL
                    ? undoLayoutParams.rightMargin
                    : parentRight - mUndoView.getMeasuredWidth() - undoLayoutParams.rightMargin;
            mUndoView.layout(
                    undoViewLeft,
                    parentBottom - mUndoView.getMeasuredHeight() - undoLayoutParams.bottomMargin,
                    undoViewLeft + mUndoView.getMeasuredWidth(),
                    parentBottom - undoLayoutParams.bottomMargin);
        } else {
            super.onLayout(changed, left, top, right, bottom);
        }
    }
}
Loading