Merge "Reinflate all headers when locale changes" into rvc-dev am: 7a38263f94
Change-Id: I511b53764414615c07a1f4b5b52724621411de92
This commit is contained in:
@@ -35,7 +35,34 @@
|
|||||||
android:forceHasOverlappingRendering="false"
|
android:forceHasOverlappingRendering="false"
|
||||||
android:clipChildren="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>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.android.systemui.statusbar.notification.stack.SectionHeaderView>
|
</com.android.systemui.statusbar.notification.stack.SectionHeaderView>
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -447,7 +447,6 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
ExpandableView getGentleHeaderView() {
|
ExpandableView getGentleHeaderView() {
|
||||||
return mGentleHeader;
|
return mGentleHeader;
|
||||||
@@ -471,7 +470,7 @@ public class NotificationSectionsManager implements StackScrollAlgorithm.Section
|
|||||||
private final ConfigurationListener mConfigurationListener = new ConfigurationListener() {
|
private final ConfigurationListener mConfigurationListener = new ConfigurationListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onLocaleListChanged() {
|
public void onLocaleListChanged() {
|
||||||
mGentleHeader.reinflateContents();
|
reinflateViews(LayoutInflater.from(mParent.getContext()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -76,9 +76,7 @@ class PeopleHubView(context: Context, attrs: AttributeSet) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun needsClippingToShelf(): Boolean {
|
override fun needsClippingToShelf(): Boolean = true
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun applyContentTransformation(contentAlpha: Float, translationY: Float) {
|
override fun applyContentTransformation(contentAlpha: Float, translationY: Float) {
|
||||||
super.applyContentTransformation(contentAlpha, translationY)
|
super.applyContentTransformation(contentAlpha, translationY)
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import android.annotation.Nullable;
|
|||||||
import android.annotation.StringRes;
|
import android.annotation.StringRes;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -30,16 +29,17 @@ import android.widget.TextView;
|
|||||||
import com.android.systemui.R;
|
import com.android.systemui.R;
|
||||||
import com.android.systemui.statusbar.notification.row.StackScrollerDecorView;
|
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
|
* Header displayed above a notification section in the shade. Currently used for Alerting and
|
||||||
* notification sections. Currently only used for gentle notifications.
|
* Silent sections.
|
||||||
*/
|
*/
|
||||||
public class SectionHeaderView extends StackScrollerDecorView {
|
public class SectionHeaderView extends StackScrollerDecorView {
|
||||||
|
|
||||||
private ViewGroup mContents;
|
private ViewGroup mContents;
|
||||||
private TextView mLabelView;
|
private TextView mLabelView;
|
||||||
private ImageView mClearAllButton;
|
private ImageView mClearAllButton;
|
||||||
|
@StringRes @Nullable private Integer mLabelTextId;
|
||||||
|
@Nullable private View.OnClickListener mLabelClickListener = null;
|
||||||
@Nullable private View.OnClickListener mOnClearClickListener = null;
|
@Nullable private View.OnClickListener mOnClearClickListener = null;
|
||||||
|
|
||||||
public SectionHeaderView(Context context, AttributeSet attrs) {
|
public SectionHeaderView(Context context, AttributeSet attrs) {
|
||||||
@@ -48,18 +48,24 @@ public class SectionHeaderView extends StackScrollerDecorView {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
mContents = Objects.requireNonNull(findViewById(R.id.content));
|
mContents = requireViewById(R.id.content);
|
||||||
bindContents();
|
bindContents();
|
||||||
super.onFinishInflate();
|
super.onFinishInflate();
|
||||||
setVisible(true /* nowVisible */, false /* animate */);
|
setVisible(true /* nowVisible */, false /* animate */);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void bindContents() {
|
private void bindContents() {
|
||||||
mLabelView = Objects.requireNonNull(findViewById(R.id.header_label));
|
mLabelView = requireViewById(R.id.header_label);
|
||||||
mClearAllButton = Objects.requireNonNull(findViewById(R.id.btn_clear_all));
|
mClearAllButton = requireViewById(R.id.btn_clear_all);
|
||||||
if (mOnClearClickListener != null) {
|
if (mOnClearClickListener != null) {
|
||||||
mClearAllButton.setOnClickListener(mOnClearClickListener);
|
mClearAllButton.setOnClickListener(mOnClearClickListener);
|
||||||
}
|
}
|
||||||
|
if (mLabelClickListener != null) {
|
||||||
|
mLabelView.setOnClickListener(mLabelClickListener);
|
||||||
|
}
|
||||||
|
if (mLabelTextId != null) {
|
||||||
|
mLabelView.setText(mLabelTextId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,21 +78,6 @@ public class SectionHeaderView extends StackScrollerDecorView {
|
|||||||
return null;
|
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
|
@Override
|
||||||
public boolean isTransparent() {
|
public boolean isTransparent() {
|
||||||
return true;
|
return true;
|
||||||
@@ -105,6 +96,7 @@ public class SectionHeaderView extends StackScrollerDecorView {
|
|||||||
* Fired whenever the user clicks on the body of the header (e.g. no sub-buttons or anything).
|
* Fired whenever the user clicks on the body of the header (e.g. no sub-buttons or anything).
|
||||||
*/
|
*/
|
||||||
void setOnHeaderClickListener(View.OnClickListener listener) {
|
void setOnHeaderClickListener(View.OnClickListener listener) {
|
||||||
|
mLabelClickListener = listener;
|
||||||
mLabelView.setOnClickListener(listener);
|
mLabelView.setOnClickListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +121,7 @@ public class SectionHeaderView extends StackScrollerDecorView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setHeaderText(@StringRes int resId) {
|
void setHeaderText(@StringRes int resId) {
|
||||||
|
mLabelTextId = resId;
|
||||||
mLabelView.setText(resId);
|
mLabelView.setText(resId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user