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

Commit 181385ce authored by Adrian Roos's avatar Adrian Roos
Browse files

Keep RemoteInputView visible when focused

Scrolls the NotificationStackScrollLayout in response to movement
to ensure that the focused view stays visible. Also makes sure that
the action list is always aligned at the bottom of the notification
to avoid jank during this scrolling when the height changes.

Fixes: 28193862
Fixes: 26919632
Change-Id: I911a873367fe26eafd9fae4bca4e693d0827eba7
parent 99aa4415
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@
    <com.android.internal.widget.NotificationActionListLayout
            android:id="@+id/actions"
            android:layout_width="match_parent"
            android:layout_height="56dp"
            android:layout_height="@dimen/notification_action_list_height"
            android:paddingEnd="4dp"
            android:orientation="horizontal"
            android:gravity="center_vertical"
+3 −0
Original line number Diff line number Diff line
@@ -152,6 +152,9 @@
    <!-- The margin on the end of the content view with a picture.-->
    <dimen name="notification_content_picture_margin">56dp</dimen>

    <!-- The height of the notification action list -->
    <dimen name="notification_action_list_height">56dp</dimen>

    <!-- height of the content margin to accomodate for the header -->
    <dimen name="notification_content_margin_top">37.5dp</dimen>

+2 −0
Original line number Diff line number Diff line
@@ -2584,6 +2584,8 @@
  <java-symbol type="dimen" name="input_extract_action_button_width" />
  <java-symbol type="dimen" name="input_extract_action_button_height" />

  <java-symbol type="dimen" name="notification_action_list_height" />

  <!-- TV Remote Service package -->
  <java-symbol type="string" name="config_tvRemoteServicePackage" />

+41 −5
Original line number Diff line number Diff line
@@ -374,10 +374,42 @@ public class NotificationContentView extends FrameLayout {
        mContentHeight = Math.max(Math.min(contentHeight, getHeight()), getMinHeight());;
        mUnrestrictedContentHeight = Math.max(contentHeight, getMinHeight());
        selectLayout(mAnimate /* animate */, false /* force */);

        int minHeightHint = getMinContentHeightHint();

        NotificationViewWrapper wrapper = getVisibleWrapper(mVisibleType);
        if (wrapper != null) {
            wrapper.setContentHeight(mContentHeight, minHeightHint);
        }

        wrapper = getVisibleWrapper(mTransformationStartVisibleType);
        if (wrapper != null) {
            wrapper.setContentHeight(mContentHeight, minHeightHint);
        }

        updateClipping();
        invalidateOutline();
    }

    /**
     * @return the minimum apparent height that the wrapper should allow for the purpose
     *         of aligning elements at the bottom edge. If this is larger than the content
     *         height, the notification is clipped instead of being further shrunk.
     */
    private int getMinContentHeightHint() {
        if (mIsChildInGroup && (mVisibleType == VISIBLE_TYPE_SINGLELINE
                || mTransformationStartVisibleType == VISIBLE_TYPE_SINGLELINE)) {
            return mContext.getResources().getDimensionPixelSize(
                        com.android.internal.R.dimen.notification_action_list_height);
        }
        if (mHeadsUpChild != null) {
            return mHeadsUpChild.getHeight();
        } else {
            return mContractedChild.getHeight() + mContext.getResources().getDimensionPixelSize(
                com.android.internal.R.dimen.notification_action_list_height);
        }
    }

    private void updateContentTransformation() {
        int visibleType = calculateVisibleType();
        if (visibleType != mVisibleType) {
@@ -498,6 +530,10 @@ public class NotificationContentView extends FrameLayout {
                    visibleView.setVisibility(VISIBLE);
                    transferRemoteInputFocus(visibleType);
                }
                NotificationViewWrapper visibleWrapper = getVisibleWrapper(visibleType);
                if (visibleWrapper != null) {
                    visibleWrapper.setContentHeight(mContentHeight, getMinContentHeightHint());
                }

                if (animate && ((visibleType == VISIBLE_TYPE_EXPANDED && mExpandedChild != null)
                        || (visibleType == VISIBLE_TYPE_HEADSUP && mHeadsUpChild != null)
+60 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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;

import android.text.Layout;
import android.text.TextUtils;
import android.util.Pools;
import android.view.View;
import android.widget.TextView;

/**
 * A transform state of the action list
*/
public class ActionListTransformState extends TransformState {

    private static Pools.SimplePool<ActionListTransformState> sInstancePool
            = new Pools.SimplePool<>(40);

    @Override
    protected boolean sameAs(TransformState otherState) {
        return otherState instanceof ActionListTransformState;
    }

    public static ActionListTransformState obtain() {
        ActionListTransformState instance = sInstancePool.acquire();
        if (instance != null) {
            return instance;
        }
        return new ActionListTransformState();
    }

    @Override
    protected void resetTransformedView() {
        // We need to keep the Y transformation, because this is used to keep the action list
        // aligned at the bottom, unrelated to transforms.
        float y = getTransformedView().getTranslationY();
        super.resetTransformedView();
        getTransformedView().setTranslationY(y);
    }

    @Override
    public void recycle() {
        super.recycle();
        sInstancePool.release(this);
    }
}
Loading