From baed5f3c75fca5cc7add693a165cdd8c10e7d726 Mon Sep 17 00:00:00 2001 From: Menna Mohammed <33840994+mennamohamed21@users.noreply.github.com> Date: Sun, 30 Dec 2018 00:45:54 +0200 Subject: [PATCH 1/2] Add SearchinNote function searchInNotefunction search in the note content and hilight the search keyword the function need some inhancement --- build.gradle | 3 ++ .../android/omninotes/DetailFragment.java | 54 ++++++++++++++++++- omniNotes/src/main/res/menu/menu_detail.xml | 7 +++ .../src/main/res/values-ar-rSA/strings.xml | 1 + .../src/main/res/values-ca-rES/strings.xml | 1 + .../src/main/res/values-cs-rCZ/strings.xml | 1 + .../src/main/res/values-de-rDE/strings.xml | 1 + .../src/main/res/values-el-rGR/strings.xml | 1 + .../src/main/res/values-en-rUS/strings.xml | 1 + .../src/main/res/values-es-rES/strings.xml | 1 + omniNotes/src/main/res/values/strings.xml | 1 + 11 files changed, 71 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8de87bcc84..1301954a76 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,9 @@ buildscript { repositories { + maven { + url 'https://dl.google.com/dl/android/maven2' + } jcenter() google() } diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/DetailFragment.java b/omniNotes/src/main/java/it/feio/android/omninotes/DetailFragment.java index d448a7bc33..1e6448ba8e 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/DetailFragment.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/DetailFragment.java @@ -20,7 +20,9 @@ import android.annotation.SuppressLint; import android.app.Activity; import android.app.DatePickerDialog.OnDateSetListener; +import android.app.SearchManager; import android.app.TimePickerDialog.OnTimeSetListener; +import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; @@ -48,6 +50,7 @@ import android.support.v4.util.Pair; import android.support.v4.view.MenuItemCompat; import android.support.v4.widget.DrawerLayout; +import android.support.v7.widget.SearchView; import android.text.Editable; import android.text.Selection; import android.text.TextUtils; @@ -59,6 +62,7 @@ import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; import android.view.animation.AnimationUtils; +import android.view.inputmethod.EditorInfo; import android.widget.*; import butterknife.BindView; import butterknife.ButterKnife; @@ -1102,6 +1106,9 @@ public boolean onOptionsItemSelected(MenuItem item) { case R.id.menu_note_info: showNoteInfo(); break; + case R.id.menu_note_search: + searchInNote(item); + break; default: Log.w(Constants.TAG, "Invalid menu option selected"); } @@ -1120,8 +1127,53 @@ private void showNoteInfo() { startActivity(intent); } + private void searchInNote(MenuItem item) { + + + noteTmp.setTitle(getNoteTitle()); + noteTmp.setContent(getNoteContent()); + + android.support.v7.widget.SearchView search = (android.support.v7.widget.SearchView) item.getActionView(); + search.requestFocus(); + SearchManager searchManager = (SearchManager) mainActivity.getSystemService(Context.SEARCH_SERVICE); + search.setSearchableInfo(searchManager.getSearchableInfo(mainActivity.getComponentName())); + search.setImeOptions(EditorInfo.IME_ACTION_SEARCH); + search.setOnQueryTextListener(new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextSubmit(String query) { + + return false; + } - private void navigateUp() { + @Override + public boolean onQueryTextChange(String newText) { + if (!newText.isEmpty()) { + String NewNoteContent = search(newText); + + noteTmp.setContent(NewNoteContent); + //View contentView = root.findViewById(R.id.detail_content); + + //((EditText)contentView).setText(NewNoteContent); + } + noteTmp.setContent(newText); + return true; + } + }); + } + private String search(String Searchkey) + { + String NoteContent= noteTmp.getContent(); + Boolean check; + check= NoteContent.matches("(?i).*Searchkey.*"); + if (check==true) + { + String newString = NoteContent.replaceAll(Searchkey, ""+Searchkey+""); + return newString; + } + else + return NoteContent; + } + private void navigateUp() { afterSavedReturnsToList = true; saveAndExit(this); } diff --git a/omniNotes/src/main/res/menu/menu_detail.xml b/omniNotes/src/main/res/menu/menu_detail.xml index c972c1ff8b..55fa2bdbcd 100644 --- a/omniNotes/src/main/res/menu/menu_detail.xml +++ b/omniNotes/src/main/res/menu/menu_detail.xml @@ -103,6 +103,13 @@ android:title="@string/untrash" android:visible="false" app:showAsAction="ifRoom"/> + رمز تذكير الملاحظة فتح قائمة الملاحة إغلاق قائمة الملاحة + Search diff --git a/omniNotes/src/main/res/values-ca-rES/strings.xml b/omniNotes/src/main/res/values-ca-rES/strings.xml index 69c0f0b07f..abb2622fda 100644 --- a/omniNotes/src/main/res/values-ca-rES/strings.xml +++ b/omniNotes/src/main/res/values-ca-rES/strings.xml @@ -389,4 +389,5 @@ símbol de recordatori de nota Obre el tauler de navegació Tanca el tauler de navegació + Search diff --git a/omniNotes/src/main/res/values-cs-rCZ/strings.xml b/omniNotes/src/main/res/values-cs-rCZ/strings.xml index 4df9023cf9..fcb6b3cc9a 100644 --- a/omniNotes/src/main/res/values-cs-rCZ/strings.xml +++ b/omniNotes/src/main/res/values-cs-rCZ/strings.xml @@ -389,4 +389,5 @@ symbol připomenutí poznámky Otevřít navigační lištu Zavřít navigační lištu + Search diff --git a/omniNotes/src/main/res/values-de-rDE/strings.xml b/omniNotes/src/main/res/values-de-rDE/strings.xml index ddf4696242..83ac3e5cfb 100644 --- a/omniNotes/src/main/res/values-de-rDE/strings.xml +++ b/omniNotes/src/main/res/values-de-rDE/strings.xml @@ -389,4 +389,5 @@ Erinnerungssymbol Navigationsleiste öffnen Navigationsleiste schließen + Search diff --git a/omniNotes/src/main/res/values-el-rGR/strings.xml b/omniNotes/src/main/res/values-el-rGR/strings.xml index 03305a6196..916797c6f8 100644 --- a/omniNotes/src/main/res/values-el-rGR/strings.xml +++ b/omniNotes/src/main/res/values-el-rGR/strings.xml @@ -389,4 +389,5 @@ σύμβολο υπενθύμισης σημείωσης Άνοιγμα μενού πλοήγησης Κλείσιμο μενού πλοήγησης + Search diff --git a/omniNotes/src/main/res/values-en-rUS/strings.xml b/omniNotes/src/main/res/values-en-rUS/strings.xml index 75d77927b5..2fc44b66e8 100644 --- a/omniNotes/src/main/res/values-en-rUS/strings.xml +++ b/omniNotes/src/main/res/values-en-rUS/strings.xml @@ -389,4 +389,5 @@ note reminder symbol Open navigation drawer Close navigation drawer + Search diff --git a/omniNotes/src/main/res/values-es-rES/strings.xml b/omniNotes/src/main/res/values-es-rES/strings.xml index 2eaa40889d..fb36644de2 100644 --- a/omniNotes/src/main/res/values-es-rES/strings.xml +++ b/omniNotes/src/main/res/values-es-rES/strings.xml @@ -390,4 +390,5 @@ símbolo de recordatorio de nota Abrir cajón de navegación Cerrar cajón de navegación + Search diff --git a/omniNotes/src/main/res/values/strings.xml b/omniNotes/src/main/res/values/strings.xml index 0e9e49ccf7..738338655b 100644 --- a/omniNotes/src/main/res/values/strings.xml +++ b/omniNotes/src/main/res/values/strings.xml @@ -409,5 +409,6 @@ note reminder symbol Open navigation drawer Close navigation drawer + Search From d61c5504456b5fbde497a9a513da530a3bf625e3 Mon Sep 17 00:00:00 2001 From: Menna Mohammed <33840994+mennamohamed21@users.noreply.github.com> Date: Mon, 31 Dec 2018 20:08:30 +0200 Subject: [PATCH 2/2] added a Curly bracket --- .../main/java/it/feio/android/omninotes/DetailFragment.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/omniNotes/src/main/java/it/feio/android/omninotes/DetailFragment.java b/omniNotes/src/main/java/it/feio/android/omninotes/DetailFragment.java index 1e6448ba8e..209a8aba48 100644 --- a/omniNotes/src/main/java/it/feio/android/omninotes/DetailFragment.java +++ b/omniNotes/src/main/java/it/feio/android/omninotes/DetailFragment.java @@ -1171,7 +1171,9 @@ private String search(String Searchkey) return newString; } else - return NoteContent; + { + return NoteContent; + } } private void navigateUp() { afterSavedReturnsToList = true;