mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-11 00:23:58 -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 versionName: String,
|
||||||
val disableSideBar: Boolean = false,
|
val disableSideBar: Boolean = false,
|
||||||
val disableTabs: Boolean = false,
|
val disableTabs: Boolean = false,
|
||||||
val disableReadAloud: Boolean = false
|
val disableReadAloud: Boolean = false,
|
||||||
|
val disableTitle: Boolean = false
|
||||||
) {
|
) {
|
||||||
constructor(name: String, parsedJson: JSONObject) : this(
|
constructor(name: String, parsedJson: JSONObject) : this(
|
||||||
name,
|
name,
|
||||||
@ -44,7 +45,8 @@ data class CustomApp(
|
|||||||
readVersionOrInfer(parsedJson),
|
readVersionOrInfer(parsedJson),
|
||||||
parsedJson.getAndCast("disable_sidebar") ?: false,
|
parsedJson.getAndCast("disable_sidebar") ?: false,
|
||||||
parsedJson.getAndCast("disable_tabs") ?: 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()
|
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_SIDEBAR", "${customApp.disableSideBar}")
|
||||||
buildConfigField("Boolean", "DISABLE_TABS", "${customApp.disableTabs}")
|
buildConfigField("Boolean", "DISABLE_TABS", "${customApp.disableTabs}")
|
||||||
buildConfigField("Boolean", "DISABLE_READ_ALOUD", "${customApp.disableReadAloud}")
|
buildConfigField("Boolean", "DISABLE_READ_ALOUD", "${customApp.disableReadAloud}")
|
||||||
|
buildConfigField("Boolean", "DISABLE_TITLE", "${customApp.disableTitle}")
|
||||||
configureStrings(customApp.displayName)
|
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) {
|
if (isAdded) {
|
||||||
actionBar?.title = getValidTitle(zimReaderContainer?.zimFileTitle)
|
actionBar?.title = getValidTitle(zimReaderContainer?.zimFileTitle)
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ class CustomReaderFragment : CoreReaderFragment() {
|
|||||||
var dialogShower: DialogShower? = null
|
var dialogShower: DialogShower? = null
|
||||||
private var permissionRequiredDialog: Dialog? = null
|
private var permissionRequiredDialog: Dialog? = null
|
||||||
private var appSettingsLaunched = false
|
private var appSettingsLaunched = false
|
||||||
|
@Suppress("NestedBlockDepth")
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
if (enforcedLanguage()) {
|
if (enforcedLanguage()) {
|
||||||
@ -71,7 +72,14 @@ class CustomReaderFragment : CoreReaderFragment() {
|
|||||||
}
|
}
|
||||||
with(activity as AppCompatActivity) {
|
with(activity as AppCompatActivity) {
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
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()
|
loadPageFromNavigationArguments()
|
||||||
}
|
}
|
||||||
@ -239,6 +247,23 @@ class CustomReaderFragment : CoreReaderFragment() {
|
|||||||
super.configureWebViewSelectionHandler(menu)
|
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() {
|
override fun createNewTab() {
|
||||||
newMainPageTab()
|
newMainPageTab()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user