Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ android {
namespace = "io.github.wiiznokes.gitnote"

// https://developer.android.com/about/versions
compileSdk = 37

compileSdk {
version = release(37) {
minorApiLevel = 2
}
}

defaultConfig {

fun getGitHash(): String {
Expand All @@ -44,8 +48,8 @@ android {
applicationId = "io.github.wiiznokes.gitnote"
minSdk = 30

versionCode = 23
versionName = "26.10.2"
versionCode = 24
versionName = "26.11"

buildConfigField(
"String",
Expand Down Expand Up @@ -136,7 +140,7 @@ android {
}


packagingOptions {
packaging {
dex.useLegacyPackaging = true
jniLibs.useLegacyPackaging = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import java.net.URI
class NetworkPermissionHelper {
companion object {
fun isPermissionGranted(context: Context): Boolean {
if (Build.VERSION.SDK_INT < 37) return true
return PermissionChecker.checkSelfPermission(
return Build.VERSION.SDK_INT < 37 || PermissionChecker.checkSelfPermission(
context,
Manifest.permission.ACCESS_LOCAL_NETWORK
) == PermissionChecker.PERMISSION_GRANTED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ class GithubProvider : Provider {
.sortedByDescending { it.lastModifiedTimeMillis }
.take(nbFirstRepoOwner)

val other = repos.filter { !first.contains(it) }.sortedByDescending { it.lastModifiedTimeMillis }
val other =
repos.filter { !first.contains(it) }.sortedByDescending { it.lastModifiedTimeMillis }

return first + other
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package io.github.wiiznokes.gitnote.ui.component
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.input.TextObfuscationMode
import androidx.compose.foundation.text.input.rememberTextFieldState
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Visibility
import androidx.compose.material.icons.filled.VisibilityOff
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.OutlinedSecureTextField
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
Expand All @@ -23,19 +25,13 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.text.input.VisualTransformation
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import io.github.wiiznokes.gitnote.ui.theme.LocalSpaces


private const val TAG = "GetStringDialog"

@Composable
fun GetStringDialog(
expanded: MutableState<Boolean>,
Expand All @@ -47,82 +43,111 @@ fun GetStringDialog(
keyboardType: KeyboardType = KeyboardType.Text,
onValidation: (String) -> Unit,
) {

BaseDialog(expanded = expanded) {

val focusRequester = remember { FocusRequester() }

LaunchedEffect(null) {
focusRequester.requestFocus()
val textFieldState = rememberTextFieldState(
initialText = defaultString
)

var passwordVisible by rememberSaveable {
mutableStateOf(false)
}

var name by rememberSaveable(stateSaver = TextFieldValue.Saver) {
mutableStateOf(
TextFieldValue(
defaultString,
selection = TextRange(defaultString.length)
)
)
fun validate() {
onValidation(textFieldState.text.toString())

if (unExpandedOnValidation) {
expanded.value = false
}
}

var passwordVisible by rememberSaveable { mutableStateOf(false) }
LaunchedEffect(focusRequester) {
focusRequester.requestFocus()
}

val isPassword = keyboardType == KeyboardType.Password

OutlinedTextField(
modifier = Modifier
.focusRequester(focusRequester),
value = name,
onValueChange = {
name = it
},
label = {
Text(
text = label,
maxLines = 1,
overflow = TextOverflow.Ellipsis
)
},
singleLine = singleLine,
visualTransformation = if (keyboardType != KeyboardType.Password || passwordVisible)
VisualTransformation.None else PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(keyboardType = keyboardType),
keyboardActions = KeyboardActions(
onDone = {
onValidation(name.text)
if (unExpandedOnValidation) {
expanded.value = false
}
}
),
trailingIcon = when (keyboardType) {
KeyboardType.Password -> {
{
val image = if (passwordVisible)
Icons.Filled.Visibility
else Icons.Filled.VisibilityOff
val keyboardOptions = KeyboardOptions(
keyboardType = keyboardType,
imeAction = ImeAction.Done,
)

val description = if (passwordVisible) "Hide password" else "Show password"
IconButton(onClick = { passwordVisible = !passwordVisible }) {
Icon(imageVector = image, description)
if (isPassword) {
OutlinedSecureTextField(
state = textFieldState,
modifier = Modifier.focusRequester(focusRequester),
label = {
Text(
text = label,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
},
keyboardOptions = keyboardOptions,
textObfuscationMode = if (passwordVisible) {
TextObfuscationMode.Visible
} else {
TextObfuscationMode.Hidden
},
trailingIcon = {
IconButton(
onClick = {
passwordVisible = !passwordVisible
}
) {
Icon(
imageVector = if (passwordVisible) {
Icons.Default.Visibility
} else {
Icons.Default.VisibilityOff
},
contentDescription = if (passwordVisible) {
"Hide password"
} else {
"Show password"
},
)
}
}
},
onKeyboardAction = {
validate()
},
)
} else {
OutlinedTextField(
state = textFieldState,
modifier = Modifier.focusRequester(focusRequester),
label = {
Text(
text = label,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
},
lineLimits = if (singleLine) {
androidx.compose.foundation.text.input.TextFieldLineLimits.SingleLine
} else {
androidx.compose.foundation.text.input.TextFieldLineLimits.MultiLine()
},
keyboardOptions = keyboardOptions,
onKeyboardAction = {
validate()
},
)
}

else -> null
}
Spacer(
modifier = Modifier.height(
LocalSpaces.current.dialogSeparation
)
)

Spacer(modifier = Modifier.height(LocalSpaces.current.dialogSeparation))

SimpleButton(
modifier = Modifier
.widthIn(min = 150.dp),
text = actionText
modifier = Modifier.widthIn(min = 150.dp),
text = actionText,
) {
onValidation(name.text)
if (unExpandedOnValidation) {
expanded.value = false
}
validate()
}
}
}
Expand All @@ -131,13 +156,10 @@ fun GetStringDialog(
@Composable
private fun DialogPreview() {
GetStringDialog(
expanded = remember {
mutableStateOf(true)
},
expanded = remember { mutableStateOf(true) },
label = "label",
actionText = "action",
defaultString = "hahaha",
keyboardType = KeyboardType.Password
) {
}
}
keyboardType = KeyboardType.Password,
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import androidx.compose.ui.unit.dp
import com.mikepenz.markdown.m3.Markdown
import io.github.wiiznokes.gitnote.ui.viewmodel.edit.MarkDownVM

private const val TAG = "MarkDown"

@Composable
fun MarkDownContent(
vm: MarkDownVM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ private fun NoteCard(
horizontalAlignment = Alignment.Start,
) {
val title = if (showFullPathOfNotes || !gridNote.isUnique) {
val currentNoteFolderRelativePath = vm.currentNoteFolderRelativePath.collectAsState().value
val currentNoteFolderRelativePath =
vm.currentNoteFolderRelativePath.collectAsState().value

if (currentNoteFolderRelativePath.isEmpty()) {
gridNote.note.relativePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ private fun NoteListRow(
verticalArrangement = Arrangement.Center
) {

val currentNoteFolderRelativePath = vm.currentNoteFolderRelativePath.collectAsState().value
val currentNoteFolderRelativePath =
vm.currentNoteFolderRelativePath.collectAsState().value

val title = if (currentNoteFolderRelativePath.isEmpty()) {
gridNote.note.relativePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ fun MarkdownCustomInner(
padding: MarkdownPadding = markdownPadding(),
dimens: MarkdownDimens = markdownDimens(),
flavour: MarkdownFlavourDescriptor = GFMFlavourDescriptor(),
parser: MarkdownParser = MarkdownParser(flavour, cancellationToken = CancellationToken.NonCancellable),
parser: MarkdownParser = MarkdownParser(
flavour,
cancellationToken = CancellationToken.NonCancellable
),
imageTransformer: ImageTransformer = NoOpImageTransformerImpl(),
annotator: MarkdownAnnotator = markdownAnnotator(),
extendedSpans: MarkdownExtendedSpans = markdownExtendedSpans(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.SheetValue
import androidx.compose.material3.Text
import androidx.compose.material3.rememberBottomSheetState
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ fun EnterUrlScreen(
onClick = {
val urlText = url.value.text
scope.launch {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CINNAMON_BUN && NetworkPermissionHelper.requiresLocalNetworkPermission(urlText) && !NetworkPermissionHelper.isPermissionGranted(
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.CINNAMON_BUN && NetworkPermissionHelper.requiresLocalNetworkPermission(
urlText
) && !NetworkPermissionHelper.isPermissionGranted(
context
)
) {
Expand Down
Loading