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

Commit c0dd0da4 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Use a switch statement instead of static list of layouts

The static list is not very scalable when we need to add things behind
flags, so let's just use a switch statement.

Bug: 378660052
Test: presubmint
Flag: android.app.notifications_redesign_templates
Change-Id: I560c6f7c09cd82860dd17a9af2e6cfc88455cd05
parent 9af1abd4
Loading
Loading
Loading
Loading
+21 −9
Original line number Diff line number Diff line
@@ -811,20 +811,32 @@ public class Notification implements Parcelable
    }
    private static boolean isStandardLayout(int layoutId) {
        // TODO: b/359128724 - Add to static list when inlining the flag.
        if (Flags.notificationsRedesignTemplates()) {
            return switch (layoutId) {
                case R.layout.notification_2025_template_collapsed_base,
                     R.layout.notification_2025_template_header,
                     R.layout.notification_template_material_heads_up_base,
                     R.layout.notification_template_material_big_base,
                     R.layout.notification_template_material_big_picture,
                     R.layout.notification_template_material_big_text,
                     R.layout.notification_template_material_inbox,
                     R.layout.notification_template_material_messaging,
                     R.layout.notification_template_material_big_messaging,
                     R.layout.notification_template_material_conversation,
                     R.layout.notification_template_material_media,
                     R.layout.notification_template_material_big_media,
                     R.layout.notification_template_material_call,
                     R.layout.notification_template_material_big_call,
                     R.layout.notification_template_header -> true;
                case R.layout.notification_template_material_progress -> Flags.apiRichOngoing();
                default -> false;
            };
        }
        if (Flags.apiRichOngoing()) {
            if (layoutId == R.layout.notification_template_material_progress) {
                return true;
            }
        }
        // TODO: b/378660052 - Add to static list when inlining the flag.
        if (Flags.notificationsRedesignTemplates()) {
            switch(layoutId) {
                case R.layout.notification_2025_template_collapsed_base:
                case R.layout.notification_2025_template_header:
                    return true;
            }
        }
        return STANDARD_LAYOUTS.contains(layoutId);
    }