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

Commit 34f2ac94 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

Create NotificationOptimizedLinearLayout

This CL introduces a custom LinearLayout class that overrides the onMeasure method.
For a specific layout pattern (a LinearLayout, whose width is match_parent, with one weighted child), this custom class will strategically measure unweighted views first
 and then measure the weighted view with remaining space.
This allows it to calculate the correct layout dimensions in a single pass, avoiding the performance overhead of the double measurement

Bug: 316110233
Test: presubmit + silver test + screenshot test of Messaging Notifications
Flag: ACONFIG notif_linearlayout_optimized DEVELOPMENT
Change-Id: I012824cb9cb24c95e5d29d8a3a9f8dde359fef96
parent 74f4fa70
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -55,7 +55,9 @@ import java.util.List;
 * A message of a {@link MessagingLayout}.
 */
@RemoteViews.RemoteView
public class MessagingGroup extends LinearLayout implements MessagingLinearLayout.MessagingChild {
public class MessagingGroup extends NotificationOptimizedLinearLayout implements
        MessagingLinearLayout.MessagingChild {

    private static final MessagingPool<MessagingGroup> sInstancePool =
            new MessagingPool<>(10);

+578 −0

File added.

Preview size limit exceeded, changes collapsed.

+3 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import java.util.ArrayList;
 * MessagingLayouts where groups need to be able to snap it's height to.
 */
@RemoteViews.RemoteView
public class RemeasuringLinearLayout extends LinearLayout {
public class RemeasuringLinearLayout extends NotificationOptimizedLinearLayout {

    private ArrayList<View> mMatchParentViews = new ArrayList<>();

@@ -87,4 +87,5 @@ public class RemeasuringLinearLayout extends LinearLayout {
        mMatchParentViews.clear();
        setMeasuredDimension(getMeasuredWidth(), height);
    }

}
+330 −0

File added.

Preview size limit exceeded, changes collapsed.

+5 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.systemui.statusbar.notification.row

import android.widget.flags.Flags.notifLinearlayoutOptimized
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import javax.inject.Inject
@@ -31,6 +32,7 @@ constructor(
    precomputedTextViewFactory: PrecomputedTextViewFactory,
    bigPictureLayoutInflaterFactory: BigPictureLayoutInflaterFactory,
    callLayoutSetDataAsyncFactory: CallLayoutSetDataAsyncFactory,
    optimizedLinearLayoutFactory: NotificationOptimizedLinearLayoutFactory
) : NotifRemoteViewsFactoryContainer {
    override val factories: Set<NotifRemoteViewsFactory> = buildSet {
        add(precomputedTextViewFactory)
@@ -40,5 +42,8 @@ constructor(
        if (featureFlags.isEnabled(Flags.CALL_LAYOUT_ASYNC_SET_DATA)) {
            add(callLayoutSetDataAsyncFactory)
        }
        if (notifLinearlayoutOptimized()) {
            add(optimizedLinearLayoutFactory)
        }
    }
}
Loading