Skip to content

Commit

Permalink
Alternative markdown viewer
Browse files Browse the repository at this point in the history
Work in proress
  • Loading branch information
patrickunterwegs committed Jan 3, 2025
1 parent a908066 commit 27269a3
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ android {
defaultConfig {
applicationId = "at.techbee.jtx"
buildConfigField("long", "buildTime", "${System.currentTimeMillis()}L")
minSdk = 23
minSdk = 24
targetSdk = 35
versionCode = 210000004
versionName = "2.10.00-beta01" // keep -release as a suffix also for release, build flavor adds the suffix e.g. .gplay (e.g. 1.00.00-rc0.gplay)
Expand Down
41 changes: 22 additions & 19 deletions app/src/main/java/at/techbee/jtx/ui/detail/DetailScreenContent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package at.techbee.jtx.ui.detail

import android.media.MediaPlayer
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand Down Expand Up @@ -55,15 +56,12 @@ import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardCapitalization
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.input.getTextBeforeSelection
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextDirection
import androidx.compose.ui.tooling.preview.Preview
Expand Down Expand Up @@ -96,9 +94,9 @@ import at.techbee.jtx.ui.detail.models.DetailsScreenSection
import at.techbee.jtx.ui.reusable.elements.ProgressElement
import at.techbee.jtx.ui.settings.DropdownSettingOption
import at.techbee.jtx.util.DateTimeUtils
import com.arnyminerz.markdowntext.MarkdownText
import com.colintheshots.twain.MarkdownEditor
import com.colintheshots.twain.MarkdownText
import kotlinx.coroutines.delay
import org.apache.commons.lang3.StringUtils
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
Expand Down Expand Up @@ -416,15 +414,15 @@ fun DetailScreenContent(
markdown = description.text.trim(),
modifier = Modifier
.fillMaxWidth()
.padding(8.dp),
.padding(8.dp)
.clickable(onClick = {
if (collection?.readonly == false)
isEditMode.value = true
}),
style = TextStyle(
textDirection = TextDirection.Content,
fontFamily = LocalTextStyle.current.fontFamily
),
onClick = {
if (collection?.readonly == false)
isEditMode.value = true
}
)
else
Text(
Expand Down Expand Up @@ -466,18 +464,18 @@ fun DetailScreenContent(
}

if(description.text.isNotEmpty() || detailSettings.detailSetting[DetailSettingsOption.ENABLE_DESCRIPTION] == true || showAllOptions) {
OutlinedTextField(
value = description,
MarkdownEditor(
value = description.text,
onValueChange = {

/*
// START Create bulletpoint if previous line started with a bulletpoint
val enteredCharIndex =
StringUtils.indexOfDifference(it.text, description.text)
StringUtils.indexOfDifference(it, description.text)
val enteredCharIsReturn =
enteredCharIndex >= 0
&& it.text.substring(enteredCharIndex)
&& it.substring(enteredCharIndex)
.startsWith(System.lineSeparator())
&& it.text.length > description.text.length // excludes backspace!
&& it.length > description.text.length // excludes backspace!
val before = it.getTextBeforeSelection(Int.MAX_VALUE)
val after =
Expand All @@ -496,7 +494,7 @@ fun DetailScreenContent(
}
description =
if (description.text != it.text && (nextLineStartWith != null) && enteredCharIsReturn)
if (description.text != it && (nextLineStartWith != null) && enteredCharIsReturn)
TextFieldValue(
annotatedString = before.plus(
AnnotatedString(
Expand All @@ -509,16 +507,21 @@ fun DetailScreenContent(
it
// END Create bulletpoint if previous line started with a bulletpoint
iCalObject.description = it.text.ifEmpty { null }
*/
description = description.copy(it)
iCalObject.description = it.ifEmpty { null }
changeState.value = DetailViewModel.DetailChangeState.CHANGEUNSAVED
},
label = { Text(stringResource(id = R.string.description)) },
hint = R.string.description,
/*
keyboardOptions = KeyboardOptions(
capitalization = KeyboardCapitalization.Sentences,
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Default
),
minLines = 3,
*/
modifier = Modifier
.fillMaxWidth()
.padding(8.dp)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/at/techbee/jtx/ui/list/ListCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ import at.techbee.jtx.ui.settings.DropdownSettingOption
import at.techbee.jtx.ui.theme.Typography
import at.techbee.jtx.ui.theme.jtxCardBorderStrokeWidth
import at.techbee.jtx.ui.theme.jtxCardCornerShape
import com.arnyminerz.markdowntext.MarkdownText
import com.colintheshots.twain.MarkdownText
import sh.calvin.reorderable.ReorderableColumn


Expand Down Expand Up @@ -145,7 +145,7 @@ fun ListCard(
MarkdownText(
markdown = iCalObject.description?.trim() ?: "",
maxLines = 6,
overflow = TextOverflow.Ellipsis,
//overflow = TextOverflow.Ellipsis,
modifier = Modifier.fillMaxWidth()
)
else
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/at/techbee/jtx/ui/list/ListCardGrid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import at.techbee.jtx.database.locals.StoredCategory
import at.techbee.jtx.database.views.ICal4List
import at.techbee.jtx.ui.reusable.elements.AudioPlaybackElement
import at.techbee.jtx.ui.theme.jtxCardBorderStrokeWidth
import com.arnyminerz.markdowntext.MarkdownText
import com.colintheshots.twain.MarkdownText


@Composable
Expand Down Expand Up @@ -125,7 +125,7 @@ fun ListCardGrid(
MarkdownText(
markdown = iCalObject.description?.trim() ?: "",
maxLines = 3,
overflow = TextOverflow.Ellipsis,
//overflow = TextOverflow.Ellipsis,
modifier = Modifier
.fillMaxWidth()
.padding(end = 8.dp)
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/at/techbee/jtx/ui/list/ListCardKanban.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import at.techbee.jtx.database.locals.StoredCategory
import at.techbee.jtx.database.views.ICal4List
import at.techbee.jtx.ui.reusable.elements.AudioPlaybackElement
import at.techbee.jtx.ui.theme.jtxCardBorderStrokeWidth
import com.arnyminerz.markdowntext.MarkdownText
import com.colintheshots.twain.MarkdownText


@Composable
Expand Down Expand Up @@ -95,7 +95,7 @@ fun ListCardKanban(
MarkdownText(
markdown = iCalObject.description?.trim() ?: "",
maxLines = 4,
overflow = TextOverflow.Ellipsis
//overflow = TextOverflow.Ellipsis
)
else
Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import at.techbee.jtx.R
import com.arnyminerz.markdowntext.MarkdownText
import com.colintheshots.twain.MarkdownText


@Composable
Expand Down
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ playServicesLocation = "21.3.0"
playServicesMaps = "19.0.0"
profileinstaller = "1.4.1"
reorderable = "2.4.0"
twain = "0.3.2"
uiTextGoogleFonts = "1.7.6"
room = "2.6.1"
volley = "1.2.1"
Expand Down Expand Up @@ -107,6 +108,7 @@ room-base = { module = "androidx.room:room-ktx", version.ref = "room" }
room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
room-runtime = { module = "androidx.room:room-runtime", version.ref = "room" }
room-testing = { module = "androidx.room:room-testing", version.ref = "room" }
twain = { module = "com.colintheshots:twain", version.ref = "twain" }
volley = { module = "com.android.volley:volley", version.ref = "volley" }

# gplay and managed build variants
Expand Down

0 comments on commit 27269a3

Please sign in to comment.