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

Commit 2768fbe7 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Make EmptyShadeView a LaunchableView

This is necessary because origin transitions using the Animation
library's ActivityTransitionAnimator (used internally by the
NotificationActivityStarter) require the view being animated from to be
a LaunchableView to avoid visibility-related flicker.

Since the onClick behavior of the empty shade text is exactly the same
as the footer's manage/history button, we should launch the intent in
the same way for consistency.

Bug: 366003631
Bug: 308591475
Flag: android.app.modes_ui_empty_shade
Flag: EXEMPT unflaggable inheritance change
Test: manually tested that pressing the No notifications text works
correctly when flag is on

Change-Id: I7e8ce55855dd7d5f4599dd4c6dd9b6ce951b9da9
parent b650eb36
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -37,7 +37,10 @@ public interface NotificationActivityStarter {
    void startNotificationGutsIntent(Intent intent, int appUid,
            ExpandableNotificationRow row);

    /** Called when the user clicks "Manage" or "History" in the Shade. */
    /**
     * Called when the user clicks "Manage" or "History" in the Shade, or the "No notifications"
     * text.
     */
    void startHistoryIntent(View view, boolean showHistory);

    /** Called when the user succeed to drop notification to proper target view. */
+35 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.annotation.StringRes;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
@@ -29,12 +30,16 @@ import android.widget.TextView;

import androidx.annotation.NonNull;

import com.android.systemui.animation.LaunchableView;
import com.android.systemui.animation.LaunchableViewDelegate;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.notification.emptyshade.shared.ModesEmptyShadeFix;
import com.android.systemui.statusbar.notification.row.StackScrollerDecorView;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;

public class EmptyShadeView extends StackScrollerDecorView {
import kotlin.Unit;

public class EmptyShadeView extends StackScrollerDecorView implements LaunchableView {

    private TextView mEmptyText;
    private TextView mEmptyFooterText;
@@ -47,6 +52,12 @@ public class EmptyShadeView extends StackScrollerDecorView {
    private @Visibility int mFooterVisibility = View.GONE;
    private int mSize;

    private LaunchableViewDelegate mLaunchableViewDelegate = new LaunchableViewDelegate(this,
            visibility -> {
                super.setVisibility(visibility);
                return Unit.INSTANCE;
            });

    public EmptyShadeView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mSize = getResources().getDimensionPixelSize(
@@ -58,6 +69,29 @@ public class EmptyShadeView extends StackScrollerDecorView {
        }
    }

    @Override
    public void setVisibility(int visibility) {
        mLaunchableViewDelegate.setVisibility(visibility);
    }

    @Override
    public void setShouldBlockVisibilityChanges(boolean block) {
        /* check if */ ModesEmptyShadeFix.isUnexpectedlyInLegacyMode();
        mLaunchableViewDelegate.setShouldBlockVisibilityChanges(block);
    }

    @Override
    public void onActivityLaunchAnimationEnd() {
        /* check if */ ModesEmptyShadeFix.isUnexpectedlyInLegacyMode();
    }

    @Override
    @NonNull
    public Rect getPaddingForLaunchAnimation() {
        /* check if */ ModesEmptyShadeFix.isUnexpectedlyInLegacyMode();
        return new Rect();
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
+6 −9
Original line number Diff line number Diff line
@@ -31,8 +31,6 @@ object EmptyShadeViewBinder {
    ) = coroutineScope {
        launch { viewModel.text.collect { view.setText(it) } }

        // TODO(b/308591475): The view needs to implement LaunchableView for this to work.
        if (false) {
        launch {
            viewModel.tappingShouldLaunchHistory.collect { shouldLaunchHistory ->
                if (shouldLaunchHistory) {
@@ -42,7 +40,6 @@ object EmptyShadeViewBinder {
                }
            }
        }
        }

        launch { bindFooter(view, viewModel) }
    }