summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Chen <ajchen@google.com>2017-07-10 14:10:15 -0700
committerAnthony Chen <ajchen@google.com>2017-07-10 14:10:15 -0700
commit97b319e44253a215dab1e6d626fcdc5f56d3867c (patch)
tree9a6906c1342f596671c312455777207d101e45ea
parentf7ed46be024b7cfb448f93d71f235b30f72aa1ee (diff)
downloadDialer-97b319e44253a215dab1e6d626fcdc5f56d3867c.tar.gz
Update Dialer with changes to PagedListView's divider.
Remove custom divider logic where possible and utilize the PagedListView's default divider. Test: booted up Dialer and verified UI looks the same. Bug: 63524971 Change-Id: Ia1192af937bb268134491d89171027d1d5edbe8c
-rw-r--r--res/layout/contact_result_fragment.xml8
-rw-r--r--res/layout/strequents_fragment.xml4
-rw-r--r--src/com/android/car/dialer/ContactResultsFragment.java42
-rw-r--r--src/com/android/car/dialer/StrequentsFragment.java23
4 files changed, 24 insertions, 53 deletions
diff --git a/res/layout/contact_result_fragment.xml b/res/layout/contact_result_fragment.xml
index 6c66d9ed..8b537dd2 100644
--- a/res/layout/contact_result_fragment.xml
+++ b/res/layout/contact_result_fragment.xml
@@ -15,11 +15,17 @@
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.android.car.view.PagedListView
android:id="@+id/contact_result_list"
android:layout_width="match_parent"
- android:layout_height="match_parent" />
+ android:layout_height="match_parent"
+ app:offsetRows="true"
+ app:showDivider="true"
+ app:dividerStartMargin="@dimen/stream_card_keyline_2"
+ app:alignDividerEndTo="@id/contact_result_card"
+ app:alignDividerStartTo="@id/contact_result_card" />
</FrameLayout>
diff --git a/res/layout/strequents_fragment.xml b/res/layout/strequents_fragment.xml
index 3966ffe5..d56fe71f 100644
--- a/res/layout/strequents_fragment.xml
+++ b/res/layout/strequents_fragment.xml
@@ -15,6 +15,7 @@
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/telecom_display_scrim"
@@ -25,5 +26,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/lens_header_height"
- android:clipChildren="false"/>
+ android:clipChildren="false"
+ app:showDivider="false" />
</FrameLayout>
diff --git a/src/com/android/car/dialer/ContactResultsFragment.java b/src/com/android/car/dialer/ContactResultsFragment.java
index 617ae8e0..9fefdfb0 100644
--- a/src/com/android/car/dialer/ContactResultsFragment.java
+++ b/src/com/android/car/dialer/ContactResultsFragment.java
@@ -18,11 +18,9 @@ package com.android.car.dialer;
import android.app.Fragment;
import android.app.LoaderManager;
-import android.content.Context;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
-import android.graphics.Canvas;
import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.annotation.Nullable;
@@ -89,7 +87,6 @@ public class ContactResultsFragment extends Fragment implements
mContactResultList = view.findViewById(R.id.contact_result_list);
mContactResultList.setLightMode();
mContactResultList.setAdapter(mAdapter);
- mContactResultList.setDefaultItemDecoration(new ItemSpacingDecoration(getContext()));
mContactResultList.getLayoutManager().setOffsetRows(false);
RecyclerView recyclerView = mContactResultList.getRecyclerView();
@@ -189,43 +186,4 @@ public class ContactResultsFragment extends Fragment implements
return fragment;
}
-
- /**
- * A {@link com.android.car.view.PagedListView.Decoration} that draws a line between
- * the items.
- */
- public static class ItemSpacingDecoration extends PagedListView.DividerDecoration {
- private final int mLineStart;
-
- public ItemSpacingDecoration(Context context) {
- super(context);
- mLineStart = context.getResources()
- .getDimensionPixelSize(R.dimen.stream_card_keyline_2);
- }
-
- @Override
- public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
- View contactCard = parent.findViewById(R.id.contact_result_card);
-
- if (contactCard == null) {
- return;
- }
-
- int left = mLineStart + contactCard.getLeft();
- int right = contactCard.getRight();
- int childCount = parent.getChildCount();
-
- for (int i = 0; i < childCount; i++) {
- View child = parent.getChildAt(i);
- int bottom = child.getBottom();
- int top = bottom - mDividerHeight;
-
- // Draw a divider line between each item. No need to draw the line for the last
- // item.
- if (i != childCount - 1) {
- c.drawRect(left, top, right, bottom, mPaint);
- }
- }
- }
- }
}
diff --git a/src/com/android/car/dialer/StrequentsFragment.java b/src/com/android/car/dialer/StrequentsFragment.java
index d0918336..f6f94ee1 100644
--- a/src/com/android/car/dialer/StrequentsFragment.java
+++ b/src/com/android/car/dialer/StrequentsFragment.java
@@ -18,9 +18,11 @@ package com.android.car.dialer;
import android.content.ContentResolver;
import android.content.Context;
import android.content.CursorLoader;
+import android.content.res.Resources;
import android.database.ContentObserver;
import android.database.Cursor;
import android.graphics.Canvas;
+import android.graphics.Paint;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -93,7 +95,7 @@ public class StrequentsFragment extends Fragment {
onLoadStrequentCursor(cursor);
if (mContext != null) {
- mListView.setDefaultItemDecoration(new Decoration(mContext));
+ mListView.addItemDecoration(new Decoration(mContext));
}
});
@@ -124,7 +126,6 @@ public class StrequentsFragment extends Fragment {
Log.v(TAG, "Max clicks: " + maxClicks + ", Max pages: " + maxPages);
}
- mListView.removeDefaultItemDecoration();
mListView.setLightMode();
mAdapter = new StrequentsAdapter(mContext, mUiCallManager);
mAdapter.setStrequentsListener(viewHolder -> {
@@ -255,16 +256,20 @@ public class StrequentsFragment extends Fragment {
}
/**
- * Decoration for the speed dial cards. This is basically copied from the one in
- * {@link PagedListView} except it won't show a divider between the dialpad item and the first
- * speed dial item and the divider is offset but a couple of pixels to offset the fact that
- * the cards overlap.
+ * Decoration for the speed dial cards. This ItemDecoration will not show a divider between
+ * the dialpad item and the first speed dial item and the divider is offset but a couple of
+ * pixels to offset the fact that the cards overlap.
*/
- private static class Decoration extends PagedListView.DividerDecoration {
+ private static class Decoration extends RecyclerView.ItemDecoration {
+ private final Paint mPaint;
private final int mPaintAlpha;
+ private final int mDividerHeight;
public Decoration(Context context) {
- super(context);
+ Resources res = context.getResources();
+ mPaint = new Paint();
+ mPaint.setColor(res.getColor(R.color.car_list_divider));
+ mDividerHeight = res.getDimensionPixelSize(R.dimen.car_divider_height);
mPaintAlpha = mPaint.getAlpha();
}
@@ -289,7 +294,7 @@ public class StrequentsFragment extends Fragment {
}
// The left edge of the divider should align with the left edge of text_container.
- final LinearLayout container = (LinearLayout) child.findViewById(R.id.container);
+ LinearLayout container = child.findViewById(R.id.container);
View textContainer = child.findViewById(R.id.text_container);
View card = child.findViewById(R.id.call_log_card);