33import androidx .annotation .NonNull ;
44import androidx .annotation .Nullable ;
55import androidx .appcompat .app .AppCompatActivity ;
6+ import androidx .core .widget .TextViewCompat ;
67
78import android .animation .LayoutTransition ;
89import android .app .AlertDialog ;
910import android .app .ProgressDialog ;
1011import android .graphics .Color ;
12+ import android .os .Build ;
1113import android .os .Bundle ;
1214import android .util .Log ;
1315import android .view .Menu ;
@@ -32,8 +34,6 @@ public class SearchActivity extends AppCompatActivity {
3234
3335 private TextView textResult = null ;
3436
35- private TextView textIllegalInput = null ;
36-
3737 private LinearLayout currentLayout = null ;
3838
3939 private Spinner filtersSpinner = null ;
@@ -276,9 +276,6 @@ private void disableCheck() {
276276 private void initSearch () {
277277 searchText = findViewById (R .id .searchInput );
278278 textResult = findViewById (R .id .textResult );
279- textResult .setVisibility (View .GONE );
280- textIllegalInput = findViewById (R .id .textIllegalInput );
281- textIllegalInput .setVisibility (View .GONE );
282279 currentLayout = findViewById (R .id .resultFullContainer );
283280
284281 searchText .setOnQueryTextListener (new SearchView .OnQueryTextListener () {
@@ -291,11 +288,12 @@ public boolean onQueryTextSubmit(final String query) {
291288 @ Override
292289 public boolean onQueryTextChange (final String newText ) {
293290 String searchInput = newText .trim ();
294- textIllegalInput .setVisibility (View .GONE );
291+ textResult .setText (R .string .search_prompt );
292+ textResult .setTextColor (getColor (R .color .colorDefaultText ));
295293 if (!searchInput .equals ("" )) {
296294 if (!validate (searchInput , translateOptionsParam ())) {
297- textResult .setVisibility ( View . GONE );
298- textIllegalInput . setVisibility ( View . VISIBLE );
295+ textResult .setText ( R . string . search_illegal );
296+ textResult . setTextColor ( Color . RED );
299297 }
300298 } else {
301299 // No input
@@ -304,10 +302,18 @@ public boolean onQueryTextChange(final String newText) {
304302 return false ;
305303 }
306304 });
305+
306+ // Set auto-sizing
307+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
308+ textResult .setAutoSizeTextTypeWithDefaults (TextView .AUTO_SIZE_TEXT_TYPE_UNIFORM );
309+ } else {
310+ TextViewCompat .setAutoSizeTextTypeWithDefaults (textResult , TextViewCompat .AUTO_SIZE_TEXT_TYPE_UNIFORM );
311+ }
307312 }
308313
309314 private void clearResults () {
310- textResult .setVisibility (View .GONE );
315+ textResult .setText (R .string .search_prompt );
316+ textResult .setTextColor (getColor (R .color .colorDefaultText ));
311317 loadedResults = null ;
312318 currentLayout .removeAllViews ();
313319 }
@@ -329,7 +335,8 @@ private boolean startSearch(final String s) {
329335 String searchInput = s .trim ();
330336 Log .i ("startSearch" , "Current Input: " + searchInput + ", Current Manufacturer: "
331337 + translateFiltersParam () + ", Current Option: " + translateOptionsParam ());
332- textIllegalInput .setVisibility (View .GONE );
338+ textResult .setText (R .string .search_prompt );
339+ textResult .setTextColor (getColor (R .color .colorDefaultText ));
333340 loadedResults = null ;
334341 currentLayout .removeAllViews ();
335342 if (!searchInput .equals ("" )) {
@@ -338,13 +345,14 @@ private boolean startSearch(final String s) {
338345 return true ;
339346 } else {
340347 // Illegal input
341- textResult .setVisibility ( View . GONE );
342- textIllegalInput . setVisibility ( View . VISIBLE );
348+ textResult .setText ( R . string . search_illegal );
349+ textResult . setTextColor ( Color . RED );
343350 return false ;
344351 }
345352 } else {
346353 // No input
347- textResult .setVisibility (View .GONE );
354+ textResult .setText (R .string .search_prompt );
355+ textResult .setTextColor (getColor (R .color .colorDefaultText ));
348356 return false ;
349357 }
350358 }
@@ -427,8 +435,10 @@ public void run() {
427435 textResult .setVisibility (View .VISIBLE );
428436 if (positions .length == 0 ) {
429437 textResult .setText (R .string .search_noResult );
438+ textResult .setTextColor (getColor (R .color .colorDefaultText ));
430439 } else {
431440 textResult .setText (getString (R .string .search_found ) + resultCount + getString (R .string .search_results ));
441+ textResult .setTextColor (getColor (R .color .colorDefaultText ));
432442 }
433443 loadedResults = new TextView [1 ][positions .length ];
434444 loadedResults [0 ] = SpecsIntentHelper .initCategory (currentLayout , positions ,
0 commit comments