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

Commit 9481b358 authored by Julia Tuttle's avatar Julia Tuttle
Browse files

HeadsUpUtil: Log TAG_CLICKED_NOTIFICATION changes

We're trying to fix a bug where HUNs don't disappear properly when
tapped, and we've got a cause identified, but the fix throws a bit of a
wrench into the animations.

This tag is useful information about how the animations are behaving, so
log changes to it.

Bug: 249840069
Test: manual
Change-Id: I4d912223aafeba628c9420bb7b2a64850d6c79ca
parent ccb4330c
Loading
Loading
Loading
Loading
+44 −0
Original line number Diff line number Diff line
@@ -16,9 +16,15 @@

package com.android.systemui.statusbar.policy;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.util.Log;
import android.view.View;

import com.android.systemui.R;
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
import com.android.systemui.util.Compile;

/**
 * A class of utility static methods for heads up notifications.
@@ -26,12 +32,18 @@ import com.android.systemui.R;
public final class HeadsUpUtil {
    private static final int TAG_CLICKED_NOTIFICATION = R.id.is_clicked_heads_up_tag;

    private static final String LOG_TAG = "HeadsUpUtil";
    private static final boolean LOG_DEBUG = Compile.IS_DEBUG && Log.isLoggable(LOG_TAG, Log.DEBUG);

    /**
     * Set the given view as clicked or not-clicked.
     * @param view The view to be set the flag to.
     * @param clicked True to set as clicked. False to not-clicked.
     */
    public static void setNeedsHeadsUpDisappearAnimationAfterClick(View view, boolean clicked) {
        if (LOG_DEBUG) {
            logTagClickedNotificationChanged(view, clicked);
        }
        view.setTag(TAG_CLICKED_NOTIFICATION, clicked ? true : null);
    }

@@ -44,4 +56,36 @@ public final class HeadsUpUtil {
        Boolean clicked = (Boolean) view.getTag(TAG_CLICKED_NOTIFICATION);
        return clicked != null && clicked;
    }

    private static void logTagClickedNotificationChanged(@Nullable View view, boolean isClicked) {
        if (view == null) {
            return;
        }

        final boolean wasClicked = isClickedHeadsUpNotification(view);
        if (isClicked == wasClicked) {
            return;
        }

        Log.d(LOG_TAG, getViewKey(view) + ": TAG_CLICKED_NOTIFICATION set to " + isClicked);
    }

    private static @NonNull String getViewKey(@NonNull View view) {
        if (!(view instanceof ExpandableNotificationRow)) {
            return "(not a row)";
        }

        final ExpandableNotificationRow row = (ExpandableNotificationRow) view;
        final NotificationEntry entry = row.getEntry();
        if (entry == null) {
            return "(null entry)";
        }

        final String key = entry.getKey();
        if (key == null) {
            return "(null key)";
        }

        return key;
    }
}