diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchFragmentTest.java b/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchFragmentTest.java deleted file mode 100644 index 1a4dd792a..000000000 --- a/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchFragmentTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Kiwix Android - * Copyright (c) 2019 Kiwix - * 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 . - * - */ - -package org.kiwix.kiwixmobile.search; - -import android.Manifest; -import androidx.test.espresso.matcher.ViewMatchers; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.filters.LargeTest; -import androidx.test.rule.ActivityTestRule; -import androidx.test.rule.GrantPermissionRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.kiwix.kiwixmobile.R; -import org.kiwix.kiwixmobile.main.KiwixMainActivity; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.action.ViewActions.click; -import static androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility; -import static androidx.test.espresso.matcher.ViewMatchers.withId; -import static androidx.test.espresso.matcher.ViewMatchers.withText; -import static org.hamcrest.CoreMatchers.allOf; - -@LargeTest -@RunWith(AndroidJUnit4.class) -public class SearchFragmentTest { - - @Rule - public ActivityTestRule mActivityTestRule = new ActivityTestRule<>( - KiwixMainActivity.class); - @Rule - public GrantPermissionRule readPermissionRule = - GrantPermissionRule.grant(Manifest.permission.READ_EXTERNAL_STORAGE); - @Rule - public GrantPermissionRule writePermissionRule = - GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE); - - @Test - public void SearchFragmentSimple() { - onView(allOf(withText(R.string.reader), - withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))).perform(click()); - onView(withId(R.id.menu_search)); - } -} diff --git a/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchFragmentTest.kt b/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchFragmentTest.kt new file mode 100644 index 000000000..bfeccded1 --- /dev/null +++ b/app/src/androidTest/java/org/kiwix/kiwixmobile/search/SearchFragmentTest.kt @@ -0,0 +1,35 @@ +/* + * Kiwix Android + * Copyright (c) 2019 Kiwix + * 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 . + * + */ +package org.kiwix.kiwixmobile.search + +import androidx.test.internal.runner.junit4.statement.UiThreadStatement +import com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed +import org.junit.Before +import org.junit.Test +import org.kiwix.kiwixmobile.BaseActivityTest +import org.kiwix.kiwixmobile.R + +class SearchFragmentTest : BaseActivityTest() { + @Before fun setUp() { + UiThreadStatement.runOnUiThread { activityRule.activity.navigate(R.id.searchFragment) } + } + + @Test fun searchFragmentSimple() { + assertDisplayed(R.string.menu_search_in_text) + } +} diff --git a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt index 58e78da20..5e5004d5a 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/main/KiwixMainActivity.kt @@ -38,7 +38,7 @@ import org.kiwix.kiwixmobile.core.base.FragmentActivityExtensions import org.kiwix.kiwixmobile.core.di.components.CoreComponent import org.kiwix.kiwixmobile.core.main.CoreMainActivity import org.kiwix.kiwixmobile.kiwixActivityComponent -import org.kiwix.kiwixmobile.nav.destination.library.LocalLibraryFragmentDirections +import org.kiwix.kiwixmobile.nav.destination.reader.KiwixReaderFragmentDirections const val NAVIGATE_TO_ZIM_HOST_FRAGMENT = "navigate_to_zim_host_fragment" @@ -95,7 +95,7 @@ class KiwixMainActivity : CoreMainActivity() { } } if (sharedPreferenceUtil.showIntro()) { - navigate(LocalLibraryFragmentDirections.actionLibraryFragmentToIntrofragment()) + navigate(KiwixReaderFragmentDirections.actionReaderFragmentToIntroFragment()) } } diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt index 550dd6290..559c6aebe 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/destination/reader/KiwixReaderFragment.kt @@ -111,6 +111,7 @@ class KiwixReaderFragment : CoreReaderFragment() { private fun openPageInBookFromNavigationArguments() { val args = KiwixReaderFragmentArgs.fromBundle(requireArguments()) + if (args.pageUrl.isNotEmpty()) { if (args.zimFileUri.isNotEmpty()) { tryOpeningZimFile(args.zimFileUri) @@ -250,9 +251,13 @@ class KiwixReaderFragment : CoreReaderFragment() { val settings = requireActivity().getSharedPreferences(SharedPreferenceUtil.PREF_KIWIX_MOBILE, 0) val zimFile = settings.getString(TAG_CURRENT_FILE, null) - if (zimFile != null) { + if (zimFile != null && File(zimFile).exists()) { if (zimReaderContainer.zimFile == null) { openZimFile(File(zimFile)) + Log.d( + TAG_KIWIX, + "Kiwix normal start, Opened last used zimFile: -> $zimFile" + ) } } else { getCurrentWebView().snack(R.string.zim_not_opened) diff --git a/app/src/main/res/navigation/kiwix_nav_graph.xml b/app/src/main/res/navigation/kiwix_nav_graph.xml index e51ca0ef7..c88915bc3 100644 --- a/app/src/main/res/navigation/kiwix_nav_graph.xml +++ b/app/src/main/res/navigation/kiwix_nav_graph.xml @@ -19,7 +19,7 @@ + app:startDestination="@id/readerFragment"> + -