mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-17 03:16:27 -04:00
Merge pull request #2309 from kiwix/feature/Frans-Lukas/2302-fix-search-back-arrow
#2302 back-button now works from search
This commit is contained in:
commit
85b0facb54
@ -48,7 +48,7 @@ import org.kiwix.kiwixmobile.core.search.viewmodel.SearchOrigin.FromWebView
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.State.NoResults
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.State.Results
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.DeleteRecentSearch
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.PopFragmentBackstack
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.FinishActivity
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.OpenSearchItem
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.ProcessActivityResult
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.SaveSearchToRecents
|
||||
@ -93,7 +93,7 @@ class SearchViewModel @Inject constructor(
|
||||
|
||||
private fun actionMapper() = actions.map {
|
||||
when (it) {
|
||||
ExitedSearch -> effects.offer(PopFragmentBackstack)
|
||||
ExitedSearch -> effects.offer(FinishActivity)
|
||||
is OnItemClick -> saveSearchAndOpenItem(it.searchListItem, false)
|
||||
is OnOpenInNewTabClick -> saveSearchAndOpenItem(it.searchListItem, true)
|
||||
is OnItemLongClick -> showDeleteDialog(it)
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Kiwix Android
|
||||
* Copyright (c) 2020 Kiwix <android.kiwix.org>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.kiwix.kiwixmobile.core.search.viewmodel.effects
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import org.kiwix.kiwixmobile.core.base.SideEffect
|
||||
|
||||
object FinishActivity : SideEffect<Unit> {
|
||||
override fun invokeWith(activity: AppCompatActivity) {
|
||||
activity.finish()
|
||||
}
|
||||
}
|
@ -54,7 +54,7 @@ import org.kiwix.kiwixmobile.core.search.viewmodel.SearchOrigin.FromWebView
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.State.NoResults
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.State.Results
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.DeleteRecentSearch
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.PopFragmentBackstack
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.FinishActivity
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.OpenSearchItem
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.ProcessActivityResult
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.SaveSearchToRecents
|
||||
@ -218,7 +218,7 @@ internal class SearchViewModelTest {
|
||||
inner class ActionMapping {
|
||||
@Test
|
||||
fun `ExitedSearch offers Finish`() {
|
||||
actionResultsInEffects(ExitedSearch, PopFragmentBackstack)
|
||||
actionResultsInEffects(ExitedSearch, FinishActivity)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Kiwix Android
|
||||
* Copyright (c) 2020 Kiwix <android.kiwix.org>
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.kiwix.kiwixmobile.core.search.viewmodel.effects
|
||||
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.kiwix.kiwixmobile.core.main.CoreMainActivity
|
||||
|
||||
internal class FinishActivityTest {
|
||||
|
||||
@Test
|
||||
fun `invoke with finishes activity`() {
|
||||
val activity = mockk<CoreMainActivity>(relaxed = true)
|
||||
FinishActivity.invokeWith(activity)
|
||||
verify { activity.finish() }
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user