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

Commit 646d2054 authored by Selim Cinek's avatar Selim Cinek
Browse files

Improved notification transformations

All views are now faded, even if they are not handled specially

Change-Id: I2970548667e0388984098293ac0dfcbdbed12df1
parent 0ffbda62
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@
    <item type="id" name="clip_children_set_tag" />
    <item type="id" name="clip_to_padding_tag" />
    <item type="id" name="image_icon_tag" />
    <item type="id" name="contains_transformed_view" />
    <item type="id" name="is_clicked_heads_up_tag" />
</resources>
+49 −0
Original line number Diff line number Diff line
@@ -19,13 +19,20 @@ package com.android.systemui.statusbar;
import android.os.Handler;
import android.util.ArrayMap;
import android.view.View;
import android.view.ViewGroup;

import com.android.systemui.R;
import com.android.systemui.statusbar.notification.TransformState;

import java.util.Stack;

/**
 * A view that can be transformed to and from.
 */
public class ViewTransformationHelper implements TransformableView {

    private static final int TAG_CONTAINS_TRANSFORMED_VIEW = R.id.contains_transformed_view;

    private final Handler mHandler = new Handler();
    private ArrayMap<Integer, View> mTransformedViews = new ArrayMap<>();

@@ -105,4 +112,46 @@ public class ViewTransformationHelper implements TransformableView {
            }
        }
    }

    /**
     * Add the remaining transformation views such that all views are being transformed correctly
     * @param viewRoot the root below which all elements need to be transformed
     */
    public void addRemainingTransformTypes(View viewRoot) {
        // lets now tag the right views
        int numValues = mTransformedViews.size();
        for (int i = 0; i < numValues; i++) {
            View view = mTransformedViews.valueAt(i);
            while (view != viewRoot.getParent()) {
                view.setTag(TAG_CONTAINS_TRANSFORMED_VIEW, true);
                view = (View) view.getParent();
            }
        }
        Stack<View> stack = new Stack<>();
        // Add the right views now
        stack.push(viewRoot);
        while (!stack.isEmpty()) {
            View child = stack.pop();
            if (child.getVisibility() == View.GONE) {
                continue;
            }
            Boolean containsView = (Boolean) child.getTag(TAG_CONTAINS_TRANSFORMED_VIEW);
            if (containsView == null) {
                // This one is unhandled, let's add it to our list.
                int id = child.getId();
                if (id != View.NO_ID) {
                    // We only fade views with an id
                    addTransformedView(id, child);
                    continue;
                }
            }
            child.setTag(TAG_CONTAINS_TRANSFORMED_VIEW, null);
            if (child instanceof ViewGroup && !mTransformedViews.containsValue(child)){
                ViewGroup group = (ViewGroup) child;
                for (int i = 0; i < group.getChildCount(); i++) {
                    stack.push(group.getChildAt(i));
                }
            }
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public class ImageTransformState extends TransformState {
    @Override
    protected boolean sameAs(TransformState otherState) {
        if (otherState instanceof ImageTransformState) {
            return mIcon.sameAs(((ImageTransformState) otherState).getIcon());
            return mIcon != null && mIcon.sameAs(((ImageTransformState) otherState).getIcon());
        }
        return super.sameAs(otherState);
    }
+12 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.drawable.Drawable;
import android.service.notification.StatusBarNotification;
import android.util.ArrayMap;
import android.view.NotificationHeaderView;
import android.view.View;
import android.view.ViewGroup;
@@ -41,6 +42,7 @@ import com.android.systemui.statusbar.TransformableView;
import com.android.systemui.statusbar.ViewTransformationHelper;
import com.android.systemui.statusbar.phone.NotificationPanelView;

import java.util.Collection;
import java.util.Stack;

/**
@@ -99,9 +101,19 @@ public class NotificationHeaderViewWrapper extends NotificationViewWrapper {
        resolveHeaderViews();
        updateInvertHelper();
        updateTransformedTypes();
        addRemainingTransformTypes();
        updateCropToPaddingForImageViews();
    }

    /**
     * Adds the remaining TransformTypes to the TransformHelper. This is done to make sure that each
     * child is faded automatically and doesn't have to be manually added.
     * The keys used for the views are the ids.
     */
    private void addRemainingTransformTypes() {
        mTransformationHelper.addRemainingTransformTypes(mView);
    }

    /**
     * Since we are deactivating the clipping when transforming the ImageViews don't get clipped
     * anymore during these transitions. We can avoid that by using
+2 −11
Original line number Diff line number Diff line
@@ -60,19 +60,10 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp

    @Override
    public void notifyContentUpdated(StatusBarNotification notification) {
        // Reinspect the notification.
        // Reinspect the notification. Before the super call, because the super call also updates
        // the transformation types and we need to have our values set by then.
        resolveTemplateViews(notification);
        super.notifyContentUpdated(notification);
        addRemainingTransformTypes();
    }

    /**
     * Adds the remaining TransformTypes to the TransformHelper. This is done to make sure that each
     * child is faded automatically and doesn't have to be manually added.
     * The keys used for the views are the ids.
     */
    private void addRemainingTransformTypes() {

    }

    @Override
Loading