Simple Notepad Application for Android OS
Revision | 5963950bfc55aa1a28830852780a02b5aabf0afd (tree) |
---|---|
Time | 2017-08-19 12:16:14 |
Author | Masahiko, SAWAI <say@user...> |
Commiter | Masahiko, SAWAI |
Fixed a issue about search and back button
@@ -6,7 +6,7 @@ | ||
6 | 6 | android:versionName="1.0.13" |
7 | 7 | android:installLocation="auto" |
8 | 8 | > |
9 | - <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="25" /> | |
9 | + <uses-sdk android:minSdkVersion="11" android:targetSdkVersion="25" /> <!-- Android 7.1 --> | |
10 | 10 | |
11 | 11 | <uses-feature android:name="android.hardware.touchscreen" android:required="false" /> |
12 | 12 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
@@ -18,6 +18,8 @@ | ||
18 | 18 | android:debuggable="false" |
19 | 19 | > |
20 | 20 | <!-- |
21 | + android:resizeableActivity="true" | |
22 | + android:supportsPictureInPicture="true" | |
21 | 23 | android:uiOptions="splitActionBarWhenNarrow" |
22 | 24 | --> |
23 | 25 |
@@ -227,6 +227,7 @@ public class NotepadActivity extends Activity implements NotepadConstants, | ||
227 | 227 | |
228 | 228 | searchView.setOnQueryTextListener(this); |
229 | 229 | searchView.setOnCloseListener(this); |
230 | + Log.v(LOG_TAG, "initialQueryString => " + initialQueryString); | |
230 | 231 | if (!TextUtils.isEmpty(initialQueryString)) |
231 | 232 | { |
232 | 233 | searchView.setIconified(false); |
@@ -249,8 +250,19 @@ public class NotepadActivity extends Activity implements NotepadConstants, | ||
249 | 250 | case android.R.id.home: |
250 | 251 | if (searchView != null) |
251 | 252 | { |
252 | - searchView.setQuery(null, false); | |
253 | - searchView.setIconified(true); | |
253 | + Log.v(LOG_TAG, "seachView.isShown() => " + searchView.isShown()); | |
254 | + Log.v(LOG_TAG, "seachView.isIconified() => " + searchView.isIconified()); | |
255 | + if (searchView.isShown() && !searchView.isIconified()) | |
256 | + { | |
257 | + if (!TextUtils.isEmpty(searchView.getQuery())) | |
258 | + { | |
259 | + Log.v(LOG_TAG, "Clear searchView query"); | |
260 | + searchView.setQuery(null, false); | |
261 | + reloadNoteList(); | |
262 | + } | |
263 | + Log.v(LOG_TAG, "Iconify seachView"); | |
264 | + searchView.setIconified(true); | |
265 | + } | |
254 | 266 | } |
255 | 267 | closeNoteDetailFragment(); |
256 | 268 | break; |
@@ -311,13 +323,15 @@ public class NotepadActivity extends Activity implements NotepadConstants, | ||
311 | 323 | boolean result; |
312 | 324 | Log.v(LOG_TAG, "Hello"); |
313 | 325 | |
314 | - if ((keyCode == KeyEvent.KEYCODE_BACK) | |
315 | - && searchView.isIconified() == false) | |
326 | + Log.v(LOG_TAG, "searchView.isIconified() => " + searchView.isIconified()); // androud 4 : true, androud 7 : false | |
327 | + Log.v(LOG_TAG, "searchView.isShown() => " + searchView.isShown()); | |
328 | + | |
329 | + if ((keyCode == KeyEvent.KEYCODE_BACK) && searchView.isShown() && !searchView.isIconified()) | |
316 | 330 | { |
331 | + Log.v(LOG_TAG, "Close SeachView"); | |
317 | 332 | searchView.setQuery(null, false); |
318 | 333 | searchView.setIconified(true); |
319 | 334 | result = true; |
320 | - | |
321 | 335 | } |
322 | 336 | else |
323 | 337 | { |
@@ -327,8 +341,8 @@ public class NotepadActivity extends Activity implements NotepadConstants, | ||
327 | 341 | Log.v(LOG_TAG, "Bye"); |
328 | 342 | return result; |
329 | 343 | } |
330 | - | |
331 | 344 | // BEGIN ---------- SeachView.OnCloseListener ---------- |
345 | + | |
332 | 346 | public boolean onClose() |
333 | 347 | { |
334 | 348 | Log.v(LOG_TAG, "Hello"); |
@@ -358,7 +372,11 @@ public class NotepadActivity extends Activity implements NotepadConstants, | ||
358 | 372 | { |
359 | 373 | Log.v(LOG_TAG, "Hello"); |
360 | 374 | |
361 | - doSeachWithQueryText(queryText); | |
375 | + doSearchWithQueryText(queryText); | |
376 | + if (TextUtils.isEmpty(queryText) == false && searchView != null && searchView.isIconified()) | |
377 | + { | |
378 | + searchView.setIconified(false); | |
379 | + } | |
362 | 380 | |
363 | 381 | Log.v(LOG_TAG, "Bye"); |
364 | 382 | return true; |
@@ -545,7 +563,7 @@ public class NotepadActivity extends Activity implements NotepadConstants, | ||
545 | 563 | Log.v(LOG_TAG, "Bye"); |
546 | 564 | } |
547 | 565 | |
548 | - private void doSeachWithQueryText(String queryString) | |
566 | + private void doSearchWithQueryText(String queryString) | |
549 | 567 | { |
550 | 568 | Log.v(LOG_TAG, "Hello"); |
551 | 569 | Log.v(LOG_TAG, "queryString => " + queryString); |
@@ -37,9 +37,9 @@ | ||
37 | 37 | <string name="search_note_hint">ノートを検索</string> |
38 | 38 | <string name="search_note_description">ノートを検索します。</string> |
39 | 39 | <string name="find_word_hint">単語を検索</string> |
40 | - <plurals name="found_word_count_message"> | |
41 | - <item quantity="other">%1$d か所ありました</item> | |
42 | - </plurals> | |
40 | + <plurals name="found_word_count_message"> | |
41 | + <item quantity="other">%1$d か所ありました</item> | |
42 | + </plurals> | |
43 | 43 | |
44 | 44 | <!-- activity title --> |
45 | 45 | <string name="note_list_title">ノート一覧</string> |