Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7689c37 authored by Katherine Kuan's avatar Katherine Kuan
Browse files

Show "no contacts" in frequent list on tablet

- This was already merged in master
https://android-git.corp.google.com/g/#/c/144789/
but needs to be cherry-picked to ics-mr1.
We can't mark it as "do not merge" because
it still needs to be merged to ics-mr1-plus-asop.
When submitting, I'll stand by to manually
say skip if the automerger detects a conflict
when merging to master.

- We need to show "no contacts" under the
"frequently contacted" header in the frequent
fragment in the People app on the tablet.

Since that header was originally the 0th item
in the ListView, to show an empty view we would
either have to:

1) Add a second fake item in the ListView that shows
"No contacts". This requires either returning
view type "empty view" or view type "frequent"
for position = 1 based on the cursor count.
Checking the cursor in getItemViewType()
would make this more than a UI change.

2) Move the "Frequently contacted" header
outside the ListView and make the ContactTileAdapter
show the empty view state when there are 0
frequently contacted people (instead of the
existing implementation which fakes it by returning
1 when the cursor count is 0).

- This CL uses the second option so that we don't
need to add a cursor dependency in getItemViewType()
of ContactTileAdapter.

- Added a TODO because UI changes like this highlight
the fact that we should do some refactoring to
ContactTileAdapter and ContactTileListFragment
so that it's easier to add specific functionality to
the favorites, frequent, or group list.

Bug: 5485640
Change-Id: Ib365543892f452cc9c87406ed2d04c1b5aad4b2c
parent 3e3e5051
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@
                <!-- Most Frequent -->
                <fragment
                    android:id="@+id/frequent_fragment"
                    class="com.android.contacts.list.ContactTileListFragment"
                    class="com.android.contacts.list.ContactTileFrequentFragment"
                    android:layout_width="0dip"
                    android:layout_height="match_parent"
                    android:layout_weight="3"
+1 −1
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@
                <!-- Most Frequent -->
                <fragment
                    android:id="@+id/frequent_fragment"
                    class="com.android.contacts.list.ContactTileListFragment"
                    class="com.android.contacts.list.ContactTileFrequentFragment"
                    android:layout_width="0dip"
                    android:layout_height="match_parent"
                    android:layout_weight="1"
+51 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2011 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.
-->

<!--
  This is very similar to contact_tile_list.xml (there needs to be a ListView called
  contact_tile_list and an empty view called contact_tile_list_empty). However, this layout also
  contains a container view for the title of the frequently contacted list.
-->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="?attr/favorites_padding_bottom"
    android:orientation="vertical">

    <FrameLayout
        android:id="@+id/header_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <ListView
        android:id="@+id/contact_tile_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fadingEdge="none"
        android:divider="@null" />

    <TextView
        android:id="@+id/contact_tile_list_empty"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center_horizontal"
        android:layout_marginTop="@dimen/empty_message_top_margin"
        android:textColor="?android:attr/textColorSecondary"
        android:textAppearance="?android:attr/textAppearanceLarge"/>

</LinearLayout>
+13 −0
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import android.provider.ContactsContract.CommonDataKinds.Im;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import java.util.List;

@@ -208,4 +210,15 @@ public class ContactsUtils {
        intent.setData(lookupUri);
        return intent;
    }

    /**
     * Returns a header view based on the R.layout.list_separator, where the
     * containing {@link TextView} is set using the given textResourceId.
     */
    public static View createHeaderView(Context context, int textResourceId) {
        View view = View.inflate(context, R.layout.list_separator, null);
        TextView textView = (TextView) view.findViewById(R.id.title);
        textView.setText(context.getString(textResourceId));
        return view;
    }
}
+2 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.contacts.list.ContactEntryListFragment;
import com.android.contacts.list.ContactListFilter;
import com.android.contacts.list.ContactListFilterController;
import com.android.contacts.list.ContactTileAdapter.DisplayType;
import com.android.contacts.list.ContactTileFrequentFragment;
import com.android.contacts.list.ContactTileListFragment;
import com.android.contacts.list.ContactsIntentResolver;
import com.android.contacts.list.ContactsRequest;
@@ -145,7 +146,7 @@ public class PeopleActivity extends ContactsActivity
     */
    private DefaultContactBrowseListFragment mAllFragment;
    private ContactTileListFragment mFavoritesFragment;
    private ContactTileListFragment mFrequentFragment;
    private ContactTileFrequentFragment mFrequentFragment;
    private GroupBrowseListFragment mGroupsFragment;

    private View mFavoritesView;
Loading