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

Commit 3607687e authored by Josh Gargus's avatar Josh Gargus Committed by Android (Google) Code Review
Browse files

Merge "Improve progress feedback for long-running directory searches." into jb-dev

parents 311882ab f4aaa475
Loading
Loading
Loading
Loading
+7 −25
Original line number Diff line number Diff line
@@ -14,29 +14,11 @@
     limitations under the License.
-->

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    style="DirectoryHeader"
    android:layout_width="match_parent"
    android:layout_height="56dip">
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/totalContactsText"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="8dip"
    android:minHeight="@dimen/contact_filter_header_min_height"
    android:paddingTop="10dip"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="?android:attr/textColorTertiary"
    android:textStyle="bold" />

    <ProgressBar
        android:id="@+id/progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="?android:attr/progressBarStyleSmall"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="10dip" />

</RelativeLayout>
+25 −14
Original line number Diff line number Diff line
@@ -33,16 +33,27 @@
        android:id="@+id/account_filter_header_container"
        layout="@layout/account_filter_header" />

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="0dip"
        android:layout_weight="1" >
        <view
            class="com.android.contacts.widget.PinnedHeaderListView"
            android:id="@android:id/list"
            android:layout_width="match_parent"
        android:layout_height="0dip"
            android:layout_height="match_parent"
            android:layout_marginLeft="?attr/contact_browser_list_padding_left"
            android:layout_marginRight="?attr/contact_browser_list_padding_right"
            android:fastScrollEnabled="true"
        android:fadingEdge="none"
        android:layout_weight="1" />
            android:fadingEdge="none" />
        <ProgressBar
            android:id="@+id/search_progress"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:visibility="gone" />
    </FrameLayout>

    <ViewStub
        android:id="@+id/footer_stub"
+5 −23
Original line number Diff line number Diff line
@@ -14,28 +14,10 @@
     limitations under the License.
-->

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="@dimen/contact_filter_header_min_height"
    android:background="@android:color/transparent">
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/totalContactsText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_alignParentLeft="true"
    android:minHeight="@dimen/contact_filter_header_min_height"
    android:paddingTop="10dip"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="?android:attr/textColorSecondary" />
 No newline at end of file

    <ProgressBar
        android:id="@+id/progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@id/totalContactsText"
        style="?android:attr/progressBarStyleSmall"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true" />

</RelativeLayout>
+18 −10
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ import android.view.accessibility.AccessibilityEvent;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;

/**
@@ -54,6 +53,8 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment
    private Button mProfileMessage;
    private FrameLayout mMessageContainer;
    private TextView mProfileTitle;
    private View mSearchProgress;
    private TextView mSearchProgressText;

    private View mPaddingView;

@@ -117,12 +118,21 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment
        headerContainer.addView(mSearchHeaderView);
        getListView().addHeaderView(headerContainer, null, false);
        checkHeaderViewVisibility();

        mSearchProgress = getView().findViewById(R.id.search_progress);
        mSearchProgressText = (TextView) mSearchHeaderView.findViewById(R.id.totalContactsText);
    }

    @Override
    protected void setSearchMode(boolean flag) {
        super.setSearchMode(flag);
        checkHeaderViewVisibility();
        if (!flag) showSearchProgress(false);
    }

    /** Show or hide the directory-search progress spinner. */
    private void showSearchProgress(boolean show) {
        mSearchProgress.setVisibility(show ? View.VISIBLE : View.GONE);
    }

    private void checkHeaderViewVisibility() {
@@ -203,19 +213,17 @@ public class DefaultContactBrowseListFragment extends ContactBrowseListFragment
            // In search mode we only display the header if there is nothing found
            if (TextUtils.isEmpty(getQueryString()) || !adapter.areAllPartitionsEmpty()) {
                mSearchHeaderView.setVisibility(View.GONE);
                showSearchProgress(false);
            } else {
                TextView textView = (TextView) mSearchHeaderView.findViewById(
                        R.id.totalContactsText);
                ProgressBar progress = (ProgressBar) mSearchHeaderView.findViewById(
                        R.id.progress);
                mSearchHeaderView.setVisibility(View.VISIBLE);
                if (adapter.isLoading()) {
                    textView.setText(R.string.search_results_searching);
                    progress.setVisibility(View.VISIBLE);
                    mSearchProgressText.setText(R.string.search_results_searching);
                    showSearchProgress(true);
                } else {
                    textView.setText(R.string.listFoundAllContactsZero);
                    textView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED);
                    progress.setVisibility(View.GONE);
                    mSearchProgressText.setText(R.string.listFoundAllContactsZero);
                    mSearchProgressText.sendAccessibilityEvent(
                            AccessibilityEvent.TYPE_VIEW_SELECTED);
                    showSearchProgress(false);
                }
            }
            showEmptyUserProfile(false);