diff --git a/app/src/main/java/org/kiwix/kiwixmobile/nav/helper/ScrollingViewWithBottomNavigationBehavior.kt b/app/src/main/java/org/kiwix/kiwixmobile/nav/helper/ScrollingViewWithBottomNavigationBehavior.kt index 4a067907f..7a6fde419 100644 --- a/app/src/main/java/org/kiwix/kiwixmobile/nav/helper/ScrollingViewWithBottomNavigationBehavior.kt +++ b/app/src/main/java/org/kiwix/kiwixmobile/nav/helper/ScrollingViewWithBottomNavigationBehavior.kt @@ -26,7 +26,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout import com.google.android.material.appbar.AppBarLayout import com.google.android.material.bottomappbar.BottomAppBar import com.google.android.material.bottomnavigation.BottomNavigationView -import org.kiwix.kiwixmobile.R /** * Inspired by James @ https://stackoverflow.com/users/165783/james @@ -62,8 +61,7 @@ class ScrollingViewWithBottomNavigationBehavior(context: Context, attrs: Attribu navigationBar: BottomNavigationView, coordinatorLayout: CoordinatorLayout ): Boolean { - val readerBottomAppBar: BottomAppBar? = - fragmentContainer.findViewById(org.kiwix.kiwixmobile.core.R.id.bottom_toolbar) + val readerBottomAppBar: BottomAppBar? = null if (readerBottomAppBar != null) { val newBottomMargin = calculateNewBottomMargin(navigationBar, coordinatorLayout) if (newBottomMargin != bottomMargin) { diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderFragment.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderFragment.kt index e4e2fc251..04c055a2e 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderFragment.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderFragment.kt @@ -72,13 +72,11 @@ import androidx.core.content.ContextCompat import androidx.core.content.edit import androidx.core.net.toUri import androidx.core.view.GravityCompat -import androidx.core.view.isVisible import androidx.drawerlayout.widget.DrawerLayout import androidx.lifecycle.Observer import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import com.google.android.material.bottomappbar.BottomAppBar import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.navigation.NavigationView import kotlinx.coroutines.CoroutineDispatcher @@ -1972,9 +1970,7 @@ abstract class CoreReaderFragment : var bottomMargin = requireActivity().resources.getDimensionPixelSize( R.dimen.donation_popup_bottom_margin ) - val bottomAppBar = requireActivity() - .findViewById(R.id.bottom_toolbar) - if (bottomAppBar.isVisible) { + if (readerScreenState.value.shouldShowBottomAppBar) { // if bottomAppBar is visible then add the height of the bottomAppBar. bottomMargin += requireActivity().resources.getDimensionPixelSize( diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ComposeDimens.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ComposeDimens.kt index 6825b2842..ce8365f9c 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ComposeDimens.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/utils/ComposeDimens.kt @@ -184,7 +184,7 @@ object ComposeDimens { // Reader screen dimens val READER_BOTTOM_APP_BAR_LAYOUT_HEIGHT = 40.dp val READER_BOTTOM_APP_BAR_BUTTON_ICON_SIZE = 30.dp - const val TTS_BUTTONS_CONTROL_ALPHA = 0.6f + const val TTS_BUTTONS_CONTROL_ALPHA = 0.9f val CLOSE_ALL_TAB_BUTTON_BOTTOM_PADDING = 24.dp val TAB_SWITCHER_TEXT_SIZE = 12.sp const val TAB_SWITCHER_ICON_CORNER_RADIUS = 10 @@ -193,6 +193,4 @@ object ComposeDimens { val BACK_TO_TOP_BUTTON_BOTTOM_MARGIN = 80.dp const val READER_BOTTOM_APP_BAR_DISABLE_BUTTON_ALPHA = 0.38f val SEARCH_PLACEHOLDER_TEXT_SIZE = 12.sp - val COMPOSE_TOOLBAR_DEFAULT_HEIGHT = 64.dp - val COMPOSE_BOTTOM_APP_BAR_DEFAULT_HEIGHT = 80.dp } diff --git a/core/src/main/res/layout/bottom_toolbar.xml b/core/src/main/res/layout/bottom_toolbar.xml deleted file mode 100644 index 13155a69b..000000000 --- a/core/src/main/res/layout/bottom_toolbar.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt index d44009ea1..eb2942757 100644 --- a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt +++ b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchFragmentTestForCustomApp.kt @@ -54,10 +54,8 @@ import org.kiwix.kiwixmobile.core.search.viewmodel.Action import org.kiwix.kiwixmobile.core.utils.LanguageUtils import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil import org.kiwix.kiwixmobile.core.utils.TestingUtils.COMPOSE_TEST_RULE_ORDER -import org.kiwix.kiwixmobile.core.utils.TestingUtils.RETRY_RULE_ORDER import org.kiwix.kiwixmobile.custom.main.CustomMainActivity import org.kiwix.kiwixmobile.custom.main.CustomReaderFragment -import org.kiwix.kiwixmobile.custom.testutils.RetryRule import org.kiwix.kiwixmobile.custom.testutils.TestUtils import org.kiwix.kiwixmobile.custom.testutils.TestUtils.closeSystemDialogs import org.kiwix.kiwixmobile.custom.testutils.TestUtils.isSystemUINotRespondingDialogVisible @@ -83,9 +81,9 @@ class SearchFragmentTestForCustomApp { InstrumentationRegistry.getInstrumentation().targetContext.applicationContext } - @Rule(order = RETRY_RULE_ORDER) - @JvmField - var retryRule = RetryRule() + // @Rule(order = RETRY_RULE_ORDER) + // @JvmField + // var retryRule = RetryRule() @get:Rule(order = COMPOSE_TEST_RULE_ORDER) val composeTestRule = createComposeRule() @@ -295,7 +293,7 @@ class SearchFragmentTestForCustomApp { openZimFileInReader(zimFile = downloadingZimFile) search { // click on home button to load the main page of ZIM file. - clickOnHomeButton() + clickOnHomeButton(composeTestRule, customMainActivity) // click on an article to load the other page. clickOnAFoolForYouArticle() assertAFoolForYouArticleLoaded() diff --git a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchRobot.kt b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchRobot.kt index c48edb916..46f23ef4e 100644 --- a/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchRobot.kt +++ b/custom/src/androidTest/java/org/kiwix/kiwixmobile/custom/search/SearchRobot.kt @@ -23,16 +23,14 @@ import androidx.compose.ui.test.assert import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.ComposeContentTestRule import androidx.compose.ui.test.onAllNodesWithTag +import androidx.compose.ui.test.onNodeWithContentDescription import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performTextClearance import androidx.compose.ui.test.performTextInput import androidx.core.view.GravityCompat -import androidx.test.espresso.Espresso import androidx.test.espresso.Espresso.onView -import androidx.test.espresso.action.ViewActions import androidx.test.espresso.action.ViewActions.click -import androidx.test.espresso.matcher.ViewMatchers import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.espresso.web.assertion.WebViewAssertions.webMatches import androidx.test.espresso.web.sugar.Web @@ -51,6 +49,7 @@ import org.kiwix.kiwixmobile.core.page.SEARCH_ICON_TESTING_TAG import org.kiwix.kiwixmobile.core.search.SEARCH_FIELD_TESTING_TAG import org.kiwix.kiwixmobile.core.search.SEARCH_ITEM_TESTING_TAG import org.kiwix.kiwixmobile.custom.R.id +import org.kiwix.kiwixmobile.custom.main.CustomMainActivity import org.kiwix.kiwixmobile.custom.testutils.TestUtils import org.kiwix.kiwixmobile.custom.testutils.TestUtils.TEST_PAUSE_MS import org.kiwix.kiwixmobile.custom.testutils.TestUtils.testFlakyView @@ -147,11 +146,14 @@ class SearchRobot { }) } - fun clickOnHomeButton() { - testFlakyView({ - Espresso.onView(ViewMatchers.withId(R.id.bottom_toolbar_home)) - .perform(ViewActions.click()) - }) + fun clickOnHomeButton( + composeTestRule: ComposeContentTestRule, + customMainActivity: CustomMainActivity + ) { + composeTestRule.apply { + onNodeWithContentDescription(customMainActivity.getString(R.string.menu_home)) + .performClick() + } } fun clickOnAFoolForYouArticle() {