Skip to content

Commit 7bbe04f

Browse files
committed
Search is now not case sensitive; search UI modify 4.7.4
1 parent 6289d74 commit 7bbe04f

File tree

6 files changed

+29
-28
lines changed

6 files changed

+29
-28
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "com.macindex.macindex"
88
minSdkVersion 23
99
targetSdkVersion 30
10-
versionCode 19
11-
versionName "4.7.3"
10+
versionCode 20
11+
versionName "4.7.4"
1212
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1313
}
1414
buildTypes {

app/src/main/java/com/macindex/macindex/MachineHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ public int[] searchHelper(final String columnName, final String searchInput, fin
10581058
for (int machineToVerify : finalPositions) {
10591059
String[] rawUndefinedQuery = getUndefined(machineToVerify, columnName).split("~");
10601060
for (String resultToVerify : rawUndefinedQuery) {
1061-
if (resultToVerify.equals(searchInput)) {
1061+
if (resultToVerify.equalsIgnoreCase(searchInput)) {
10621062
verifiedPositions.add(machineToVerify);
10631063
break;
10641064
}

app/src/main/java/com/macindex/macindex/SearchActivity.java

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
import androidx.annotation.NonNull;
44
import androidx.annotation.Nullable;
55
import androidx.appcompat.app.AppCompatActivity;
6+
import androidx.core.widget.TextViewCompat;
67

78
import android.animation.LayoutTransition;
89
import android.app.AlertDialog;
910
import android.app.ProgressDialog;
1011
import android.graphics.Color;
12+
import android.os.Build;
1113
import android.os.Bundle;
1214
import android.util.Log;
1315
import 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,

app/src/main/res/layout/activity_search.xml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,13 @@
2828

2929
<Space
3030
android:layout_width="match_parent"
31-
android:layout_height="10dp"
32-
android:layout_weight="1" />
33-
34-
<TextView
35-
android:id="@+id/textIllegalInput"
36-
android:layout_width="match_parent"
37-
android:layout_height="wrap_content"
38-
android:gravity="center"
39-
android:text="@string/search_illegal"
40-
android:textColor="#D50000"
41-
android:textStyle="bold" />
31+
android:layout_height="10dp" />
4232

4333
<TextView
4434
android:id="@+id/textResult"
4535
android:layout_width="match_parent"
4636
android:layout_height="wrap_content"
4737
android:gravity="center"
48-
android:text="@string/search_noResult"
4938
android:textStyle="bold" />
5039

5140
<Space

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<string name="search_noResult">无结果</string>
6161
<string name="search_found">共找到&#160;</string>
6262
<string name="search_results">&#160;个结果</string>
63+
<string name="search_prompt">点按回车来开始搜索</string>
6364
<string name="search_illegal">无效输入(请参阅帮助内容)</string>
6465
<string name="search_disable_identification">Old world Macintosh 没有型号标识符和 EMC 编号。请以形态标识符代替。也请参阅帮助内容。</string>
6566
<string name="search_disable_gestalt">New world Macintosh 没有形态标识符。请以型号标识符代替。也请参阅帮助内容。</string>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<string name="search_noResult">No result</string>
6161
<string name="search_found">Found&#160;</string>
6262
<string name="search_results">&#160;result(s)</string>
63+
<string name="search_prompt">Press return to start searching</string>
6364
<string name="search_illegal">Invalid Input</string>
6465
<string name="search_disable_identification">Old world Macintosh does not have Identification and EMC Number. Please use the Gestalt ID instead.</string>
6566
<string name="search_disable_gestalt">New world Macintosh does not have a Gestalt ID. Please use the Identification instead.</string>

0 commit comments

Comments
 (0)