Stop using framework internal layout for timezone header.

The framework version header has deviated from supportlib version long
ago, and we shouldn't hack our theme to make this layout work. Instead
we now have a custom layout compatible to settings theme.

Fixes: 128833223
Test: visual
Change-Id: I83087352240de183b0639daf844bd7f90e02056a
This commit is contained in:
Fan Zhang
2019-03-18 16:37:28 -07:00
parent 9f5e7b77ff
commit 5d2e0fc10f
2 changed files with 37 additions and 3 deletions

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<!-- similar to preference_material.xml but textview for emoji country flag
instead of an ImageView -->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:textAppearance="@style/TextAppearance.CategoryTitle"
android:textColor="?android:attr/colorAccent"
android:paddingStart="@dimen/preference_no_icon_padding_start"/>

View File

@@ -77,9 +77,10 @@ public class BaseTimeZoneAdapter<T extends BaseTimeZoneAdapter.AdapterItem>
@Override @Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext()); LayoutInflater inflater = LayoutInflater.from(parent.getContext());
switch(viewType) { switch (viewType) {
case TYPE_HEADER: { case TYPE_HEADER: {
final View view = inflater.inflate(R.layout.preference_category_material, final View view = inflater.inflate(
R.layout.time_zone_search_header,
parent, false); parent, false);
return new HeaderViewHolder(view); return new HeaderViewHolder(view);
} }
@@ -136,7 +137,8 @@ public class BaseTimeZoneAdapter<T extends BaseTimeZoneAdapter.AdapterItem>
return mShowHeader && position == 0; return mShowHeader && position == 0;
} }
public @NonNull ArrayFilter getFilter() { @NonNull
public ArrayFilter getFilter() {
if (mFilter == null) { if (mFilter == null) {
mFilter = new ArrayFilter(); mFilter = new ArrayFilter();
} }
@@ -153,14 +155,18 @@ public class BaseTimeZoneAdapter<T extends BaseTimeZoneAdapter.AdapterItem>
public interface AdapterItem { public interface AdapterItem {
CharSequence getTitle(); CharSequence getTitle();
CharSequence getSummary(); CharSequence getSummary();
String getIconText(); String getIconText();
String getCurrentTime(); String getCurrentTime();
/** /**
* @return unique non-negative number * @return unique non-negative number
*/ */
long getItemId(); long getItemId();
String[] getSearchKeys(); String[] getSearchKeys();
} }