This broke a bunch of people due to some style name mismatches.
am: 0d4d806
* commit '0d4d806606fa8210ad09430fab3a230a1c4e3681':
This broke a bunch of people due to some style name mismatches.
diff --git a/res/drawable/chip_autocomplete_divider_background.xml b/res/drawable/chip_autocomplete_divider_background.xml
deleted file mode 100644
index c013b57..0000000
--- a/res/drawable/chip_autocomplete_divider_background.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<shape xmlns:android="http://schemas.android.com/apk/res/android">
- <gradient
- android:angle="90"
- android:startColor="@android:color/transparent"
- android:endColor="@color/autocomplete_bottom_shadow_start" />
-</shape>
\ No newline at end of file
diff --git a/res/layout/chips_autocomplete_permission_dropdown_item.xml b/res/layout/chips_autocomplete_permission_dropdown_item.xml
deleted file mode 100644
index 6f5b54e..0000000
--- a/res/layout/chips_autocomplete_permission_dropdown_item.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2014 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.
--->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?android:attr/selectableItemBackground"
- android:orientation="vertical">
-
- <View
- android:id="@+id/chip_autocomplete_top_divider"
- style="@style/ChipAutocompleteDividerStyle.Top" />
-
- <LinearLayout
- android:id="@+id/chip_permission_wrapper"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- style="@style/ChipAutocompleteWrapperStyle">
-
- <TextView style="@style/ChipPermissionStyle" />
-
- <ImageView style="@style/ChipPermissionDismissIconStyle"/>
-
- </LinearLayout>
-
- <View
- android:id="@+id/chip_autocomplete_bottom_divider"
- style="@style/ChipAutocompleteDividerStyle.Bottom.PermissionItem" />
-
-</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/chips_autocomplete_recipient_dropdown_item.xml b/res/layout/chips_autocomplete_recipient_dropdown_item.xml
index f6d8d6f..ac30f77 100644
--- a/res/layout/chips_autocomplete_recipient_dropdown_item.xml
+++ b/res/layout/chips_autocomplete_recipient_dropdown_item.xml
@@ -43,6 +43,18 @@
</LinearLayout>
+ <LinearLayout
+ android:id="@+id/chip_permission_wrapper"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/ChipAutocompleteWrapperStyle">
+
+ <TextView style="@style/ChipPermissionStyle" />
+
+ <ImageView style="@style/ChipPermissionDismissIconStyle"/>
+
+ </LinearLayout>
+
<View
android:id="@+id/chip_autocomplete_bottom_divider"
style="@style/ChipAutocompleteDividerStyle" />
diff --git a/res/values-v17/styles.xml b/res/values-v17/styles.xml
index 360ed94..81dbbbf 100644
--- a/res/values-v17/styles.xml
+++ b/res/values-v17/styles.xml
@@ -28,12 +28,6 @@
<item name="android:layout_marginStart">@dimen/chip_wrapper_start_padding</item>
</style>
- <style name="ChipAutocompleteDividerStyle.Bottom.PermissionItem">
- <item name="android:background">@drawable/chip_autocomplete_divider_background</item>
- <item name="android:layout_height">3dp</item>
- <item name="android:layout_marginStart">0dp</item>
- </style>
-
<style name="ChipStartIconStyle" parent="@style/ChipIconBaseStyle">
<item name="android:layout_marginEnd">@dimen/chip_icon_margin_end</item>
</style>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 1f32b60..79bf4f8 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -21,7 +21,6 @@
<color name="chips_dropdown_background_pressed">#ededed</color>
<color name="autocomplete_divider_color">#cccccc</color>
- <color name="autocomplete_bottom_shadow_start">#40000000</color>
<color name="chip_background">#f6f6f6</color>
<color name="chip_background_invalid">#db4437</color>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 169d8ec..e60fb79 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -44,12 +44,6 @@
<item name="android:layout_marginLeft">@dimen/chip_wrapper_start_padding</item>
</style>
- <style name="ChipAutocompleteDividerStyle.Bottom.PermissionItem">
- <item name="android:background">@drawable/chip_autocomplete_divider_background</item>
- <item name="android:layout_height">3dp</item>
- <item name="android:layout_marginLeft">0dp</item>
- </style>
-
<style name="ChipTextViewLayoutStyle">
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">wrap_content</item>
diff --git a/src/com/android/ex/chips/DropdownChipLayouter.java b/src/com/android/ex/chips/DropdownChipLayouter.java
index adad800..251e255 100644
--- a/src/com/android/ex/chips/DropdownChipLayouter.java
+++ b/src/com/android/ex/chips/DropdownChipLayouter.java
@@ -115,7 +115,7 @@
* default state can map to a drawable of your choice (or null for no drawable).
*/
public View bindView(View convertView, ViewGroup parent, RecipientEntry entry, int position,
- AdapterType adapterType, String constraint, StateListDrawable deleteDrawable) {
+ AdapterType type, String constraint, StateListDrawable deleteDrawable) {
// Default to show all the information
CharSequence[] styledResults =
getStyledResults(constraint, entry.getDisplayName(), entry.getDestination());
@@ -124,14 +124,12 @@
boolean showImage = true;
CharSequence destinationType = getDestinationType(entry);
- final int entryType = entry.getEntryType();
- final View itemView =
- reuseOrInflateView(convertView, parent, adapterType, entryType);
+ final View itemView = reuseOrInflateView(convertView, parent, type);
final ViewHolder viewHolder = new ViewHolder(itemView);
// Hide some information depending on the adapter type.
- switch (adapterType) {
+ switch (type) {
case BASE_RECIPIENT:
if (TextUtils.isEmpty(displayName) || TextUtils.equals(displayName, destination)) {
displayName = destination;
@@ -155,8 +153,7 @@
(MarginLayoutParams) viewHolder.topDivider.getLayoutParams(),
mAutocompleteDividerMarginStart);
}
- if ((viewHolder.bottomDivider != null)
- && (entryType == RecipientEntry.ENTRY_TYPE_PERSON)) {
+ if (viewHolder.bottomDivider != null) {
MarginLayoutParamsCompat.setMarginStart(
(MarginLayoutParams) viewHolder.bottomDivider.getLayoutParams(),
mAutocompleteDividerMarginStart);
@@ -177,12 +174,22 @@
bindTextToView(displayName, viewHolder.displayNameView);
bindTextToView(destination, viewHolder.destinationView);
bindTextToView(destinationType, viewHolder.destinationTypeView);
- bindIconToView(showImage, entry, viewHolder.imageView, adapterType);
+ bindIconToView(showImage, entry, viewHolder.imageView, type);
bindDrawableToDeleteView(deleteDrawable, entry.getDisplayName(), viewHolder.deleteView);
bindIndicatorToView(
entry.getIndicatorIconId(), entry.getIndicatorText(), viewHolder.indicatorView);
bindPermissionRequestDismissView(viewHolder.permissionRequestDismissView);
+ // Hide some view groups depending on the entry type
+ final int entryType = entry.getEntryType();
+ if (entryType == RecipientEntry.ENTRY_TYPE_PERSON) {
+ setViewVisibility(viewHolder.personViewGroup, View.VISIBLE);
+ setViewVisibility(viewHolder.permissionViewGroup, View.GONE);
+ } else if (entryType == RecipientEntry.ENTRY_TYPE_PERMISSION_REQUEST) {
+ setViewVisibility(viewHolder.personViewGroup, View.GONE);
+ setViewVisibility(viewHolder.permissionViewGroup, View.VISIBLE);
+ }
+
return itemView;
}
@@ -196,15 +203,14 @@
/**
* Returns the same view, or inflates a new one if the given view was null.
*/
- protected View reuseOrInflateView(
- View convertView, ViewGroup parent, AdapterType adapterType, int entryType) {
- @LayoutRes int itemLayout = getItemLayoutResId(adapterType, entryType);
- switch (adapterType) {
+ protected View reuseOrInflateView(View convertView, ViewGroup parent, AdapterType type) {
+ int itemLayout = getItemLayoutResId(type);
+ switch (type) {
case BASE_RECIPIENT:
case RECIPIENT_ALTERNATES:
break;
case SINGLE_RECIPIENT:
- itemLayout = getAlternateItemLayoutResId(adapterType);
+ itemLayout = getAlternateItemLayoutResId(type);
break;
}
return convertView != null ? convertView : mInflater.inflate(itemLayout, parent, false);
@@ -346,12 +352,8 @@
* (for photo). Ids for those should be available via {@link #getDisplayNameResId()},
* {@link #getDestinationResId()}, and {@link #getPhotoResId()}.
*/
- protected @LayoutRes int getItemLayoutResId(
- AdapterType adapterType, @Nullable Integer entryType) {
- if (entryType == RecipientEntry.ENTRY_TYPE_PERMISSION_REQUEST) {
- return R.layout.chips_autocomplete_permission_dropdown_item;
- }
- switch (adapterType) {
+ protected @LayoutRes int getItemLayoutResId(AdapterType type) {
+ switch (type) {
case BASE_RECIPIENT:
return R.layout.chips_autocomplete_recipient_dropdown_item;
case RECIPIENT_ALTERNATES:
@@ -361,10 +363,6 @@
}
}
- protected @LayoutRes int getItemLayoutResId(AdapterType adapterType) {
- return getItemLayoutResId(adapterType, null);
- }
-
/**
* Returns a layout id for each item inside alternate auto-complete list.
*
@@ -516,6 +514,7 @@
* corresponding views.
*/
protected class ViewHolder {
+ public final ViewGroup personViewGroup;
public final TextView displayNameView;
public final TextView destinationView;
public final TextView destinationTypeView;
@@ -525,9 +524,11 @@
public final View topDivider;
public final View bottomDivider;
+ public final ViewGroup permissionViewGroup;
public final ImageView permissionRequestDismissView;
public ViewHolder(View view) {
+ personViewGroup = (ViewGroup) view.findViewById(getPersonGroupResId());
displayNameView = (TextView) view.findViewById(getDisplayNameResId());
destinationView = (TextView) view.findViewById(getDestinationResId());
destinationTypeView = (TextView) view.findViewById(getDestinationTypeResId());
@@ -537,6 +538,7 @@
bottomDivider = view.findViewById(R.id.chip_autocomplete_bottom_divider);
indicatorView = (TextView) view.findViewById(R.id.chip_indicator_text);
+ permissionViewGroup = (ViewGroup) view.findViewById(getPermissionGroupResId());
permissionRequestDismissView =
(ImageView) view.findViewById(getPermissionRequestDismissResId());
}