mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 14:52:13 -04:00
Fixed: The server was not starting automatically after granting notification/storage permissions, whereas it previously started automatically with the XML-based design.
* Fixed: The link was not clickable and was only displaying as plain text in the TextView. * Fixed: The TagView UI was not adjusting properly when all tags were displayed. Fixed: The TagView was not positioned at the bottom and had an unintended bottom margin. * Fixed: The fonts and sizes of the date, article size, and description were not aligned with our current XML design. * Fixed: The ZIM files list was not updating on the UI when selecting/deselecting items. * Removed the `activity_zim_host.xml` file from project since it is unused now.
This commit is contained in:
parent
436a001eb9
commit
6e370a1e74
@ -45,13 +45,12 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
import org.kiwix.kiwixmobile.core.extensions.faviconToPainter
|
import org.kiwix.kiwixmobile.core.extensions.faviconToPainter
|
||||||
import org.kiwix.kiwixmobile.core.ui.theme.KiwixTheme
|
import org.kiwix.kiwixmobile.core.ui.theme.KiwixTheme
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.BOOK_DESCRIPTION_LETTER_SPACING
|
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.BOOK_ICON_SIZE
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.BOOK_ICON_SIZE
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.EIGHT_DP
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.EIGHT_DP
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.FIVE_DP
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.FIVE_DP
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.FOURTEEN_SP
|
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.FOUR_DP
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.FOUR_DP
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SIXTEEN_DP
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SIXTEEN_DP
|
||||||
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.TWO_DP
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.KiloByte
|
import org.kiwix.kiwixmobile.core.zim_manager.KiloByte
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.ArticleCount
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.ArticleCount
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode
|
||||||
@ -65,7 +64,6 @@ fun BookItem(
|
|||||||
onLongClick: ((BookOnDisk) -> Unit)? = null,
|
onLongClick: ((BookOnDisk) -> Unit)? = null,
|
||||||
onMultiSelect: ((BookOnDisk) -> Unit)? = null,
|
onMultiSelect: ((BookOnDisk) -> Unit)? = null,
|
||||||
selectionMode: SelectionMode = SelectionMode.NORMAL,
|
selectionMode: SelectionMode = SelectionMode.NORMAL,
|
||||||
onCheckedChange: (Boolean) -> Unit = {}
|
|
||||||
) {
|
) {
|
||||||
KiwixTheme {
|
KiwixTheme {
|
||||||
Card(
|
Card(
|
||||||
@ -89,7 +87,7 @@ fun BookItem(
|
|||||||
elevation = CardDefaults.elevatedCardElevation(),
|
elevation = CardDefaults.elevatedCardElevation(),
|
||||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainer)
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainer)
|
||||||
) {
|
) {
|
||||||
BookContent(bookOnDisk, selectionMode, onCheckedChange)
|
BookContent(bookOnDisk, selectionMode, onMultiSelect, onClick)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,16 +96,17 @@ fun BookItem(
|
|||||||
private fun BookContent(
|
private fun BookContent(
|
||||||
bookOnDisk: BookOnDisk,
|
bookOnDisk: BookOnDisk,
|
||||||
selectionMode: SelectionMode,
|
selectionMode: SelectionMode,
|
||||||
onCheckedChange: (Boolean) -> Unit
|
onMultiSelect: ((BookOnDisk) -> Unit)?,
|
||||||
|
onClick: ((BookOnDisk) -> Unit)?,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(SIXTEEN_DP)
|
.padding(top = SIXTEEN_DP, start = SIXTEEN_DP)
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
if (selectionMode == SelectionMode.MULTI) {
|
if (selectionMode == SelectionMode.MULTI) {
|
||||||
BookCheckbox(bookOnDisk, onCheckedChange)
|
BookCheckbox(bookOnDisk, selectionMode, onMultiSelect, onClick)
|
||||||
}
|
}
|
||||||
BookIcon(bookOnDisk.book.faviconToPainter())
|
BookIcon(bookOnDisk.book.faviconToPainter())
|
||||||
BookDetails(Modifier.weight(1f), bookOnDisk)
|
BookDetails(Modifier.weight(1f), bookOnDisk)
|
||||||
@ -115,10 +114,20 @@ private fun BookContent(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun BookCheckbox(bookOnDisk: BookOnDisk, onCheckedChange: (Boolean) -> Unit) {
|
private fun BookCheckbox(
|
||||||
|
bookOnDisk: BookOnDisk,
|
||||||
|
selectionMode: SelectionMode,
|
||||||
|
onMultiSelect: ((BookOnDisk) -> Unit)?,
|
||||||
|
onClick: ((BookOnDisk) -> Unit)?
|
||||||
|
) {
|
||||||
Checkbox(
|
Checkbox(
|
||||||
checked = bookOnDisk.isSelected,
|
checked = bookOnDisk.isSelected,
|
||||||
onCheckedChange = onCheckedChange
|
onCheckedChange = {
|
||||||
|
when (selectionMode) {
|
||||||
|
SelectionMode.MULTI -> onMultiSelect?.invoke(bookOnDisk)
|
||||||
|
SelectionMode.NORMAL -> onClick?.invoke(bookOnDisk)
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,38 +147,36 @@ private fun BookDetails(modifier: Modifier, bookOnDisk: BookOnDisk) {
|
|||||||
Column(modifier = modifier.padding(start = SIXTEEN_DP)) {
|
Column(modifier = modifier.padding(start = SIXTEEN_DP)) {
|
||||||
Text(
|
Text(
|
||||||
text = bookOnDisk.book.title,
|
text = bookOnDisk.book.title,
|
||||||
style = MaterialTheme.typography.titleMedium
|
style = MaterialTheme.typography.titleSmall
|
||||||
)
|
)
|
||||||
|
Spacer(modifier = Modifier.height(TWO_DP))
|
||||||
Text(
|
Text(
|
||||||
text = bookOnDisk.book.description.orEmpty(),
|
text = bookOnDisk.book.description.orEmpty(),
|
||||||
style = MaterialTheme.typography.bodySmall.copy(
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
fontSize = FOURTEEN_SP,
|
|
||||||
letterSpacing = BOOK_DESCRIPTION_LETTER_SPACING
|
|
||||||
),
|
|
||||||
maxLines = 2,
|
maxLines = 2,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
color = MaterialTheme.colorScheme.onSecondary
|
color = MaterialTheme.colorScheme.onSecondary
|
||||||
)
|
)
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = Modifier.padding(top = FOUR_DP)
|
modifier = Modifier.padding(top = FIVE_DP)
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = bookOnDisk.book.date,
|
text = bookOnDisk.book.date,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onTertiary
|
color = MaterialTheme.colorScheme.onTertiary
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(EIGHT_DP))
|
Spacer(modifier = Modifier.width(EIGHT_DP))
|
||||||
Text(
|
Text(
|
||||||
text = KiloByte(bookOnDisk.book.size).humanReadable,
|
text = KiloByte(bookOnDisk.book.size).humanReadable,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onTertiary
|
color = MaterialTheme.colorScheme.onTertiary
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.width(EIGHT_DP))
|
Spacer(modifier = Modifier.width(EIGHT_DP))
|
||||||
Text(
|
Text(
|
||||||
text = ArticleCount(bookOnDisk.book.articleCount.orEmpty())
|
text = ArticleCount(bookOnDisk.book.articleCount.orEmpty())
|
||||||
.toHumanReadable(LocalContext.current),
|
.toHumanReadable(LocalContext.current),
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
color = MaterialTheme.colorScheme.onTertiary
|
color = MaterialTheme.colorScheme.onTertiary
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
package org.kiwix.kiwixmobile.ui
|
package org.kiwix.kiwixmobile.ui
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.ExperimentalLayoutApi
|
||||||
|
import androidx.compose.foundation.layout.FlowRow
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.SuggestionChip
|
import androidx.compose.material3.SuggestionChip
|
||||||
import androidx.compose.material3.SuggestionChipDefaults
|
import androidx.compose.material3.SuggestionChipDefaults
|
||||||
@ -36,9 +37,10 @@ import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag.Companion.YesNoValueTag.P
|
|||||||
import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag.Companion.YesNoValueTag.VideoTag
|
import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag.Companion.YesNoValueTag.VideoTag
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag.TagValue.YES
|
import org.kiwix.kiwixmobile.core.zim_manager.KiwixTag.TagValue.YES
|
||||||
|
|
||||||
|
@OptIn(ExperimentalLayoutApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun TagsView(tags: List<KiwixTag>, modifier: Modifier = Modifier) {
|
fun TagsView(tags: List<KiwixTag>, modifier: Modifier = Modifier) {
|
||||||
Row(
|
FlowRow(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
horizontalArrangement = Arrangement.spacedBy(EIGHT_DP)
|
horizontalArrangement = Arrangement.spacedBy(EIGHT_DP)
|
||||||
) {
|
) {
|
||||||
|
@ -71,7 +71,6 @@ import org.kiwix.kiwixmobile.core.utils.files.Log
|
|||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.SelectionMode
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
|
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
|
||||||
import org.kiwix.kiwixmobile.databinding.ActivityZimHostBinding
|
|
||||||
import org.kiwix.kiwixmobile.main.KiwixMainActivity
|
import org.kiwix.kiwixmobile.main.KiwixMainActivity
|
||||||
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService
|
||||||
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.Companion.ACTION_CHECK_IP_ADDRESS
|
import org.kiwix.kiwixmobile.webserver.wifi_hotspot.HotspotService.Companion.ACTION_CHECK_IP_ADDRESS
|
||||||
@ -105,7 +104,6 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
private var ip: String? = null
|
private var ip: String? = null
|
||||||
private lateinit var serviceConnection: ServiceConnection
|
private lateinit var serviceConnection: ServiceConnection
|
||||||
private var dialog: Dialog? = null
|
private var dialog: Dialog? = null
|
||||||
private var activityZimHostBinding: ActivityZimHostBinding? = null
|
|
||||||
private var isHotspotServiceRunning = false
|
private var isHotspotServiceRunning = false
|
||||||
private var serverIpText = mutableStateOf("")
|
private var serverIpText = mutableStateOf("")
|
||||||
private var shareIconItem = mutableStateOf(false to {})
|
private var shareIconItem = mutableStateOf(false to {})
|
||||||
@ -140,7 +138,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
ActivityResultContracts.RequestPermission()
|
ActivityResultContracts.RequestPermission()
|
||||||
) { isGranted ->
|
) { isGranted ->
|
||||||
if (isGranted) {
|
if (isGranted) {
|
||||||
activityZimHostBinding?.startServerButton?.performClick()
|
startServerButtonClick()
|
||||||
} else {
|
} else {
|
||||||
if (!ActivityCompat.shouldShowRequestPermissionRationale(
|
if (!ActivityCompat.shouldShowRequestPermissionRationale(
|
||||||
requireActivity(),
|
requireActivity(),
|
||||||
@ -164,7 +162,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
Map.Entry<String, @kotlin.jvm.JvmSuppressWildcards Boolean>::value
|
Map.Entry<String, @kotlin.jvm.JvmSuppressWildcards Boolean>::value
|
||||||
)
|
)
|
||||||
if (isGranted) {
|
if (isGranted) {
|
||||||
activityZimHostBinding?.startServerButton?.performClick()
|
startServerButtonClick()
|
||||||
} else {
|
} else {
|
||||||
if (!ActivityCompat.shouldShowRequestPermissionRationale(
|
if (!ActivityCompat.shouldShowRequestPermissionRationale(
|
||||||
requireActivity(),
|
requireActivity(),
|
||||||
@ -192,7 +190,7 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
startServerButtonItem = startServerButtonItem.value,
|
startServerButtonItem = startServerButtonItem.value,
|
||||||
selectionMode = SelectionMode.MULTI,
|
selectionMode = SelectionMode.MULTI,
|
||||||
onMultiSelect = { select(it) },
|
onMultiSelect = { select(it) },
|
||||||
booksList = booksList.value,
|
booksList = booksList.value
|
||||||
) {
|
) {
|
||||||
NavigationIcon(
|
NavigationIcon(
|
||||||
onClick = { activity?.onBackPressedDispatcher?.onBackPressed() }
|
onClick = { activity?.onBackPressedDispatcher?.onBackPressed() }
|
||||||
@ -207,17 +205,6 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
//
|
|
||||||
// bookDelegate =
|
|
||||||
// BookOnDiskDelegate.BookDelegate(sharedPreferenceUtil, multiSelectAction = ::select)
|
|
||||||
// bookDelegate.selectionMode = SelectionMode.MULTI
|
|
||||||
// booksAdapter =
|
|
||||||
// BooksOnDiskAdapter(
|
|
||||||
// bookDelegate,
|
|
||||||
// BookOnDiskDelegate.LanguageDelegate
|
|
||||||
// )
|
|
||||||
//
|
|
||||||
// activityZimHostBinding?.recyclerViewZimHost?.adapter = booksAdapter
|
|
||||||
presenter.attachView(this)
|
presenter.attachView(this)
|
||||||
|
|
||||||
serviceConnection =
|
serviceConnection =
|
||||||
@ -324,6 +311,10 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
}
|
}
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
// Force recomposition by first setting an empty list before assigning the updated list.
|
||||||
|
// This is necessary because modifying an object's property doesn't trigger recomposition,
|
||||||
|
// as Compose still considers the list unchanged.
|
||||||
|
booksList.value = emptyList()
|
||||||
booksList.value = tempBooksList
|
booksList.value = tempBooksList
|
||||||
saveHostedBooks(tempBooksList)
|
saveHostedBooks(tempBooksList)
|
||||||
if (ServerUtils.isServerStarted) {
|
if (ServerUtils.isServerStarted) {
|
||||||
@ -380,10 +371,6 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
|
|
||||||
private fun layoutServerStarted() {
|
private fun layoutServerStarted() {
|
||||||
serverIpText.value = getString(R.string.server_started_message, ip)
|
serverIpText.value = getString(R.string.server_started_message, ip)
|
||||||
// activityZimHostBinding?.serverTextView?.apply {
|
|
||||||
// text = getString(R.string.server_started_message, ip)
|
|
||||||
// movementMethod = LinkMovementMethod.getInstance()
|
|
||||||
// }
|
|
||||||
configureUrlSharingIcon(true)
|
configureUrlSharingIcon(true)
|
||||||
configureQrIcon(true)
|
configureQrIcon(true)
|
||||||
startServerButtonItem.value =
|
startServerButtonItem.value =
|
||||||
@ -419,10 +406,8 @@ class ZimHostFragment : BaseFragment(), ZimHostCallbacks, ZimHostContract.View {
|
|||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
super.onDestroyView()
|
super.onDestroyView()
|
||||||
activityZimHostBinding?.recyclerViewZimHost?.adapter = null
|
|
||||||
unRegisterHotspotService()
|
unRegisterHotspotService()
|
||||||
presenter.detachView()
|
presenter.detachView()
|
||||||
activityZimHostBinding = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun unRegisterHotspotService() {
|
private fun unRegisterHotspotService() {
|
||||||
|
@ -18,6 +18,11 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.webserver
|
package org.kiwix.kiwixmobile.webserver
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.text.method.LinkMovementMethod
|
||||||
|
import android.text.util.Linkify
|
||||||
|
import android.view.Gravity
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@ -31,16 +36,17 @@ import androidx.compose.foundation.layout.widthIn
|
|||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.material3.minimumInteractiveComponentSize
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.viewinterop.AndroidView
|
||||||
|
import androidx.core.text.util.LinkifyCompat
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
import org.kiwix.kiwixmobile.core.ui.components.KiwixAppBar
|
import org.kiwix.kiwixmobile.core.ui.components.KiwixAppBar
|
||||||
import org.kiwix.kiwixmobile.core.ui.components.KiwixButton
|
import org.kiwix.kiwixmobile.core.ui.components.KiwixButton
|
||||||
@ -82,11 +88,18 @@ fun ZimHostScreen(
|
|||||||
modifier = Modifier.fillMaxWidth().padding(horizontal = SIXTEEN_DP),
|
modifier = Modifier.fillMaxWidth().padding(horizontal = SIXTEEN_DP),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
ServerIpText(serverIpText, Modifier.weight(1f))
|
ServerIpText(serverIpText, Modifier.weight(1f), LocalContext.current)
|
||||||
ShareIcon(shareIconItem)
|
ShareIcon(shareIconItem)
|
||||||
}
|
}
|
||||||
Box(modifier = Modifier.weight(1f)) {
|
Box(modifier = Modifier.weight(1f)) {
|
||||||
BookItemList(booksList, selectionMode, qrImageItem, onClick, onLongClick, onMultiSelect)
|
BookItemList(
|
||||||
|
booksList,
|
||||||
|
selectionMode,
|
||||||
|
qrImageItem,
|
||||||
|
onClick,
|
||||||
|
onLongClick,
|
||||||
|
onMultiSelect
|
||||||
|
)
|
||||||
}
|
}
|
||||||
KiwixButton(
|
KiwixButton(
|
||||||
startServerButtonItem.first,
|
startServerButtonItem.first,
|
||||||
@ -99,20 +112,28 @@ fun ZimHostScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("MagicNumber")
|
||||||
@Composable
|
@Composable
|
||||||
fun ServerIpText(
|
private fun ServerIpText(
|
||||||
serverIpText: String,
|
serverIpText: String,
|
||||||
modifier: Modifier
|
modifier: Modifier,
|
||||||
|
context: Context
|
||||||
) {
|
) {
|
||||||
Text(
|
val serverIpTextView = remember { TextView(context) }
|
||||||
text = serverIpText,
|
AndroidView(factory = { serverIpTextView }, modifier = modifier) { textView ->
|
||||||
modifier = modifier.minimumInteractiveComponentSize(),
|
textView.apply {
|
||||||
textAlign = TextAlign.Start,
|
text = serverIpText
|
||||||
)
|
textSize = 14F
|
||||||
|
minHeight = context.resources.getDimensionPixelSize(R.dimen.material_minimum_height_and_width)
|
||||||
|
gravity = Gravity.CENTER or Gravity.START
|
||||||
|
LinkifyCompat.addLinks(this, Linkify.WEB_URLS)
|
||||||
|
movementMethod = LinkMovementMethod.getInstance()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ShareIcon(shareIconItem: Pair<Boolean, () -> Unit>) {
|
private fun ShareIcon(shareIconItem: Pair<Boolean, () -> Unit>) {
|
||||||
if (shareIconItem.first) {
|
if (shareIconItem.first) {
|
||||||
Image(
|
Image(
|
||||||
painter = painterResource(id = R.drawable.ic_share_35dp),
|
painter = painterResource(id = R.drawable.ic_share_35dp),
|
||||||
@ -128,7 +149,7 @@ fun ShareIcon(shareIconItem: Pair<Boolean, () -> Unit>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun QRImage(qrImageItem: Pair<Boolean, IconItem>) {
|
private fun QRImage(qrImageItem: Pair<Boolean, IconItem>) {
|
||||||
if (qrImageItem.first) {
|
if (qrImageItem.first) {
|
||||||
Image(
|
Image(
|
||||||
painter = qrImageItem.second.toPainter(),
|
painter = qrImageItem.second.toPainter(),
|
||||||
@ -143,7 +164,7 @@ fun QRImage(qrImageItem: Pair<Boolean, IconItem>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun BookItemList(
|
private fun BookItemList(
|
||||||
booksList: List<BooksOnDiskListItem>,
|
booksList: List<BooksOnDiskListItem>,
|
||||||
selectionMode: SelectionMode,
|
selectionMode: SelectionMode,
|
||||||
qrImageItem: Pair<Boolean, IconItem>,
|
qrImageItem: Pair<Boolean, IconItem>,
|
||||||
|
@ -1,113 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Kiwix Android
|
|
||||||
~ Copyright (c) 2023 Kiwix <android.kiwix.org>
|
|
||||||
~ This program is free software: you can redistribute it and/or modify
|
|
||||||
~ it under the terms of the GNU General Public License as published by
|
|
||||||
~ the Free Software Foundation, either version 3 of the License, or
|
|
||||||
~ (at your option) any later version.
|
|
||||||
~
|
|
||||||
~ This program is distributed in the hope that it will be useful,
|
|
||||||
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
~ GNU General Public License for more details.
|
|
||||||
~
|
|
||||||
~ You should have received a copy of the GNU General Public License
|
|
||||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
~
|
|
||||||
-->
|
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
tools:context="org.kiwix.kiwixmobile.webserver.ZimHostFragment">
|
|
||||||
|
|
||||||
<include layout="@layout/layout_toolbar" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/serverTextView"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="16dp"
|
|
||||||
android:layout_marginEnd="4dp"
|
|
||||||
android:autoLink="web"
|
|
||||||
android:gravity="center|start"
|
|
||||||
android:minHeight="@dimen/material_minimum_height_and_width"
|
|
||||||
android:text="@string/server_textview_default_message"
|
|
||||||
app:layout_constraintEnd_toStartOf="@id/shareServerUrlIcon"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/toolbar" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/shareServerUrlIcon"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:scaleType="centerInside"
|
|
||||||
android:minHeight="@dimen/material_minimum_height_and_width"
|
|
||||||
android:minWidth="@dimen/material_minimum_height_and_width"
|
|
||||||
android:contentDescription="@string/share_host_address"
|
|
||||||
android:src="@drawable/ic_share_35dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
app:layout_constraintBottom_toBottomOf="@id/serverTextView"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="@id/serverTextView"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<ScrollView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0dp"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/startServerButton"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/serverTextView">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/serverQrCode"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:adjustViewBounds="true"
|
|
||||||
android:contentDescription="@string/qr_code"
|
|
||||||
android:maxHeight="128dp"
|
|
||||||
android:minHeight="76dp"
|
|
||||||
android:visibility="gone"
|
|
||||||
android:scaleType="fitCenter"
|
|
||||||
tools:src="@tools:sample/avatars" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recyclerViewZimHost"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:contentDescription="@string/menu_wifi_hotspot"
|
|
||||||
android:minHeight="256dp"
|
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
|
||||||
tools:listitem="@layout/item_book" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</ScrollView>
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/startServerButton"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="8dp"
|
|
||||||
android:layout_marginLeft="8dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:layout_marginRight="8dp"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:backgroundTint="@color/startServerGreen"
|
|
||||||
android:text="@string/start_server_label"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -42,6 +42,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.graphics.ImageBitmap
|
import androidx.compose.ui.graphics.ImageBitmap
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextAlign
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
import com.tonyodev.fetch2.R.string
|
import com.tonyodev.fetch2.R.string
|
||||||
import org.kiwix.kiwixmobile.core.R
|
import org.kiwix.kiwixmobile.core.R
|
||||||
@ -137,7 +138,7 @@ private fun CrashMessage(
|
|||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(messageId),
|
text = stringResource(messageId),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Normal),
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
color = White,
|
color = White,
|
||||||
modifier = Modifier.padding(start = EIGHT_DP, top = EIGHT_DP, end = EIGHT_DP)
|
modifier = Modifier.padding(start = EIGHT_DP, top = EIGHT_DP, end = EIGHT_DP)
|
||||||
|
@ -30,6 +30,7 @@ import androidx.compose.runtime.MutableState
|
|||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import org.kiwix.kiwixmobile.core.ui.theme.DenimBlue200
|
import org.kiwix.kiwixmobile.core.ui.theme.DenimBlue200
|
||||||
import org.kiwix.kiwixmobile.core.ui.theme.ErrorActivityBackground
|
import org.kiwix.kiwixmobile.core.ui.theme.ErrorActivityBackground
|
||||||
import org.kiwix.kiwixmobile.core.ui.theme.White
|
import org.kiwix.kiwixmobile.core.ui.theme.White
|
||||||
@ -54,7 +55,7 @@ fun CrashCheckBox(checkBoxItem: Pair<Int, MutableState<Boolean>>) {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium.copy(fontWeight = FontWeight.Normal),
|
||||||
text = stringResource(id = checkBoxItem.first),
|
text = stringResource(id = checkBoxItem.first),
|
||||||
color = White,
|
color = White,
|
||||||
modifier = Modifier.padding(start = CRASH_CHECKBOX_TOP_PADDING)
|
modifier = Modifier.padding(start = CRASH_CHECKBOX_TOP_PADDING)
|
||||||
|
@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.core.ui.theme
|
|||||||
|
|
||||||
import androidx.compose.material3.Typography
|
import androidx.compose.material3.Typography
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_BODY_TEXT_SIZE
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_BODY_TEXT_SIZE
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_HEADLINE_TEXT_SIZE
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_HEADLINE_TEXT_SIZE
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_LABEL_TEXT_SIZE
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.LARGE_LABEL_TEXT_SIZE
|
||||||
@ -28,6 +29,7 @@ import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_BODY_TEXT_SIZE
|
|||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_HEADLINE_TEXT_SIZE
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_HEADLINE_TEXT_SIZE
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_LABEL_TEXT_SIZE
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_LABEL_TEXT_SIZE
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_TITLE_TEXT_SIZE
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_TITLE_TEXT_SIZE
|
||||||
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.MEDIUM_BODY_LETTER_SPACING
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_BODY_TEXT_SIZE
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_BODY_TEXT_SIZE
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_HEADLINE_TEXT_SIZE
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_HEADLINE_TEXT_SIZE
|
||||||
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_LABEL_TEXT_SIZE
|
import org.kiwix.kiwixmobile.core.utils.ComposeDimens.SMALL_LABEL_TEXT_SIZE
|
||||||
@ -47,7 +49,11 @@ val KiwixTypography = Typography(
|
|||||||
titleMedium = TextStyle(fontSize = MEDIUM_TITLE_TEXT_SIZE),
|
titleMedium = TextStyle(fontSize = MEDIUM_TITLE_TEXT_SIZE),
|
||||||
titleSmall = TextStyle(fontSize = SMALL_TITLE_TEXT_SIZE),
|
titleSmall = TextStyle(fontSize = SMALL_TITLE_TEXT_SIZE),
|
||||||
bodyLarge = TextStyle(fontSize = LARGE_BODY_TEXT_SIZE),
|
bodyLarge = TextStyle(fontSize = LARGE_BODY_TEXT_SIZE),
|
||||||
bodyMedium = TextStyle(fontSize = MEDIUM_BODY_TEXT_SIZE),
|
bodyMedium = TextStyle(
|
||||||
|
fontSize = MEDIUM_BODY_TEXT_SIZE,
|
||||||
|
fontWeight = FontWeight.Medium,
|
||||||
|
letterSpacing = MEDIUM_BODY_LETTER_SPACING
|
||||||
|
),
|
||||||
bodySmall = TextStyle(fontSize = SMALL_BODY_TEXT_SIZE),
|
bodySmall = TextStyle(fontSize = SMALL_BODY_TEXT_SIZE),
|
||||||
labelLarge = TextStyle(fontSize = LARGE_LABEL_TEXT_SIZE),
|
labelLarge = TextStyle(fontSize = LARGE_LABEL_TEXT_SIZE),
|
||||||
labelMedium = TextStyle(fontSize = MEDIUM_LABEL_TEXT_SIZE),
|
labelMedium = TextStyle(fontSize = MEDIUM_LABEL_TEXT_SIZE),
|
||||||
|
@ -47,6 +47,7 @@ object ComposeDimens {
|
|||||||
val TWELVE_DP = 12.dp
|
val TWELVE_DP = 12.dp
|
||||||
val TEN_DP = 10.dp
|
val TEN_DP = 10.dp
|
||||||
val EIGHT_DP = 8.dp
|
val EIGHT_DP = 8.dp
|
||||||
|
val SIX_DP = 6.dp
|
||||||
val FIVE_DP = 5.dp
|
val FIVE_DP = 5.dp
|
||||||
val FOUR_DP = 4.dp
|
val FOUR_DP = 4.dp
|
||||||
val TWO_DP = 2.dp
|
val TWO_DP = 2.dp
|
||||||
@ -79,6 +80,7 @@ object ComposeDimens {
|
|||||||
val LARGE_LABEL_TEXT_SIZE = 14.sp
|
val LARGE_LABEL_TEXT_SIZE = 14.sp
|
||||||
val MEDIUM_LABEL_TEXT_SIZE = 12.sp
|
val MEDIUM_LABEL_TEXT_SIZE = 12.sp
|
||||||
val SMALL_LABEL_TEXT_SIZE = 10.sp
|
val SMALL_LABEL_TEXT_SIZE = 10.sp
|
||||||
|
val MEDIUM_BODY_LETTER_SPACING = 0.00714285714.em
|
||||||
|
|
||||||
// AddNoteDialog dimens
|
// AddNoteDialog dimens
|
||||||
val MINIMUM_HEIGHT_OF_NOTE_TEXT_FILED = 120.dp
|
val MINIMUM_HEIGHT_OF_NOTE_TEXT_FILED = 120.dp
|
||||||
@ -93,5 +95,4 @@ object ComposeDimens {
|
|||||||
|
|
||||||
// BookItem dimes
|
// BookItem dimes
|
||||||
val BOOK_ICON_SIZE = 40.dp
|
val BOOK_ICON_SIZE = 40.dp
|
||||||
val BOOK_DESCRIPTION_LETTER_SPACING = 0.00714285714.em
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user