diff --git a/.idea/misc.xml b/.idea/misc.xml index 9f71c83d..773fe0fb 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/app/src/main/res/menu/bottom_nav_menu.xml b/app/src/main/res/menu/bottom_nav_menu.xml index 9742222d..ef93e718 100644 --- a/app/src/main/res/menu/bottom_nav_menu.xml +++ b/app/src/main/res/menu/bottom_nav_menu.xml @@ -11,6 +11,11 @@ android:icon="@drawable/folder_24px" android:title="Library"/> + + + \ No newline at end of file diff --git a/feature/search/build.gradle b/feature/search/build.gradle index b92bd0d5..ee25aff1 100644 --- a/feature/search/build.gradle +++ b/feature/search/build.gradle @@ -27,9 +27,17 @@ android { dependencies { - implementation 'androidx.appcompat:appcompat:1.6.1' - implementation 'com.google.android.material:material:1.10.0' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' + implementation libs.androidx.appcompat + implementation libs.com.google.android.material + testImplementation libs.junit + androidTestImplementation libs.androidx.test.ext.junit + androidTestImplementation libs.androidx.test.espresso.core + + // Navigation + implementation libs.navigation.fragment + implementation libs.navigation.ui + implementation libs.navigation.dynamic.features.fragment + + // shared + implementation project(':shared:ui') } \ No newline at end of file diff --git a/feature/search/src/main/java/one/nem/lacerta/feature/search/SearchTopFragment.java b/feature/search/src/main/java/one/nem/lacerta/feature/search/SearchTopFragment.java new file mode 100644 index 00000000..f337a3e0 --- /dev/null +++ b/feature/search/src/main/java/one/nem/lacerta/feature/search/SearchTopFragment.java @@ -0,0 +1,142 @@ +package one.nem.lacerta.feature.search; + +import android.app.LauncherActivity; +import android.os.Bundle; + +import androidx.fragment.app.Fragment; + +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.SearchView; + +import java.util.ArrayList; + +/** + * A simple {@link Fragment} subclass. + * Use the {@link SearchTopFragment#newInstance} factory method to + * create an instance of this fragment. + */ +public class SearchTopFragment extends Fragment { + private static final String TAG = SearchTopFragment.class.getSimpleName(); + private final SearchTopFragment self = this; + + private SearchView searchView; + private String searchWord; + + // TODO: Rename parameter arguments, choose names that match + // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER + private static final String ARG_PARAM1 = "param1"; + private static final String ARG_PARAM2 = "param2"; + + // TODO: Rename and change types of parameters + private String mParam1; + private String mParam2; + + public SearchTopFragment() { + // Required empty public constructor + } + + /** + * Use this factory method to create a new instance of + * this fragment using the provided parameters. + * + * @param param1 Parameter 1. + * @param param2 Parameter 2. + * @return A new instance of fragment SearchTopFragment. + */ + // TODO: Rename and change types and number of parameters + public static SearchTopFragment newInstance(String param1, String param2) { + SearchTopFragment fragment = new SearchTopFragment(); + Bundle args = new Bundle(); + args.putString(ARG_PARAM1, param1); + args.putString(ARG_PARAM2, param2); + fragment.setArguments(args); + return fragment; + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + if (getArguments() != null) { + mParam1 = getArguments().getString(ARG_PARAM1); + mParam2 = getArguments().getString(ARG_PARAM2); + } + } + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + // Inflate the layout for this fragment + return inflater.inflate(R.layout.fragment_search_top, container, false); + } + + + + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + super.onCreateOptionsMenu(menu, inflater); + + + + + this.searchView.setIconifiedByDefault(true); + + + this.searchView.setSubmitButtonEnabled(false); + + + if (!this.searchWord.equals("")) { + + this.searchView.setQuery(this.searchWord, false); + } else { + String queryHint = self.getResources().getString(R.string.hello_blank_fragment); + + this.searchView.setQueryHint(queryHint); + } + this.searchView.setOnQueryTextListener(self.onQueryTextListener); + } + + private final SearchView.OnQueryTextListener onQueryTextListener = new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextSubmit(String query) { + + return self.setSearchWord(searchWord); + } + + @Override + public boolean onQueryTextChange(String query) { + + return false; + } + }; + private boolean setSearchWord(String query) { + + + if (searchWord != null && !searchWord.equals("")) { + + this.searchWord = searchWord; + } + + this.searchView.setIconified(false); + + this.searchView.onActionViewCollapsed(); + + this.searchView.clearFocus(); + return false; + } +} + + + + + interface LacertaSearch { + ArrayList autoSearch(String query, int limit); + + ArrayList autoSearch(String query, int limit, int offset); + } + + + diff --git a/feature/search/src/main/res/layout/fragment_search_top.xml b/feature/search/src/main/res/layout/fragment_search_top.xml new file mode 100644 index 00000000..34b12bd0 --- /dev/null +++ b/feature/search/src/main/res/layout/fragment_search_top.xml @@ -0,0 +1,27 @@ + + + + + + + + + + \ No newline at end of file diff --git a/feature/search/src/main/res/navigation/feature_search_navigation.xml b/feature/search/src/main/res/navigation/feature_search_navigation.xml new file mode 100644 index 00000000..56514559 --- /dev/null +++ b/feature/search/src/main/res/navigation/feature_search_navigation.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/feature/search/src/main/res/values/strings.xml b/feature/search/src/main/res/values/strings.xml new file mode 100644 index 00000000..6048840e --- /dev/null +++ b/feature/search/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + Hello blank fragment + \ No newline at end of file