From 913c81e525dd3a764d8d6251202f5cf326fdb31d Mon Sep 17 00:00:00 2001 From: CookieGamesOfficial Date: Sat, 22 Jan 2022 19:50:57 +0100 Subject: [PATCH] Bottom navbar items now toggle drawers instead of just opening them --- .../smartcookie/browser/activity/BrowserActivity.kt | 13 +++++++++++-- .../com/cookiegames/smartcookie/popup/PopUpClass.kt | 1 + .../java/com/cookiegames/smartcookie/utils/Utils.kt | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/cookiegames/smartcookie/browser/activity/BrowserActivity.kt b/app/src/main/java/com/cookiegames/smartcookie/browser/activity/BrowserActivity.kt index 95e974c8..604559b4 100644 --- a/app/src/main/java/com/cookiegames/smartcookie/browser/activity/BrowserActivity.kt +++ b/app/src/main/java/com/cookiegames/smartcookie/browser/activity/BrowserActivity.kt @@ -812,12 +812,12 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr when(item.itemId) { R.id.tabs -> { drawer_layout.closeDrawer(getBookmarkDrawer()) - drawer_layout.openDrawer(getTabDrawer()) + toggleDrawer(drawer_layout, getTabDrawer()) true } R.id.bookmarks -> { drawer_layout.closeDrawer(getTabDrawer()) - drawer_layout.openDrawer(getBookmarkDrawer()) + toggleDrawer(drawer_layout, getBookmarkDrawer()) true } R.id.forward -> { @@ -838,6 +838,15 @@ abstract class BrowserActivity : ThemableBrowserActivity(), BrowserView, UIContr } } + private fun toggleDrawer(layout: DrawerLayout, drawer: View) { + if(layout.isDrawerOpen(drawer)){ + layout.closeDrawer(drawer) + } + else{ + layout.openDrawer(drawer) + } + } + public override fun onWindowVisibleToUserAfterResume() { super.onWindowVisibleToUserAfterResume() toolbar_layout.translationY = 0f diff --git a/app/src/main/java/com/cookiegames/smartcookie/popup/PopUpClass.kt b/app/src/main/java/com/cookiegames/smartcookie/popup/PopUpClass.kt index 1c5fd750..76b3dfcf 100644 --- a/app/src/main/java/com/cookiegames/smartcookie/popup/PopUpClass.kt +++ b/app/src/main/java/com/cookiegames/smartcookie/popup/PopUpClass.kt @@ -103,6 +103,7 @@ class PopUpClass { when(userPreferences.useTheme){ AppTheme.DARK -> popupView.findViewById(R.id.transparent_container).setBackgroundResource(R.drawable.toolbar_dark) AppTheme.BLACK -> popupView.findViewById(R.id.transparent_container).setBackgroundResource(R.drawable.toolbar_black) + else -> {} } } diff --git a/app/src/main/java/com/cookiegames/smartcookie/utils/Utils.kt b/app/src/main/java/com/cookiegames/smartcookie/utils/Utils.kt index e4808840..66ac9b8d 100644 --- a/app/src/main/java/com/cookiegames/smartcookie/utils/Utils.kt +++ b/app/src/main/java/com/cookiegames/smartcookie/utils/Utils.kt @@ -176,6 +176,7 @@ object Utils { var reloadButtonCode = "" when(showButton){ false -> reloadButtonCode = "" + else -> {} } return "" + @@ -209,6 +210,7 @@ object Utils { val goBackButton = "" when(showProceedButton){ false -> proceedButton = "" + else -> {} } return "" +