Skip to content

Commit

Permalink
fix(PR-review): use string format & remove redundant strings
Browse files Browse the repository at this point in the history
* Merge correct_suggestion_text and search_suggestion_helper_text_size to one with string format
* Remove redundant string search_showing_result_for and use already defined did_you_mean
  • Loading branch information
Royosef authored and wb9688 committed May 12, 2020
1 parent 94a2166 commit 7714b8e
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 30 deletions.
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ dependencies {
exclude module: 'support-annotations'
})

implementation 'com.github.TeamNewPipe:NewPipeExtractor:f3913e241e379adf0091319091e8f895c5fcfd07'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:baf5dd3e8f83bd8e3c5b616e1e377d06b8387624'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ public class SearchFragment extends BaseListFragment<SearchInfo, ListExtractor.I
private View searchClear;

private View correctSuggestionPanel;
private TextView correctSuggestionHelperText;
private TextView correctSuggestionText;

private View suggestionsPanel;
Expand Down Expand Up @@ -352,7 +351,6 @@ public void onSwiped(@NonNull final RecyclerView.ViewHolder viewHolder, final in

correctSuggestionPanel = rootView.findViewById(R.id.correct_suggestion_panel);
correctSuggestionText = rootView.findViewById(R.id.correct_suggestion_text);
correctSuggestionHelperText = rootView.findViewById(R.id.correct_suggestion_helper_text);
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -993,11 +991,12 @@ public void handleResult(@NonNull final SearchInfo result) {
}

private void handleSearchSuggestion(@NonNull final SearchInfo result) {
if (!result.getSearchSuggestion().isEmpty()) {
correctSuggestionText.setText(result.getSearchSuggestion());
correctSuggestionHelperText.setText(getString(result.isCorrectedSearch()
if (!TextUtils.isEmpty(result.getSearchSuggestion())) {
String helperText = getString(result.isCorrectedSearch()
? R.string.search_showing_result_for
: R.string.search_did_you_mean));
: R.string.did_you_mean);

correctSuggestionText.setText(String.format(helperText, result.getSearchSuggestion()));

correctSuggestionPanel.setOnClickListener(v -> {
correctSuggestionPanel.setVisibility(View.GONE);
Expand Down
18 changes: 3 additions & 15 deletions app/src/main/res/layout/fragment_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,15 @@
android:orientation="horizontal">

<TextView
android:id="@+id/correct_suggestion_helper_text"
android:layout_width="wrap_content"
android:id="@+id/correct_suggestion_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:textSize="@dimen/search_suggestion_helper_text_size"
android:textStyle="normal"
tools:text="@string/did_you_mean" />

<TextView
android:id="@+id/correct_suggestion_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="5dp"
android:layout_weight="1"
android:textColor="@color/background_title_color"
android:textSize="@dimen/search_suggestion_text_size"
android:textStyle="bold|italic"
tools:text="z101bara" />
android:textSize="@dimen/search_suggestion_text_size" />
</LinearLayout>

<androidx.recyclerview.widget.RecyclerView
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/res/values-land/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@
<!-- File picker dimensions -->
<dimen name="file_picker_items_text_size">16sp</dimen>

<dimen name="search_suggestion_text_size">14dp</dimen>
<dimen name="search_suggestion_helper_text_size">12sp</dimen>
<dimen name="search_suggestion_text_size">14sp</dimen>
</resources>
3 changes: 1 addition & 2 deletions app/src/main/res/values-sw600dp/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<dimen name="video_item_detail_like_image_width">18sp</dimen>
<!-- Paddings & Margins -->
<dimen name="video_item_detail_like_margin">10dp</dimen>
<dimen name="search_suggestion_text_size">14dp</dimen>
<dimen name="search_suggestion_helper_text_size">12sp</dimen>

<dimen name="search_suggestion_text_size">14sp</dimen>
</resources>
2 changes: 0 additions & 2 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,4 @@
<dimen name="feed_group_carousel_between_items_margin">4dp</dimen>

<dimen name="search_suggestion_text_size">16sp</dimen>
<dimen name="search_suggestion_helper_text_size">14sp</dimen>

</resources>
3 changes: 1 addition & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,5 @@
<string name="detail_sub_channel_thumbnail_view_description">Channel\'s avatar thumbnail</string>
<string name="channel_created_by">Created by %s</string>
<string name="video_detail_by">By %s</string>
<string name="search_showing_result_for">Showing results for</string>
<string name="search_did_you_mean">Did you mean:</string>
<string name="search_showing_result_for">Showing results for: %s</string>
</resources>

0 comments on commit 7714b8e

Please sign in to comment.