Merge "Reinflate all headers when locale changes" into rvc-dev
diff --git a/packages/SystemUI/res/layout/status_bar_notification_section_header.xml b/packages/SystemUI/res/layout/status_bar_notification_section_header.xml
index 44c409e..b5822c8 100644
--- a/packages/SystemUI/res/layout/status_bar_notification_section_header.xml
+++ b/packages/SystemUI/res/layout/status_bar_notification_section_header.xml
@@ -35,7 +35,34 @@
         android:forceHasOverlappingRendering="false"
         android:clipChildren="false"
         >
-        <include layout="@layout/status_bar_notification_section_header_contents"/>
+        <FrameLayout
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:gravity="start|center_vertical"
+            android:layout_weight="1">
+
+            <TextView
+                style="@style/TextAppearance.NotificationSectionHeaderButton"
+                android:id="@+id/header_label"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:forceHasOverlappingRendering="false"
+                android:text="@string/notification_section_header_gentle"
+            />
+
+        </FrameLayout>
+        <ImageView
+            android:id="@+id/btn_clear_all"
+            android:layout_width="48dp"
+            android:layout_height="48dp"
+            android:src="@drawable/status_bar_notification_section_header_clear_btn"
+            android:contentDescription="@string/accessibility_notification_section_header_gentle_clear_all"
+            android:scaleType="center"
+            android:tint="?attr/wallpaperTextColor"
+            android:tintMode="src_in"
+            android:visibility="gone"
+            android:forceHasOverlappingRendering="false"
+        />
     </LinearLayout>
 
 </com.android.systemui.statusbar.notification.stack.SectionHeaderView>
diff --git a/packages/SystemUI/res/layout/status_bar_notification_section_header_contents.xml b/packages/SystemUI/res/layout/status_bar_notification_section_header_contents.xml
deleted file mode 100644
index 3b9c44d..0000000
--- a/packages/SystemUI/res/layout/status_bar_notification_section_header_contents.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<!--
-  ~ Copyright (C) 2019 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
-  -->
-
-<!-- Used by both status_bar_notification_header and SectionHeaderView -->
-<merge xmlns:android="http://schemas.android.com/apk/res/android" >
-    <FrameLayout
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:gravity="start|center_vertical"
-        android:layout_weight="1">
-
-        <TextView
-            style="@style/TextAppearance.NotificationSectionHeaderButton"
-            android:id="@+id/header_label"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:forceHasOverlappingRendering="false"
-            android:text="@string/notification_section_header_gentle"
-        />
-
-    </FrameLayout>
-    <ImageView
-        android:id="@+id/btn_clear_all"
-        android:layout_width="48dp"
-        android:layout_height="48dp"
-        android:src="@drawable/status_bar_notification_section_header_clear_btn"
-        android:contentDescription="@string/accessibility_notification_section_header_gentle_clear_all"
-        android:scaleType="center"
-        android:tint="?attr/wallpaperTextColor"
-        android:tintMode="src_in"
-        android:visibility="gone"
-        android:forceHasOverlappingRendering="false"
-    />
-</merge>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java
index 42a7c6a..f6f8363 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.java
@@ -447,7 +447,6 @@
         }
     }
 
-
     @VisibleForTesting
     ExpandableView getGentleHeaderView() {
         return mGentleHeader;
@@ -471,7 +470,7 @@
     private final ConfigurationListener mConfigurationListener = new ConfigurationListener() {
         @Override
         public void onLocaleListChanged() {
-            mGentleHeader.reinflateContents();
+            reinflateViews(LayoutInflater.from(mParent.getContext()));
         }
     };
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/PeopleHubView.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/PeopleHubView.kt
index 1b4f98f..bc25c71 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/PeopleHubView.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/PeopleHubView.kt
@@ -76,9 +76,7 @@
             }
         }
 
-    override fun needsClippingToShelf(): Boolean {
-        return true
-    }
+    override fun needsClippingToShelf(): Boolean = true
 
     override fun applyContentTransformation(contentAlpha: Float, translationY: Float) {
         super.applyContentTransformation(contentAlpha, translationY)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/SectionHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/SectionHeaderView.java
index deb5532..a3d8eec 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/SectionHeaderView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/SectionHeaderView.java
@@ -20,7 +20,6 @@
 import android.annotation.StringRes;
 import android.content.Context;
 import android.util.AttributeSet;
-import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.ViewGroup;
@@ -30,16 +29,17 @@
 import com.android.systemui.R;
 import com.android.systemui.statusbar.notification.row.StackScrollerDecorView;
 
-import java.util.Objects;
-
 /**
- * Similar in size and appearance to the NotificationShelf, appears at the beginning of some
- * notification sections. Currently only used for gentle notifications.
+ * Header displayed above a notification section in the shade. Currently used for Alerting and
+ * Silent sections.
  */
 public class SectionHeaderView extends StackScrollerDecorView {
+
     private ViewGroup mContents;
     private TextView mLabelView;
     private ImageView mClearAllButton;
+    @StringRes @Nullable private Integer mLabelTextId;
+    @Nullable private View.OnClickListener mLabelClickListener = null;
     @Nullable private View.OnClickListener mOnClearClickListener = null;
 
     public SectionHeaderView(Context context, AttributeSet attrs) {
@@ -48,18 +48,24 @@
 
     @Override
     protected void onFinishInflate() {
-        mContents = Objects.requireNonNull(findViewById(R.id.content));
+        mContents = requireViewById(R.id.content);
         bindContents();
         super.onFinishInflate();
         setVisible(true /* nowVisible */, false /* animate */);
     }
 
     private void bindContents() {
-        mLabelView = Objects.requireNonNull(findViewById(R.id.header_label));
-        mClearAllButton = Objects.requireNonNull(findViewById(R.id.btn_clear_all));
+        mLabelView = requireViewById(R.id.header_label);
+        mClearAllButton = requireViewById(R.id.btn_clear_all);
         if (mOnClearClickListener != null) {
             mClearAllButton.setOnClickListener(mOnClearClickListener);
         }
+        if (mLabelClickListener != null) {
+            mLabelView.setOnClickListener(mLabelClickListener);
+        }
+        if (mLabelTextId != null) {
+            mLabelView.setText(mLabelTextId);
+        }
     }
 
     @Override
@@ -72,21 +78,6 @@
         return null;
     }
 
-    /**
-     * Destroys and reinflates the visible contents of the section header. For use on configuration
-     * changes or any other time that layout values might need to be re-evaluated.
-     *
-     * Does not reinflate the base content view itself ({@link #findContentView()} or any of the
-     * decorator views, such as the background view or shadow view.
-     */
-    void reinflateContents() {
-        mContents.removeAllViews();
-        LayoutInflater.from(getContext()).inflate(
-                R.layout.status_bar_notification_section_header_contents,
-                mContents);
-        bindContents();
-    }
-
     @Override
     public boolean isTransparent() {
         return true;
@@ -105,6 +96,7 @@
      * Fired whenever the user clicks on the body of the header (e.g. no sub-buttons or anything).
      */
     void setOnHeaderClickListener(View.OnClickListener listener) {
+        mLabelClickListener = listener;
         mLabelView.setOnClickListener(listener);
     }
 
@@ -129,6 +121,7 @@
     }
 
     void setHeaderText(@StringRes int resId) {
+        mLabelTextId = resId;
         mLabelView.setText(resId);
     }
 }