Skip to content

Commit

Permalink
- Repair bug in RTL text
Browse files Browse the repository at this point in the history
- Repair bug related session expired
  • Loading branch information
DesarrolloAntonio committed May 21, 2024
1 parent 4492ae8 commit 457cbdc
Show file tree
Hide file tree
Showing 9 changed files with 327 additions and 19 deletions.
261 changes: 261 additions & 0 deletions .idea/other.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions presentation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id ("de.mannodermaus.android-junit5")
}

android {
Expand Down Expand Up @@ -100,6 +101,15 @@ dependencies {
implementation (libs.androidx.datastore.preferences)
implementation (libs.coil.compose)

// Testing libraries
testImplementation(libs.junit.jupiter) // JUnit Jupiter for unit testing with JUnit 5.
testRuntimeOnly(libs.junit.jupiter.engine) // JUnit Jupiter Engine for running JUnit 5 tests.
testImplementation(libs.junit.jupiter.api) // JUnit Jupiter API for writing tests and extensions in JUnit 5.
testImplementation(libs.mockito.core) // Mockito for mocking objects in tests.
testImplementation(libs.mockito.kotlin) // Kotlin extension for Mockito to better support Kotlin features.
testImplementation(libs.kotlin.coroutines.test) // Coroutines Test library for testing Kotlin coroutines.
testImplementation(libs.kotlin.test.junit5) // Kotlin Test library for JUnit 5 support.

}

java {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package com.desarrollodroide.pagekeeper.extensions
*
* @return True if the string contains more than half Arabic characters, false otherwise.
*/
fun String.isArabicText(): Boolean {
fun String.isRTLText(): Boolean {
// Take the first 20 characters of the string
val textSample = this.take(20)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,10 @@ fun FeedScreen(
content = bookmarksUiState.error,
openDialog = remember { mutableStateOf(true) },
onConfirm = {
actions.onClearError()
actions.goToLogin.invoke()
if (bookmarksUiState.error == SESSION_HAS_BEEN_EXPIRED){
actions.onClearError()
actions.goToLogin.invoke()
}
},
properties = DialogProperties(
dismissOnClickOutside = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,10 @@ class FeedViewModel(
when (result) {
is Result.Error -> {
Log.v("FeedViewModel", "Error getting tags: ${result.error?.message}")
_tagsState.error(
errorMessage = result.error?.message ?: ""
)
}

is Result.Loading -> {
Log.v("FeedViewModel", "updating tags...")
Log.v("FeedViewModel", "Loading, updating tags from cache...")
_tagsState.success(result.data)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import com.desarrollodroide.data.extensions.removeTrailingSlash
import com.desarrollodroide.model.Bookmark
import com.desarrollodroide.pagekeeper.extensions.isArabicText
import com.desarrollodroide.pagekeeper.extensions.isRTLText

@Composable
fun FullBookmarkView(
Expand All @@ -32,7 +32,7 @@ fun FullBookmarkView(
token: String,
actions: BookmarkActions
) {
val isArabic = bookmark.title.isArabicText() || bookmark.excerpt.isArabicText()
val isArabic = bookmark.title.isRTLText() || bookmark.excerpt.isRTLText()
val imageUrl =
"${serverURL.removeTrailingSlash()}${bookmark.imageURL}?lastUpdated=${bookmark.modified}"
Column {
Expand All @@ -57,13 +57,16 @@ fun FullBookmarkView(
) {
CompositionLocalProvider(LocalLayoutDirection provides if (isArabic) LayoutDirection.Rtl else LayoutDirection.Ltr) {
Text(
modifier = Modifier.fillMaxWidth(),
text = bookmark.title,
style = MaterialTheme.typography.titleLarge,
overflow = TextOverflow.Ellipsis,
maxLines = 2
)
Text(
modifier = Modifier.padding(top = 5.dp),
modifier = Modifier
.fillMaxWidth()
.padding(top = 5.dp),
text = bookmark.excerpt,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.secondary,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.CloudUpload
import androidx.compose.material.icons.filled.MoreVert
import androidx.compose.material.icons.outlined.CloudUpload
import androidx.compose.material.icons.outlined.Delete
Expand Down Expand Up @@ -41,7 +40,7 @@ import androidx.compose.ui.unit.dp
import com.desarrollodroide.data.extensions.removeTrailingSlash
import com.desarrollodroide.model.Bookmark
import com.desarrollodroide.pagekeeper.R
import com.desarrollodroide.pagekeeper.extensions.isArabicText
import com.desarrollodroide.pagekeeper.extensions.isRTLText

@Composable
fun SmallBookmarkView(
Expand All @@ -56,7 +55,7 @@ fun SmallBookmarkView(
"${serverURL.removeTrailingSlash()}${bookmark.imageURL}?lastUpdated=${bookmark.modified}"
val modifier =
if (bookmark.imageURL.isNotEmpty()) Modifier.height(90.dp) else Modifier.wrapContentHeight()
val isArabic = bookmark.title.isArabicText() || bookmark.excerpt.isArabicText()
val isArabic = bookmark.title.isRTLText() || bookmark.excerpt.isRTLText()
Row(
modifier = modifier
.padding(vertical = 8.dp)
Expand Down
Loading

0 comments on commit 457cbdc

Please sign in to comment.