#2319 search is popped after item opening

This commit is contained in:
HissPirat 2020-08-23 11:39:48 +02:00
parent b8007de398
commit ca8362f8b3
4 changed files with 12 additions and 8 deletions

View File

@ -44,6 +44,7 @@ import org.kiwix.kiwixmobile.core.main.ZIM_FILE_URI_KEY
import org.kiwix.kiwixmobile.core.utils.titleToUrl import org.kiwix.kiwixmobile.core.utils.titleToUrl
import org.kiwix.kiwixmobile.core.utils.urlSuffixToParsableUrl import org.kiwix.kiwixmobile.core.utils.urlSuffixToParsableUrl
import org.kiwix.kiwixmobile.kiwixActivityComponent import org.kiwix.kiwixmobile.kiwixActivityComponent
import org.kiwix.kiwixmobile.nav.destination.reader.KiwixReaderFragmentDirections
const val NAVIGATE_TO_ZIM_HOST_FRAGMENT = "navigate_to_zim_host_fragment" const val NAVIGATE_TO_ZIM_HOST_FRAGMENT = "navigate_to_zim_host_fragment"
@ -142,6 +143,10 @@ class KiwixMainActivity : CoreMainActivity() {
navigate(R.id.zimHostFragment) navigate(R.id.zimHostFragment)
} }
override fun openSearch() {
navigate(KiwixReaderFragmentDirections.actionReaderFragmentToSearchFragment())
}
override fun openPage(pageUrl: String, zimFilePath: String, shouldOpenInNewTab: Boolean) { override fun openPage(pageUrl: String, zimFilePath: String, shouldOpenInNewTab: Boolean) {
navigate( navigate(
R.id.readerFragment, R.id.readerFragment,

View File

@ -255,9 +255,7 @@ abstract class CoreMainActivity : BaseActivity(), WebViewProvider {
navigate(historyFragmentResId) navigate(historyFragmentResId)
} }
fun openSearch() { abstract fun openSearch()
navigate(searchFragmentResId)
}
private fun openBookmarks() { private fun openBookmarks() {
navigate(bookmarksFragmentResId) navigate(bookmarksFragmentResId)

View File

@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.core.search.viewmodel.effects
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import org.kiwix.kiwixmobile.core.base.SideEffect import org.kiwix.kiwixmobile.core.base.SideEffect
import org.kiwix.kiwixmobile.core.extensions.ActivityExtensions.popNavigationBackstack
import org.kiwix.kiwixmobile.core.main.CoreMainActivity import org.kiwix.kiwixmobile.core.main.CoreMainActivity
import org.kiwix.kiwixmobile.core.search.adapter.SearchListItem import org.kiwix.kiwixmobile.core.search.adapter.SearchListItem
@ -28,11 +29,7 @@ data class OpenSearchItem(
private val openInNewTab: Boolean = false private val openInNewTab: Boolean = false
) : SideEffect<Unit> { ) : SideEffect<Unit> {
override fun invokeWith(activity: AppCompatActivity) { override fun invokeWith(activity: AppCompatActivity) {
// activity.setResult( activity.popNavigationBackstack()
// Activity.RESULT_OK,
// Intent().putExtra(TAG_FILE_SEARCHED, searchListItem.value)
// .putExtra(TAG_FILE_SEARCHED_NEW_TAB, openInNewTab)
// )
(activity as CoreMainActivity).openSearchItem(searchListItem.value, openInNewTab) (activity as CoreMainActivity).openSearchItem(searchListItem.value, openInNewTab)
} }
} }

View File

@ -82,6 +82,10 @@ class CustomMainActivity : CoreMainActivity() {
.isVisible = false .isVisible = false
} }
override fun openSearch() {
TODO("Not yet implemented")
}
override fun openPage(pageUrl: String, zimFilePath: String, shouldOpenInNewTab: Boolean) { override fun openPage(pageUrl: String, zimFilePath: String, shouldOpenInNewTab: Boolean) {
val bundle = bundleOf(PAGE_URL_KEY to pageUrl, ZIM_FILE_URI_KEY to zimFilePath) val bundle = bundleOf(PAGE_URL_KEY to pageUrl, ZIM_FILE_URI_KEY to zimFilePath)
navigate(R.id.customReaderFragment, bundle) navigate(R.id.customReaderFragment, bundle)