diff --git a/android-base/src/main/AndroidManifest.xml b/android-base/src/main/AndroidManifest.xml index 215383317..ca91ffd57 100644 --- a/android-base/src/main/AndroidManifest.xml +++ b/android-base/src/main/AndroidManifest.xml @@ -10,11 +10,15 @@ android:supportsRtl="false" android:usesCleartextTraffic="true" android:theme="@style/Theme.DroidKaigi.DayNight"> - + + + diff --git a/android-base/src/main/java/io/github/droidkaigi/confsched2020/MainActivity.kt b/android-base/src/main/java/io/github/droidkaigi/confsched2020/MainActivity.kt index 2add7fe69..6c6294873 100644 --- a/android-base/src/main/java/io/github/droidkaigi/confsched2020/MainActivity.kt +++ b/android-base/src/main/java/io/github/droidkaigi/confsched2020/MainActivity.kt @@ -349,6 +349,11 @@ class MainActivity : AppCompatActivity(), HasAndroidInjector { } } + override fun onNewIntent(intent: Intent?) { + super.onNewIntent(intent) + setIntent(intent) + } + companion object { const val ENTIRE_SURVEY = "https://docs.google.com/forms/d/1pm-47edcdP3BYp59_cImgrvXiEOWYTxtXYUUb8CpeE8/viewform" diff --git a/android-base/src/main/res/xml/searchable.xml b/android-base/src/main/res/xml/searchable.xml new file mode 100644 index 000000000..a3b95e80f --- /dev/null +++ b/android-base/src/main/res/xml/searchable.xml @@ -0,0 +1,7 @@ + + + + diff --git a/feature/session/src/main/java/io/github/droidkaigi/confsched2020/session/ui/SearchSessionsFragment.kt b/feature/session/src/main/java/io/github/droidkaigi/confsched2020/session/ui/SearchSessionsFragment.kt index 8c804f14c..3e5a700e7 100644 --- a/feature/session/src/main/java/io/github/droidkaigi/confsched2020/session/ui/SearchSessionsFragment.kt +++ b/feature/session/src/main/java/io/github/droidkaigi/confsched2020/session/ui/SearchSessionsFragment.kt @@ -1,7 +1,10 @@ package io.github.droidkaigi.confsched2020.session.ui import android.app.Activity +import android.app.SearchManager +import android.content.Intent import android.os.Bundle +import android.speech.RecognizerIntent import android.view.Menu import android.view.MenuInflater import android.view.View @@ -9,6 +12,7 @@ import android.view.inputmethod.InputMethodManager import android.widget.ImageView import androidx.appcompat.content.res.AppCompatResources import androidx.appcompat.widget.SearchView +import androidx.core.content.getSystemService import androidx.core.view.updatePadding import androidx.fragment.app.Fragment import androidx.lifecycle.LifecycleOwner @@ -65,6 +69,8 @@ class SearchSessionsFragment : Fragment(R.layout.fragment_search_sessions), Inje @Inject lateinit var sectionHeaderItemFactory: SectionHeaderItem.Factory + private var menu: Menu? = null + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setHasOptionsMenu(true) @@ -148,22 +154,51 @@ class SearchSessionsFragment : Fragment(R.layout.fragment_search_sessions), Inje } } + override fun onResume() { + super.onResume() + val activity = requireActivity() + val intent = activity.intent + if (intent.action == Intent.ACTION_SEARCH && + intent.hasExtra(RecognizerIntent.EXTRA_RESULTS) + ) { + val query: String = requireNotNull(intent.getStringExtra(SearchManager.QUERY)) + val searchView: SearchView? = + menu?.findItem(R.id.search_view)?.actionView as SearchView? + searchView?.setQuery(query, true) + } + } + override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) { super.onCreateOptionsMenu(menu, inflater) inflater.inflate(R.menu.menu_search_sessions, menu) + this.menu = menu val searchView = menu.findItem(R.id.search_view).actionView as SearchView + val context = requireContext() + context.getSystemService()?.let { searchManager -> + searchView.setSearchableInfo( + searchManager.getSearchableInfo(requireActivity().componentName) + ) + } (searchView.findViewById(AppcompatRId.search_button) as ImageView).setColorFilter( AppCompatResources.getColorStateList( - requireContext(), + context, R.color.search_icon ).defaultColor ) (searchView.findViewById(AppcompatRId.search_close_btn) as ImageView).setColorFilter( AppCompatResources.getColorStateList( - requireContext(), + context, R.color.search_close_icon ).defaultColor ) + val searchVoiceButton = searchView.findViewById(AppcompatRId.search_voice_btn) as ImageView + searchVoiceButton.setImageResource(R.drawable.ic_keyboard_voice_24px) + searchVoiceButton.setColorFilter( + AppCompatResources.getColorStateList( + context, + R.color.search_voice_icon + ).defaultColor + ) searchView.isIconified = false searchView.clearFocus() val searchResult = searchSessionsViewModel.uiModel.requireValue().searchResult diff --git a/feature/session/src/main/res/color-night/search_voice_icon.xml b/feature/session/src/main/res/color-night/search_voice_icon.xml new file mode 100644 index 000000000..70b01e8bc --- /dev/null +++ b/feature/session/src/main/res/color-night/search_voice_icon.xml @@ -0,0 +1,4 @@ + + + + diff --git a/feature/session/src/main/res/color/search_voice_icon.xml b/feature/session/src/main/res/color/search_voice_icon.xml new file mode 100644 index 000000000..5bf0d37aa --- /dev/null +++ b/feature/session/src/main/res/color/search_voice_icon.xml @@ -0,0 +1,4 @@ + + + + diff --git a/feature/session/src/main/res/drawable/ic_keyboard_voice_24px.xml b/feature/session/src/main/res/drawable/ic_keyboard_voice_24px.xml new file mode 100644 index 000000000..e5f1c9c89 --- /dev/null +++ b/feature/session/src/main/res/drawable/ic_keyboard_voice_24px.xml @@ -0,0 +1,9 @@ + + +