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

Commit d5808587 authored by Ibrahim Yilmaz's avatar Ibrahim Yilmaz
Browse files

[RONs] Create ProgressStyle Expanded Template

This CL creates ProgressStyle template and binds start and end icons.

Bug: 370497239
Test: Presubmit && check the attacted ProgressStyle expanded view screenshot
Flag: android.app.api_rich_ongoing
Change-Id: I2ea492b471074125a5ce21a2a7e77764aabcc393
parent c09e63ed
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
@@ -810,6 +810,11 @@ public class Notification implements Parcelable
    }
    private static boolean isStandardLayout(int layoutId) {
        if (Flags.apiRichOngoing()) {
            if (layoutId == R.layout.notification_template_material_progress) {
                return true;
            }
        }
        return STANDARD_LAYOUTS.contains(layoutId);
    }
@@ -7683,6 +7688,10 @@ public class Notification implements Parcelable
            return R.layout.notification_template_material_conversation;
        }
        private int getProgressLayoutResource() {
            return R.layout.notification_template_material_progress;
        }
        private int getActionLayoutResource() {
            return R.layout.notification_material_action;
        }
@@ -11640,6 +11649,37 @@ public class Notification implements Parcelable
            return getStandardView(mBuilder.getHeadsUpBaseLayoutResource(), p, null /* result */);
        }
        /**
         * @hide
         */
        @Override
        public RemoteViews makeBigContentView() {
            StandardTemplateParams p = mBuilder.mParams.reset()
                    .viewType(StandardTemplateParams.VIEW_TYPE_BIG)
                    .allowTextWithProgress(true)
                    .fillTextsFrom(mBuilder);
            // Replace the text with the big text, but only if the big text is not empty.
            RemoteViews contentView = getStandardView(mBuilder.getProgressLayoutResource(), p,
                    null /* result */);
            // Bind progress start and end icons.
            if (mStartIcon != null) {
                contentView.setViewVisibility(R.id.notification_progress_start_icon, View.VISIBLE);
                contentView.setImageViewIcon(R.id.notification_progress_start_icon, mStartIcon);
            } else {
                contentView.setViewVisibility(R.id.notification_progress_start_icon, View.GONE);
            }
            if (mEndIcon != null) {
                contentView.setViewVisibility(R.id.notification_progress_end_icon, View.VISIBLE);
                contentView.setImageViewIcon(R.id.notification_progress_end_icon, mEndIcon);
            } else {
                contentView.setViewVisibility(R.id.notification_progress_end_icon, View.GONE);
            }
            return contentView;
        }
        private static @NonNull ArrayList<Bundle> getProgressSegmentsAsBundleList(
                @Nullable List<Segment> progressSegments) {
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2010 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="#00000000" />
    <corners android:radius="4dp" />
</shape>
 No newline at end of file
+121 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?><!--
  ~ Copyright (C) 2024 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/status_bar_latest_event_content"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:clipChildren="false"
    android:tag="progress"
    >

    <LinearLayout
        android:id="@+id/notification_action_list_margin_target"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="@dimen/notification_content_margin"
        android:orientation="vertical"
        >

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="top"
            >

            <include layout="@layout/notification_template_header" />

            <LinearLayout
                android:id="@+id/notification_main_column"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/notification_content_margin_start"
                android:layout_marginEnd="@dimen/notification_content_margin_end"
                android:layout_marginTop="@dimen/notification_content_margin_top"
                android:orientation="vertical"
                >

                <include layout="@layout/notification_template_part_line1" />

                <include layout="@layout/notification_template_text_multiline" />

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center_vertical"
                    android:layout_marginTop="@dimen/notification_progress_margin_top"
                    android:orientation="horizontal">

                    <com.android.internal.widget.CachingIconView
                        android:id="@+id/notification_progress_start_icon"
                        android:layout_width="@dimen/notification_progress_icon_size"
                        android:layout_height="@dimen/notification_progress_icon_size"
                        android:background="@drawable/notification_progress_icon_background"
                        android:clipToOutline="true"
                        android:importantForAccessibility="no"
                        android:layout_marginEnd="@dimen/notification_progress_margin_horizontal"
                        android:scaleType="centerCrop"
                        android:maxDrawableWidth="@dimen/notification_progress_icon_size"
                        android:maxDrawableHeight="@dimen/notification_progress_icon_size"
                        />


                    <include
                        android:layout_width="0dp"
                        android:layout_height="@dimen/notification_progress_bar_height"
                        layout="@layout/notification_template_progress"
                        android:layout_weight="1"
                        />

                    <com.android.internal.widget.CachingIconView
                        android:id="@+id/notification_progress_end_icon"
                        android:layout_width="@dimen/notification_progress_icon_size"
                        android:layout_height="@dimen/notification_progress_icon_size"
                        android:background="@drawable/notification_progress_icon_background"
                        android:clipToOutline="true"
                        android:importantForAccessibility="no"
                        android:scaleType="centerCrop"
                        android:layout_marginStart="@dimen/notification_progress_margin_horizontal"
                        android:maxDrawableWidth="@dimen/notification_progress_icon_size"
                        android:maxDrawableHeight="@dimen/notification_progress_icon_size"
                        />
                </LinearLayout>
            </LinearLayout>

            <include layout="@layout/notification_template_right_icon" />
        </FrameLayout>

        <ViewStub
            android:layout="@layout/notification_material_reply_text"
            android:id="@+id/notification_material_reply_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            />

        <include
            layout="@layout/notification_template_smart_reply_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/notification_content_margin_start"
            android:layout_marginEnd="@dimen/notification_content_margin_end"
            android:layout_marginTop="@dimen/notification_content_margin"
            />

        <include layout="@layout/notification_material_action_list" />
    </LinearLayout>
</FrameLayout>
 No newline at end of file
+3 −0
Original line number Diff line number Diff line
@@ -304,6 +304,9 @@
    <!-- The top margin before the notification progress bar. -->
    <dimen name="notification_progress_margin_top">8dp</dimen>

    <!-- The horizontal margin before and after the notification progress bar. -->
    <dimen name="notification_progress_margin_horizontal">2dp</dimen>

    <!-- height of the notification header -->
    <dimen name="notification_header_height">56dp</dimen>

+5 −0
Original line number Diff line number Diff line
@@ -224,6 +224,8 @@
  <java-symbol type="id" name="status_bar_latest_event_content" />
  <java-symbol type="id" name="notification_main_column" />
  <java-symbol type="id" name="notification_headerless_view_column" />
  <java-symbol type="id" name="notification_progress_start_icon" />
  <java-symbol type="id" name="notification_progress_end_icon" />
  <java-symbol type="id" name="sms_short_code_confirm_message" />
  <java-symbol type="id" name="sms_short_code_detail_layout" />
  <java-symbol type="id" name="sms_short_code_detail_message" />
@@ -2390,6 +2392,7 @@
  <java-symbol type="layout" name="notification_template_material_media" />
  <java-symbol type="layout" name="notification_template_material_big_media" />
  <java-symbol type="layout" name="notification_template_material_big_text" />
  <java-symbol type="layout" name="notification_template_material_progress" />
  <java-symbol type="layout" name="notification_template_header" />
  <java-symbol type="layout" name="notification_material_media_action" />
  <java-symbol type="color" name="notification_progress_background_color" />
@@ -3205,6 +3208,7 @@
  <java-symbol type="dimen" name="notification_heading_margin_end" />
  <java-symbol type="dimen" name="notification_content_margin_top" />
  <java-symbol type="dimen" name="notification_content_margin" />
  <java-symbol type="dimen" name="notification_progress_margin_horizontal" />
  <java-symbol type="dimen" name="notification_header_background_height" />
  <java-symbol type="dimen" name="notification_header_touchable_height" />
  <java-symbol type="dimen" name="notification_header_expand_icon_size" />
@@ -4076,6 +4080,7 @@
  <java-symbol type="dimen" name="text_size_body_2_material" />
  <java-symbol type="dimen" name="notification_icon_circle_size" />
  <java-symbol type="drawable" name="notification_icon_circle" />
  <java-symbol type="drawable" name="notification_progress_icon_background" />
  <java-symbol type="dimen" name="messaging_avatar_size" />
  <java-symbol type="dimen" name="messaging_group_sending_progress_size" />
  <java-symbol type="dimen" name="messaging_image_rounding" />