mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-09 15:27:55 -04:00
Introduced the disable title option for custom apps.
This commit is contained in:
parent
952b539fa8
commit
f46f2f324b
@ -34,7 +34,8 @@ data class CustomApp(
|
||||
val versionName: String,
|
||||
val disableSideBar: Boolean = false,
|
||||
val disableTabs: Boolean = false,
|
||||
val disableReadAloud: Boolean = false
|
||||
val disableReadAloud: Boolean = false,
|
||||
val disableTitle: Boolean = false
|
||||
) {
|
||||
constructor(name: String, parsedJson: JSONObject) : this(
|
||||
name,
|
||||
@ -44,7 +45,8 @@ data class CustomApp(
|
||||
readVersionOrInfer(parsedJson),
|
||||
parsedJson.getAndCast("disable_sidebar") ?: false,
|
||||
parsedJson.getAndCast("disable_tabs") ?: false,
|
||||
parsedJson.getAndCast("disable_read_aloud") ?: false
|
||||
parsedJson.getAndCast("disable_read_aloud") ?: false,
|
||||
parsedJson.getAndCast("disable_title") ?: false
|
||||
)
|
||||
|
||||
val versionCode: Int = formatCurrentDate("YYDDD0").toInt()
|
||||
|
@ -51,6 +51,7 @@ fun ProductFlavors.create(customApps: List<CustomApp>) {
|
||||
buildConfigField("Boolean", "DISABLE_SIDEBAR", "${customApp.disableSideBar}")
|
||||
buildConfigField("Boolean", "DISABLE_TABS", "${customApp.disableTabs}")
|
||||
buildConfigField("Boolean", "DISABLE_READ_ALOUD", "${customApp.disableReadAloud}")
|
||||
buildConfigField("Boolean", "DISABLE_TITLE", "${customApp.disableTitle}")
|
||||
configureStrings(customApp.displayName)
|
||||
}
|
||||
}
|
||||
|
@ -938,7 +938,15 @@ abstract class CoreReaderFragment :
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTitle() {
|
||||
/**
|
||||
* Sets the title for toolbar, controlling the title of toolbar.
|
||||
* Subclasses like CustomReaderFragment override this method to provide custom
|
||||
* behavior, such as hiding the title when configured not to show it.
|
||||
*
|
||||
* WARNING: If modifying this method, ensure thorough testing with custom apps
|
||||
* to verify proper functionality.
|
||||
*/
|
||||
open fun updateTitle() {
|
||||
if (isAdded) {
|
||||
actionBar?.title = getValidTitle(zimReaderContainer?.zimFileTitle)
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ class CustomReaderFragment : CoreReaderFragment() {
|
||||
var dialogShower: DialogShower? = null
|
||||
private var permissionRequiredDialog: Dialog? = null
|
||||
private var appSettingsLaunched = false
|
||||
@Suppress("NestedBlockDepth")
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
if (enforcedLanguage()) {
|
||||
@ -71,7 +72,14 @@ class CustomReaderFragment : CoreReaderFragment() {
|
||||
}
|
||||
with(activity as AppCompatActivity) {
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
toolbar?.let { setupDrawerToggle(it) }
|
||||
toolbar?.let {
|
||||
setupDrawerToggle(it)
|
||||
if (BuildConfig.DISABLE_TITLE) {
|
||||
// if the title is disable then set the app logo to hamburger icon,
|
||||
// see https://github.com/kiwix/kiwix-android/issues/3528#issuecomment-1814905330
|
||||
it.setNavigationIcon(R.mipmap.ic_launcher)
|
||||
}
|
||||
}
|
||||
}
|
||||
loadPageFromNavigationArguments()
|
||||
}
|
||||
@ -239,6 +247,23 @@ class CustomReaderFragment : CoreReaderFragment() {
|
||||
super.configureWebViewSelectionHandler(menu)
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the method to configure the title of toolbar. When the "setting title" is disabled
|
||||
* in a custom app, this function set the empty toolbar title.
|
||||
*/
|
||||
override fun updateTitle() {
|
||||
if (BuildConfig.DISABLE_TITLE) {
|
||||
// Set an empty title for the toolbar because we are handling the toolbar click on behalf of this title.
|
||||
// Since we have increased the zone for triggering search suggestions (see https://github.com/kiwix/kiwix-android/pull/3566),
|
||||
// we need to set this title for handling the toolbar click,
|
||||
// even if it is empty. If we do not set up this title,
|
||||
// the search screen will open if the user clicks on the toolbar from the tabs screen.
|
||||
actionBar?.title = " "
|
||||
} else {
|
||||
super.updateTitle()
|
||||
}
|
||||
}
|
||||
|
||||
override fun createNewTab() {
|
||||
newMainPageTab()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user