Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
YangDai2003 committed Apr 24, 2024
1 parent 4d279c2 commit 2a5ccc7
Show file tree
Hide file tree
Showing 46 changed files with 2,218 additions and 1,405 deletions.
15 changes: 9 additions & 6 deletions .idea/deploymentTargetDropDown.xml

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

11 changes: 6 additions & 5 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId = "com.yangdai.opennote"
minSdk = 29
targetSdk = 34
versionCode = 118
versionName = "1.1.8"
versionCode = 120
versionName = "1.2.0"
resourceConfigurations += listOf("en", "zh")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -62,10 +62,8 @@ android {
}

dependencies {
// For Glance support
implementation(libs.androidx.glance)
implementation(libs.androidx.glance.appwidget)

implementation(libs.google.gson)
implementation(libs.kotlinx.collections.immutable)

// CommonMark, for markdown rendering and parsing
Expand Down Expand Up @@ -113,6 +111,9 @@ dependencies {
implementation(libs.androidx.compose.material3)
implementation(libs.androidx.compose.material3.window.size)
implementation(libs.androidx.compose.material.icons)
implementation(libs.androidx.compose.material3.adaptive)
implementation(libs.androidx.compose.material3.adaptive.layout)
implementation(libs.androidx.compose.material3.adaptive.navigation)
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.lifecycle.runtime.compose)
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
10 changes: 0 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@
android:name="firebase_analytics_collection_enabled"
android:value="false" />

<!-- <receiver android:name=".presentation.glance.MyReceiver"-->
<!-- android:exported="true">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />-->
<!-- </intent-filter>-->
<!-- <meta-data-->
<!-- android:name="android.appwidget.provider"-->
<!-- android:resource="@xml/my_app_widget_info" />-->
<!-- </receiver>-->

</application>

</manifest>
17 changes: 7 additions & 10 deletions app/src/main/java/com/yangdai/opennote/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,16 @@ import androidx.compose.runtime.remember
import androidx.core.animation.doOnEnd
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.yangdai.opennote.presentation.screen.BaseScreen
import com.yangdai.opennote.presentation.util.BiometricPromptManager
import com.yangdai.opennote.presentation.viewmodel.SharedViewModel
import dagger.hilt.android.AndroidEntryPoint

@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {

private val promptManager by lazy { BiometricPromptManager(this) }
private val sharedViewModel: SharedViewModel by viewModels()
val sharedViewModel: SharedViewModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
// Handle the splash screen transition.
installSplashScreen().apply {
setKeepOnScreenCondition {
Expand Down Expand Up @@ -62,13 +60,12 @@ class MainActivity : AppCompatActivity() {
setContent {
val windowSize = calculateWindowSizeClass(this)
val isLargeScreen by remember {
derivedStateOf { windowSize.widthSizeClass == WindowWidthSizeClass.Expanded && windowSize.heightSizeClass > WindowHeightSizeClass.Compact }
derivedStateOf {
windowSize.widthSizeClass == WindowWidthSizeClass.Expanded
&& windowSize.heightSizeClass > WindowHeightSizeClass.Compact
}
}
BaseScreen(
sharedViewModel = sharedViewModel,
promptManager = promptManager,
isLargeScreen = isLargeScreen
)
BaseScreen(isLargeScreen = isLargeScreen)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.yangdai.opennote.presentation.component

import androidx.compose.foundation.shape.CornerBasedShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.shape.ZeroCornerSize
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Outline
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.unit.LayoutDirection
import kotlin.math.cos
import kotlin.math.sin

class CurlyCornerShape(
private val amp: Double = 16.0,
private val count: Int = 12,
) : CornerBasedShape(
topStart = ZeroCornerSize,
topEnd = ZeroCornerSize,
bottomEnd = ZeroCornerSize,
bottomStart = ZeroCornerSize
) {

private fun sineCircleXYatAngle(
d1: Double,
d2: Double,
d3: Double,
d4: Double,
d5: Double,
i: Int,
): List<Double> = (i.toDouble() * d5).run {
listOf(
(sin(this) * d4 + d3) * cos(d5) + d1,
(sin(this) * d4 + d3) * sin(d5) + d2
)
}

override fun createOutline(
size: Size,
topStart: Float,
topEnd: Float,
bottomEnd: Float,
bottomStart: Float,
layoutDirection: LayoutDirection,
): Outline {
val d = 2.0
val r2: Double = size.width / d
var r13: Double = size.height / d
val r18 = size.width / 2.0 - amp
val path = Path()
path.moveTo((d * r2 - amp).toFloat(), r13.toFloat())
var i = 0
while (true) {
val i2 = i + 1
val d3 = r13
val r5: List<Double> = sineCircleXYatAngle(
r2, r13, r18, amp, Math.toRadians(
i.toDouble()
), count
)
path.lineTo(r5[0].toFloat(), r5[1].toFloat())
if (i2 >= 360) {
path.close()
return Outline.Generic(path)
}
i = i2
r13 = d3
}
}

override fun copy(
topStart: CornerSize,
topEnd: CornerSize,
bottomEnd: CornerSize,
bottomStart: CornerSize,
) = RoundedCornerShape(
topStart = topStart,
topEnd = topEnd,
bottomEnd = bottomEnd,
bottomStart = bottomStart
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.yangdai.opennote.R
import com.yangdai.opennote.data.local.entity.FolderEntity
Expand All @@ -47,9 +48,11 @@ fun DrawerContent(
// Record whether the folder list is expanded
var isFoldersExpended by rememberSaveable { mutableStateOf(false) }

Column(modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())) {
Column(
modifier = Modifier
.fillMaxWidth()
.verticalScroll(rememberScrollState())
) {

Row(
modifier = Modifier.fillMaxWidth(),
Expand Down Expand Up @@ -109,17 +112,12 @@ fun DrawerContent(
}
}

Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.Center
) {
TextButton(
modifier = Modifier
.fillMaxWidth()
.padding(NavigationDrawerItemDefaults.ItemPadding),
onClick = { navigateTo(Route.FOLDERS) }) {
Text(text = stringResource(R.string.manage_folders))
}
TextButton(
modifier = Modifier
.fillMaxWidth()
.padding(NavigationDrawerItemDefaults.ItemPadding),
onClick = { navigateTo(Route.FOLDERS) }) {
Text(text = stringResource(R.string.manage_folders), textAlign = TextAlign.Center)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.yangdai.opennote.R
import com.yangdai.opennote.presentation.util.exportNote

@Composable
fun ExportDialog(
html: String,
title: String,
content: String,
onDismissRequest: () -> Unit
onDismissRequest: () -> Unit,
onConfirm: (String) -> Unit
) {
val context = LocalContext.current
val modeOptions = listOf(
"TXT",
"MARKDOWN",
Expand Down Expand Up @@ -81,22 +77,7 @@ fun ExportDialog(
confirmButton = {
TextButton(
onClick = {
if (selectedMode == "HTML") {
exportNote(
context.applicationContext,
title,
html,
selectedMode
)
} else {
exportNote(
context.applicationContext,
title,
content,
selectedMode
)
}
onDismissRequest()
onConfirm(selectedMode)
}
) {
Text(text = stringResource(android.R.string.ok))
Expand All @@ -110,3 +91,12 @@ fun ExportDialog(
}
})
}

@Composable
@Preview
fun ExportDialogPreview() {
ExportDialog(
onDismissRequest = {},
onConfirm = {}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.grid.LazyGridItemScope
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Delete
import androidx.compose.material.icons.outlined.DriveFileRenameOutline
Expand All @@ -27,7 +28,7 @@ import com.yangdai.opennote.R
import com.yangdai.opennote.data.local.entity.FolderEntity

@Composable
fun FolderItem(
fun LazyGridItemScope.FolderItem(
folder: FolderEntity,
onModify: (FolderEntity) -> Unit,
onDelete: () -> Unit
Expand All @@ -44,7 +45,8 @@ fun FolderItem(
Row(
Modifier
.fillMaxWidth()
.padding(vertical = 4.dp),
.padding(vertical = 4.dp)
.animateItem(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.yangdai.opennote.R
import com.yangdai.opennote.data.local.entity.FolderEntity
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toImmutableList


@Composable
Expand Down Expand Up @@ -130,3 +132,19 @@ fun FolderListDialog(
}
)
}

@Composable
@Preview
fun FolderListDialogPreview() {
FolderListDialog(
hint = "Select a folder",
oFolderId = 1,
folders = listOf(
FolderEntity(1, "Folder 1", null),
FolderEntity(2, "Folder 2", null),
FolderEntity(3, "Folder 3", null)
).toImmutableList(),
onDismissRequest = {},
onSelect = {}
)
}
Loading

0 comments on commit 2a5ccc7

Please sign in to comment.