From 4f98921aab412cc2c6576e617075aee103a490da Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 14 Jan 2023 22:24:33 +0100 Subject: [PATCH] switch to the Player tab on clicking Search --- .../voicerecorder/activities/MainActivity.kt | 11 +++++++++++ .../voicerecorder/adapters/ViewPagerAdapter.kt | 4 ++++ .../voicerecorder/fragments/PlayerFragment.kt | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/MainActivity.kt index b238d2d..e431417 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/activities/MainActivity.kt @@ -95,6 +95,14 @@ class MainActivity : SimpleActivity() { main_menu.toggleHideOnScroll(false) main_menu.setupMenu() + main_menu.onSearchOpenListener = { + view_pager.currentItem = 1 + } + + main_menu.onSearchTextChangedListener = { text -> + getPagerAdapter()?.searchTextChanged(text) + } + main_menu.getToolbar().setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.more_apps_from_us -> launchMoreAppsFromUsIntent() @@ -142,6 +150,9 @@ class MainActivity : SimpleActivity() { main_tabs_holder.onTabSelectionChanged( tabUnselectedAction = { updateBottomTabItemColors(it.customView, false) + if (it.position == 1) { + main_menu.closeSearch() + } }, tabSelectedAction = { view_pager.currentItem = it.position diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/ViewPagerAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/ViewPagerAdapter.kt index 1354777..0a67177 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/ViewPagerAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/adapters/ViewPagerAdapter.kt @@ -43,4 +43,8 @@ class ViewPagerAdapter(private val activity: SimpleActivity) : PagerAdapter() { } fun finishActMode() = (mFragments[1] as? PlayerFragment)?.finishActMode() + + fun searchTextChanged(text: String) { + (mFragments[1] as? PlayerFragment)?.onSearchTextChanged(text) + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt index 7468022..d7c52d1 100644 --- a/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/voicerecorder/fragments/PlayerFragment.kt @@ -390,6 +390,10 @@ class PlayerFragment(context: Context, attributeSet: AttributeSet) : MyViewPager player_progress_max.text = (recording?.duration ?: 0).getFormattedDuration() } + fun onSearchTextChanged(text: String) { + + } + private fun togglePlayPause() { if (getIsPlaying()) { pausePlayback()