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

Commit 18e7fdd5 authored by Yorke Lee's avatar Yorke Lee
Browse files

Add no contacts view to Dialer

Bug: 10330508
Change-Id: I5f73a63118558e734cd36e681c59f4b82050a49c
parent e44b3c6a
Loading
Loading
Loading
Loading
+11 −17
Original line number Diff line number Diff line
@@ -14,27 +14,21 @@
     limitations under the License.
-->

<!-- "Loading" text with a spinner, which is used in PhoneFavorite screen -->
<LinearLayout
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:orientation="horizontal"
    android:gravity="start|center_vertical">

    <ProgressBar
        android:indeterminate="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/progress_spinner"/>
    android:minHeight="?android:attr/listPreferredItemHeight">

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/contact_list_loading"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:layout_marginStart="4dip" />
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:text="@string/listTotalAllContactsZeroStarred"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="?android:attr/textColorSecondary"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"/>

</LinearLayout>
</FrameLayout>
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@

    <!-- Shown only when an Account filter is set.
         - paddingTop should be here to show "shade" effect correctly. -->
    <!-- TODO {klp} Remove the filter header. -->
    <!-- TODO: Remove the filter header. -->
    <include
        android:id="@+id/account_filter_header_container"
        layout="@layout/account_filter_header" />
+7 −11
Original line number Diff line number Diff line
@@ -144,18 +144,17 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
    private CallLogAdapter mCallLogAdapter;
    private CallLogQueryHandler mCallLogQueryHandler;

    private TextView mEmptyView;
    private PhoneFavoriteListView mListView;

    private View mShowAllContactsButton;

    private final HashMap<Long, Integer> mItemIdTopMap = new HashMap<Long, Integer>();
    private final HashMap<Long, Integer> mItemIdLeftMap = new HashMap<Long, Integer>();

    /**
     * Layout used when contacts load is slower than expected and thus "loading" view should be
     * shown.
     * Layout used when there are no favorites.
     */
    private View mLoadingView;
    private View mEmptyView;

    private final ContactTileView.Listener mContactTileAdapterListener =
            new ContactTileAdapterListener();
@@ -171,7 +170,6 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
        // Construct two base adapters which will become part of PhoneFavoriteMergedAdapter.
        // We don't construct the resultant adapter at this moment since it requires LayoutInflater
        // that will be available on onCreateView().

        mContactTileAdapter = new PhoneFavoritesTileAdapter(activity, mContactTileAdapterListener,
                this,
                getResources().getInteger(R.integer.contact_tile_column_count_in_favorites_new),
@@ -214,7 +212,8 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
        mListView.setScrollBarStyle(ListView.SCROLLBARS_OUTSIDE_OVERLAY);
        mListView.setOnItemSwipeListener(mContactTileAdapter);

        mLoadingView = inflater.inflate(R.layout.phone_loading_contacts, mListView, false);
        mEmptyView = inflater.inflate(R.layout.phone_no_favorites, mListView, false);

        mShowAllContactsButton = inflater.inflate(R.layout.show_all_contact_button, mListView,
                false);
        mShowAllContactsButton.setOnClickListener(new OnClickListener() {
@@ -224,8 +223,9 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
            }
        });

        mContactTileAdapter.setEmptyView(mEmptyView);
        mAdapter = new PhoneFavoriteMergedAdapter(getActivity(), mContactTileAdapter,
                mCallLogAdapter, mLoadingView, mShowAllContactsButton);
                mCallLogAdapter, mShowAllContactsButton);

        mListView.setAdapter(mAdapter);

@@ -233,10 +233,6 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
        mListView.setFastScrollEnabled(false);
        mListView.setFastScrollAlwaysVisible(false);

        mEmptyView = (TextView) listLayout.findViewById(R.id.contact_tile_list_empty);
        mEmptyView.setText(getString(R.string.listTotalAllContactsZero));
        mListView.setEmptyView(mEmptyView);

        return listLayout;
    }

+0 −6
Original line number Diff line number Diff line
@@ -52,7 +52,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
    private static final int ALL_CONTACTS_BUTTON_ITEM_ID = -1;
    private final PhoneFavoritesTileAdapter mContactTileAdapter;
    private final CallLogAdapter mCallLogAdapter;
    private final View mLoadingView;
    private final View mShowAllContactsButton;

    private final int mCallLogPadding;
@@ -99,7 +98,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
    public PhoneFavoriteMergedAdapter(Context context,
            PhoneFavoritesTileAdapter contactTileAdapter,
            CallLogAdapter callLogAdapter,
            View loadingView,
            View showAllContactsButton) {
        final Resources resources = context.getResources();
        mContext = context;
@@ -109,7 +107,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
        mObserver = new CustomDataSetObserver();
        mCallLogAdapter.registerDataSetObserver(mObserver);
        mContactTileAdapter.registerDataSetObserver(mObserver);
        mLoadingView = loadingView;
        mShowAllContactsButton = showAllContactsButton;
        mCallLogQueryHandler = new CallLogQueryHandler(mContext.getContentResolver(),
                mCallLogQueryHandlerListener);
@@ -242,9 +239,6 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {

    @Override
    public boolean areAllItemsEnabled() {
        // If "all" section is being loaded we'll show mLoadingView, which is not enabled.
        // Otherwise check the all the other components in the ListView and return appropriate
        // result.
        return mCallLogAdapter.areAllItemsEnabled() && mContactTileAdapter.areAllItemsEnabled();
    }

+21 −3
Original line number Diff line number Diff line
@@ -74,6 +74,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
    private Context mContext;
    private Resources mResources;

    private View mEmptyView;

    /** Contact data stored in cache. This is used to populate the associated view. */
    protected ArrayList<ContactEntry> mContactEntries = null;
    /** Back up of the temporarily removed Contact during dragging. */
@@ -367,10 +369,15 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
        return mNumFrequents;
    }

    private boolean isEmptyView(int position) {
        return position == 0 && (mContactEntries == null || mContactEntries.isEmpty());
    }

    @Override
    public int getCount() {
        if (mContactEntries == null || mContactEntries.isEmpty()) {
            return 0;
            // empty view
            return 1;
        }

        int total = mContactEntries.size();
@@ -493,7 +500,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements

    @Override
    public boolean isEnabled(int position) {
        return true;
        return !isEmptyView(position);
    }

    @Override
@@ -509,8 +516,13 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
        if (DEBUG) {
            Log.v(TAG, "get view for " + String.valueOf(position));
        }

        int itemViewType = getItemViewType(position);

        if (itemViewType == ViewTypes.EMPTY) {
            return mEmptyView;
        }

        ContactTileRow contactTileRowView  = (ContactTileRow) convertView;

        ArrayList<ContactEntry> contactList = getItem(position);
@@ -542,6 +554,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements

    @Override
    public int getItemViewType(int position) {
        if (isEmptyView(position)) return ViewTypes.EMPTY;
        if (position < getRowCount(getMaxContactsInTiles())) {
            return ViewTypes.TOP;
        } else {
@@ -1129,9 +1142,10 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
    }

    protected static class ViewTypes {
        public static final int COUNT = 2;
        public static final int COUNT = 3;
        public static final int FREQUENT = 0;
        public static final int TOP = 1;
        public static final int EMPTY = 2;
    }

    @Override
@@ -1158,4 +1172,8 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
    public boolean isSwipeEnabled() {
        return !mAwaitingRemove;
    }

    public void setEmptyView(View emptyView) {
        mEmptyView = emptyView;
    }
}
Loading