From 38729f4fe1592a49f86d46f0ac44d41ad47f9944 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Tue, 27 Oct 2026 13:21:31 +0530 Subject: [PATCH 1/2] Fixed: Content drawer dialog was showing in branded apps when it is disabled. * Now, we are only showing this TOC drawer hint if the TOC sidebar is enabled for branded apps. * Added necessary comments for devs. --- .../custom/main/BrandedReaderViewModel.kt | 12 ++++++++++++ .../core/main/reader/CoreReaderViewModel.kt | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/branded/src/main/java/org/kiwix/kiwixmobile/custom/main/BrandedReaderViewModel.kt b/branded/src/main/java/org/kiwix/kiwixmobile/custom/main/BrandedReaderViewModel.kt index 527a4a759e..3c2bfdca90 100644 --- a/branded/src/main/java/org/kiwix/kiwixmobile/custom/main/BrandedReaderViewModel.kt +++ b/branded/src/main/java/org/kiwix/kiwixmobile/custom/main/BrandedReaderViewModel.kt @@ -482,4 +482,16 @@ class BrandedReaderViewModel @Inject constructor( ) } } + + /** + * Overrides this method to configure the showing the TOC sidebar hint dialog. If a branded app + * has the TOC sidebar feature disabled, this method prevents the hint dialog from being shown + * when the user navigates to a new URL in the WebView. + * This ensures that users of branded apps do not see hints for features + * that are not available to them. + */ + override fun webViewUrlLoading() { + if (!isTocSidebarEnabled()) return + super.webViewUrlLoading() + } } diff --git a/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderViewModel.kt b/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderViewModel.kt index efc9bcca9a..c0280883e5 100644 --- a/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderViewModel.kt +++ b/core/src/main/java/org/kiwix/kiwixmobile/core/main/reader/CoreReaderViewModel.kt @@ -1040,6 +1040,15 @@ abstract class CoreReaderViewModel( findInPageManager.stop() } + /** + * Show the TOC sidebar hint on the first run of the app, unless it's a debug build. + * This is to guide users to the contents drawer feature. + * Subclasses like BrandedViewModel override this method to provide custom + * behavior, such as not showing this dialog when it is disabled in branded app. + * + * WARNING: If modifying this method, ensure thorough testing with branded apps + * to verify proper functionality. + */ override fun webViewUrlLoading() { viewModelScope.launch { if (kiwixDataStore.isFirstRun.first() && !kiwixDataStore.isDebugBuild.first()) { From 13e69e8d30f954e77e19c449611c85923628e108 Mon Sep 17 00:00:00 2001 From: MohitMaliFtechiz Date: Tue, 27 Oct 2026 16:27:35 +0530 Subject: [PATCH 2/2] Setting `setIsFirstRun` to true to avoid the future conditions. --- .../kiwixmobile/custom/main/BrandedReaderViewModel.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/branded/src/main/java/org/kiwix/kiwixmobile/custom/main/BrandedReaderViewModel.kt b/branded/src/main/java/org/kiwix/kiwixmobile/custom/main/BrandedReaderViewModel.kt index 3c2bfdca90..205efdab94 100644 --- a/branded/src/main/java/org/kiwix/kiwixmobile/custom/main/BrandedReaderViewModel.kt +++ b/branded/src/main/java/org/kiwix/kiwixmobile/custom/main/BrandedReaderViewModel.kt @@ -29,12 +29,14 @@ import androidx.compose.material.icons.filled.Menu import androidx.compose.ui.graphics.Color import androidx.core.net.toUri import androidx.core.os.LocaleListCompat +import androidx.lifecycle.viewModelScope import androidx.navigation.NavOptions import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.MainCoroutineDispatcher import kotlinx.coroutines.delay import kotlinx.coroutines.flow.first +import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.kiwix.kiwixmobile.core.R.string import org.kiwix.kiwixmobile.core.di.IoDispatcher @@ -491,7 +493,12 @@ class BrandedReaderViewModel @Inject constructor( * that are not available to them. */ override fun webViewUrlLoading() { - if (!isTocSidebarEnabled()) return + if (!isTocSidebarEnabled()) { + viewModelScope.launch { + kiwixDataStore.setIsFirstRun(false) + } + return + } super.webViewUrlLoading() } }