Add an empty state for search

This commit is contained in:
Moxie Marlinspike 2017-11-13 09:31:01 -08:00
parent 9c50057909
commit 9a75f49aa1
4 changed files with 24 additions and 1 deletions

View File

@ -7,6 +7,16 @@
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView android:id="@+id/empty_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:gravity="center"
android:textSize="18sp"
android:padding="16dp"
android:visibility="invisible"
tools:text="No results found for 'foo'"/>
<FrameLayout android:id="@+id/empty_state"
android:layout_width="match_parent"
android:layout_height="match_parent"

View File

@ -1493,6 +1493,7 @@
<string name="conversation_list_fragment__give_your_inbox_something_to_write_home_about_get_started_by_messaging_a_friend">Give your inbox something to write home about. Get started by messaging a friend.</string>
<string name="conversation_list_item_inbox_zero__inbox_zeeerrro">Inbox zeeerrro</string>
<string name="conversation_list_item_inbox_zero__zip_zilch_zero_nada_nyou_re_all_caught_up">Zip. Zilch. Zero. Nada. You\'re all caught up!</string>
<string name="ConversationListFragment_no_results_found_for_s_">No results found for \'%s\'</string>
<!-- EOF -->

View File

@ -16,6 +16,7 @@
*/
package org.thoughtcrime.securesms;
import android.annotation.SuppressLint;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@ -209,6 +210,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
startActivity(new Intent(this, ImportExportActivity.class));
}
@SuppressLint("StaticFieldLeak")
private void handleMarkAllRead() {
new AsyncTask<Void, Void, Void>() {
@Override

View File

@ -48,6 +48,7 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import org.thoughtcrime.securesms.ConversationListAdapter.ItemClickListener;
import org.thoughtcrime.securesms.components.recyclerview.DeleteItemAnimator;
@ -91,6 +92,7 @@ public class ConversationListFragment extends Fragment
private RecyclerView list;
private ReminderView reminderView;
private View emptyState;
private TextView emptySearch;
private PulsingFloatingActionButton fab;
private Locale locale;
private String queryFilter = "";
@ -112,6 +114,7 @@ public class ConversationListFragment extends Fragment
list = ViewUtil.findById(view, R.id.list);
fab = ViewUtil.findById(view, R.id.fab);
emptyState = ViewUtil.findById(view, R.id.empty_state);
emptySearch = ViewUtil.findById(view, R.id.empty_search);
if (archive) fab.setVisibility(View.GONE);
else fab.setVisibility(View.VISIBLE);
@ -318,13 +321,20 @@ public class ConversationListFragment extends Fragment
@Override
public void onLoadFinished(Loader<Cursor> arg0, Cursor cursor) {
if (cursor == null || cursor.getCount() <= 0) {
if ((cursor == null || cursor.getCount() <= 0) && TextUtils.isEmpty(queryFilter) && !archive) {
list.setVisibility(View.INVISIBLE);
emptyState.setVisibility(View.VISIBLE);
emptySearch.setVisibility(View.INVISIBLE);
fab.startPulse(3 * 1000);
} else if ((cursor == null || cursor.getCount() <= 0) && !TextUtils.isEmpty(queryFilter)) {
list.setVisibility(View.INVISIBLE);
emptyState.setVisibility(View.GONE);
emptySearch.setVisibility(View.VISIBLE);
emptySearch.setText(getString(R.string.ConversationListFragment_no_results_found_for_s_, queryFilter));
} else {
list.setVisibility(View.VISIBLE);
emptyState.setVisibility(View.GONE);
emptySearch.setVisibility(View.INVISIBLE);
fab.stopPulse();
}