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

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

Merge "Add additional UI logging for bubble click events."

parents 7179c272 b00225be
Loading
Loading
Loading
Loading
+30 −1
Original line number Diff line number Diff line
@@ -34,8 +34,10 @@ import android.graphics.drawable.ShapeDrawable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.provider.Settings;
import android.service.notification.StatusBarNotification;
import android.util.AttributeSet;
import android.util.Log;
import android.util.StatsLog;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageButton;
@@ -234,6 +236,8 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
            mStackView.collapseStack(() -> {
                try {
                    n.contentIntent.send();
                    logBubbleClickEvent(mEntry.notification,
                            StatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_APP);
                } catch (PendingIntent.CanceledException e) {
                    Log.w(TAG, "Failed to send intent for bubble with key: "
                            + (mEntry != null ? mEntry.key : " null entry"));
@@ -242,7 +246,11 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
        } else if (id == R.id.settings_button) {
            Intent intent = getSettingsIntent(mEntry.notification.getPackageName(),
                    mEntry.notification.getUid());
            mStackView.collapseStack(() -> mContext.startActivity(intent));
            mStackView.collapseStack(() -> {
                mContext.startActivity(intent);
                logBubbleClickEvent(mEntry.notification,
                        StatsLog.BUBBLE_UICHANGED__ACTION__HEADER_GO_TO_SETTINGS);
            });
        } else if (id == R.id.no_bubbles_button) {
            setBubblesAllowed(false);
        } else if (id == R.id.yes_bubbles_button) {
@@ -262,6 +270,9 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
            } else if (mOnBubbleBlockedListener != null) {
                mOnBubbleBlockedListener.onBubbleBlocked(mEntry);
            }
            logBubbleClickEvent(mEntry.notification,
                    allowed ? StatsLog.BUBBLE_UICHANGED__ACTION__PERMISSION_OPT_IN :
                            StatsLog.BUBBLE_UICHANGED__ACTION__PERMISSION_OPT_OUT);
        } catch (RemoteException e) {
            Log.w(TAG, e);
        }
@@ -318,4 +329,22 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList
         */
        void onBubbleBlocked(NotificationEntry entry);
    }

    /**
     * Logs bubble UI click event.
     *
     * @param notification the bubble notification that user is interacting with.
     * @param action the user interaction enum.
     */
    private void logBubbleClickEvent(StatusBarNotification notification, int action) {
        StatsLog.write(StatsLog.BUBBLE_UI_CHANGED,
                notification.getPackageName(),
                notification.getNotification().getChannelId(),
                notification.getId(),
                mStackView.getBubbleIndex(mStackView.getExpandedBubble()),
                mStackView.getBubbleCount(),
                action,
                mStackView.getNormalizedXPosition(),
                mStackView.getNormalizedYPosition());
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -773,7 +773,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
    /**
     * @return the number of bubbles in the stack view.
     */
    private int getBubbleCount() {
    public int getBubbleCount() {
        return mBubbleContainer.getChildCount();
    }

@@ -784,14 +784,14 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
     * @return the index of the bubble view within the bubble stack. The range of the position
     * is between 0 and the bubble count minus 1.
     */
    private int getBubbleIndex(BubbleView bubbleView) {
    public int getBubbleIndex(BubbleView bubbleView) {
        return mBubbleContainer.indexOfChild(bubbleView);
    }

    /**
     * @return the normalized x-axis position of the bubble stack rounded to 4 decimal places.
     */
    private float getNormalizedXPosition() {
    public float getNormalizedXPosition() {
        return new BigDecimal(getPosition().x / mDisplaySize.x)
                .setScale(4, RoundingMode.CEILING.HALF_UP)
                .floatValue();
@@ -800,7 +800,7 @@ public class BubbleStackView extends FrameLayout implements BubbleTouchHandler.F
    /**
     * @return the normalized y-axis position of the bubble stack rounded to 4 decimal places.
     */
    private float getNormalizedYPosition() {
    public float getNormalizedYPosition() {
        return new BigDecimal(getPosition().y / mDisplaySize.y)
                .setScale(4, RoundingMode.CEILING.HALF_UP)
                .floatValue();