Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -482,4 +484,21 @@ 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()) {
viewModelScope.launch {
kiwixDataStore.setIsFirstRun(false)
}
return
}
super.webViewUrlLoading()
Comment thread
harshsomankar123-tech marked this conversation as resolved.
Resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Loading