Improve suggestion panel

This commit is contained in:
Stypox 2020-07-05 00:39:36 +02:00
parent ccd82fb8b8
commit 20e828be51
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
2 changed files with 16 additions and 27 deletions

View File

@ -149,8 +149,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
private EditText searchEditText; private EditText searchEditText;
private View searchClear; private View searchClear;
private View correctSuggestionPanel; private TextView correctSuggestion;
private TextView correctSuggestionText;
private View suggestionsPanel; private View suggestionsPanel;
private RecyclerView suggestionsRecyclerView; private RecyclerView suggestionsRecyclerView;
@ -357,8 +356,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
searchEditText = searchToolbarContainer.findViewById(R.id.toolbar_search_edit_text); searchEditText = searchToolbarContainer.findViewById(R.id.toolbar_search_edit_text);
searchClear = searchToolbarContainer.findViewById(R.id.toolbar_search_clear); searchClear = searchToolbarContainer.findViewById(R.id.toolbar_search_clear);
correctSuggestionPanel = rootView.findViewById(R.id.correct_suggestion_panel); correctSuggestion = rootView.findViewById(R.id.correct_suggestion);
correctSuggestionText = rootView.findViewById(R.id.correct_suggestion_text);
} }
/*////////////////////////////////////////////////////////////////////////// /*//////////////////////////////////////////////////////////////////////////
@ -511,7 +509,7 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
return; return;
} }
correctSuggestionPanel.setVisibility(View.GONE); correctSuggestion.setVisibility(View.GONE);
searchEditText.setText(""); searchEditText.setText("");
suggestionListAdapter.setItems(new ArrayList<>()); suggestionListAdapter.setItems(new ArrayList<>());
@ -1007,17 +1005,17 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
? R.string.search_showing_result_for ? R.string.search_showing_result_for
: R.string.did_you_mean); : R.string.did_you_mean);
correctSuggestionText.setText(String.format(helperText, searchSuggestion)); correctSuggestion.setText(String.format(helperText, searchSuggestion));
correctSuggestionPanel.setOnClickListener(v -> { correctSuggestion.setOnClickListener(v -> {
correctSuggestionPanel.setVisibility(View.GONE); correctSuggestion.setVisibility(View.GONE);
search(searchSuggestion, contentFilter, sortFilter); search(searchSuggestion, contentFilter, sortFilter);
searchEditText.setText(searchSuggestion); searchEditText.setText(searchSuggestion);
}); });
correctSuggestionPanel.setVisibility(View.VISIBLE); correctSuggestion.setVisibility(View.VISIBLE);
} else { } else {
correctSuggestionPanel.setVisibility(View.GONE); correctSuggestion.setVisibility(View.GONE);
} }
} }

View File

@ -6,31 +6,22 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout <TextView
android:id="@+id/correct_suggestion_panel" android:id="@+id/correct_suggestion"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignTop="@id/error_panel" android:layout_alignTop="@id/error_panel"
android:layout_marginTop="0dp" android:background="?attr/selectableItemBackground"
android:orientation="horizontal"> android:padding="10dp"
android:textColor="@color/background_title_color"
<TextView android:textSize="@dimen/search_suggestion_text_size"
android:id="@+id/correct_suggestion_text" tools:text="Showing results for lorem ipsum dolor sit amet consectetur adipisci elit" />
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:textColor="@color/background_title_color"
android:textSize="@dimen/search_suggestion_text_size" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/items_list" android:id="@+id/items_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_below="@+id/correct_suggestion_panel" android:layout_below="@+id/correct_suggestion"
android:scrollbars="vertical" android:scrollbars="vertical"
app:layoutManager="LinearLayoutManager" app:layoutManager="LinearLayoutManager"
tools:listitem="@layout/list_stream_item" /> tools:listitem="@layout/list_stream_item" />