diff --git a/app/build.gradle b/app/build.gradle index 1a51aae14f..9b64d87f23 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 21 targetSdkVersion 34 - versionCode 1072 - versionName "0.10.72" + versionCode 1073 + versionName "0.10.73" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/course/CourseFragment.java b/app/src/main/java/org/ole/planet/myplanet/ui/course/CourseFragment.java index 197f2ff38a..db3badd00c 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/course/CourseFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/course/CourseFragment.java @@ -2,19 +2,18 @@ import android.app.AlertDialog; -import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.Button; +import android.text.Editable; +import android.text.TextWatcher; import android.widget.CheckBox; import android.widget.EditText; -import android.widget.ImageView; import android.widget.Spinner; import android.widget.TextView; import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; import androidx.recyclerview.widget.RecyclerView; import com.google.gson.Gson; @@ -26,7 +25,6 @@ import org.ole.planet.myplanet.callback.TagClickListener; import org.ole.planet.myplanet.model.RealmCourseProgress; import org.ole.planet.myplanet.model.RealmMyCourse; -import org.ole.planet.myplanet.model.RealmMyLibrary; import org.ole.planet.myplanet.model.RealmRating; import org.ole.planet.myplanet.model.RealmSearchActivity; import org.ole.planet.myplanet.model.RealmTag; @@ -45,7 +43,6 @@ public class CourseFragment extends BaseRecyclerFragment implements OnCourseItemSelected, TagClickListener { TextView tvAddToLib, tvMessage, tvSelected; EditText etSearch; - ImageView imgSearch; AdapterCourses adapterCourses; Button btnRemove, orderByDate, orderByTitle; CheckBox selectAll; @@ -85,10 +82,20 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { btnRemove.setVisibility(View.VISIBLE); } - imgSearch.setOnClickListener(view -> { - adapterCourses.setCourseList(filterCourseByTag(etSearch.getText().toString(), searchTags)); - showNoData(tvMessage, adapterCourses.getItemCount()); - KeyboardUtils.hideSoftKeyboard(getActivity()); + etSearch.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + adapterCourses.setCourseList(filterCourseByTag(etSearch.getText().toString(), searchTags)); + showNoData(tvMessage, adapterCourses.getItemCount()); + } + + @Override + public void afterTextChanged(Editable s) { + } }); btnRemove.setOnClickListener(V -> new AlertDialog.Builder(this.getContext()) @@ -98,7 +105,6 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { if (adapterCourses.getCourseList().size() == 0) { selectAll.setVisibility(View.GONE); etSearch.setVisibility(View.GONE); - imgSearch.setVisibility(View.GONE); tvAddToLib.setVisibility(View.GONE); getView().findViewById(R.id.filter).setVisibility(View.GONE); spn.setVisibility(View.GONE); @@ -159,7 +165,6 @@ private void initializeView() { if (adapterCourses.getCourseList().size() == 0) { selectAll.setVisibility(View.GONE); etSearch.setVisibility(View.GONE); - imgSearch.setVisibility(View.GONE); tvAddToLib.setVisibility(View.GONE); getView().findViewById(R.id.filter).setVisibility(View.GONE); spn.setVisibility(View.GONE); @@ -173,7 +178,6 @@ private void initializeView() { btnRemove = getView().findViewById(R.id.btn_remove); spnGrade = getView().findViewById(R.id.spn_grade); spnSubject = getView().findViewById(R.id.spn_subject); - imgSearch = getView().findViewById(R.id.img_search); tvMessage = getView().findViewById(R.id.tv_message); getView().findViewById(R.id.tl_tags).setVisibility(View.GONE); tvFragmentInfo = getView().findViewById(R.id.tv_fragment_info); @@ -183,7 +187,6 @@ private void initializeView() { if (adapterCourses.getCourseList().size() == 0) { selectAll.setVisibility(View.GONE); etSearch.setVisibility(View.GONE); - imgSearch.setVisibility(View.GONE); tvAddToLib.setVisibility(View.GONE); getView().findViewById(R.id.filter).setVisibility(View.GONE); spn.setVisibility(View.GONE); diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryFragment.java b/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryFragment.java index afdeaab544..d7e8d7f210 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryFragment.java +++ b/app/src/main/java/org/ole/planet/myplanet/ui/library/LibraryFragment.java @@ -6,12 +6,13 @@ import android.app.AlertDialog; import android.os.Bundle; +import android.text.Editable; +import android.text.TextWatcher; import android.view.View; import android.widget.AdapterView; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; -import android.widget.ImageView; import android.widget.Spinner; import android.widget.TextView; @@ -51,7 +52,6 @@ public class LibraryFragment extends BaseRecyclerFragment implements OnLibraryItemSelected, ChipDeletedListener, TagClickListener, OnFilterListener { TextView tvAddToLib, tvSelected; EditText etSearch, etTags; - ImageView imgSearch; AdapterLibrary adapterLibrary; FlexboxLayout flexBoxTags; List searchTags; @@ -90,7 +90,6 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { etTags = getView().findViewById(R.id.et_tags); clearTags = getView().findViewById(R.id.btn_clear_tags); tvSelected = getView().findViewById(R.id.tv_selected); - imgSearch = getView().findViewById(R.id.img_search); flexBoxTags = getView().findViewById(R.id.flexbox_tags); selectAll = getView().findViewById(R.id.selectAll); tvDelete = getView().findViewById(R.id.tv_delete); @@ -117,11 +116,22 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { }) .setNegativeButton(R.string.no, null).show()); - imgSearch.setOnClickListener(view -> { - adapterLibrary.setLibraryList(applyFilter(filterLibraryByTag(etSearch.getText().toString().trim(), searchTags))); - showNoData(tvMessage, adapterLibrary.getItemCount()); - KeyboardUtils.hideSoftKeyboard(getActivity()); + etSearch.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + adapterLibrary.setLibraryList(applyFilter(filterLibraryByTag(etSearch.getText().toString().trim(), searchTags))); + showNoData(tvMessage, adapterLibrary.getItemCount()); + } + + @Override + public void afterTextChanged(Editable s) { + } }); + getView().findViewById(R.id.btn_collections).setOnClickListener(view -> { CollectionsFragment f = CollectionsFragment.getInstance(searchTags, "resources"); f.setListener(LibraryFragment.this); @@ -167,7 +177,6 @@ private void checkList() { if (adapterLibrary.getLibraryList().size() == 0) { selectAll.setVisibility(View.GONE); etSearch.setVisibility(View.GONE); - imgSearch.setVisibility(View.GONE); tvAddToLib.setVisibility(View.GONE); spn.setVisibility(View.GONE); tvSelected.setVisibility(View.GONE); diff --git a/app/src/main/res/layout/layout_search.xml b/app/src/main/res/layout/layout_search.xml index 266b21f99e..90cf766f36 100644 --- a/app/src/main/res/layout/layout_search.xml +++ b/app/src/main/res/layout/layout_search.xml @@ -54,14 +54,5 @@ android:maxLines="1" android:padding="@dimen/padding_normal" /> - - -