Skip to content

Commit

Permalink
v1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
YangDai2003 committed May 1, 2024
1 parent dfb89e0 commit e048049
Show file tree
Hide file tree
Showing 26 changed files with 118 additions and 237 deletions.
4 changes: 2 additions & 2 deletions .idea/deploymentTargetDropDown.xml

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

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

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

1 change: 0 additions & 1 deletion .idea/misc.xml

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

15 changes: 8 additions & 7 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.androidApplication)
alias(libs.plugins.jetbrainsKotlinAndroid)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.googleHilt)
alias(libs.plugins.googleKsp)
alias(libs.plugins.googleGms)
Expand All @@ -16,8 +17,8 @@ android {
applicationId = "com.yangdai.opennote"
minSdk = 29
targetSdk = 34
versionCode = 120
versionName = "1.2.0"
versionCode = 122
versionName = "1.2.2"
resourceConfigurations += listOf("en", "zh")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -51,8 +52,10 @@ android {
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.12"
composeCompiler {
enableStrongSkippingMode = true
enableIntrinsicRemember = true
enableNonSkippingGroupOptimization = true
}
packaging {
resources {
Expand Down Expand Up @@ -95,11 +98,10 @@ dependencies {
annotationProcessor(libs.androidx.room.compiler)
ksp(libs.androidx.room.compiler)
implementation(libs.androidx.room.ktx)
implementation(libs.androidx.room.paging)
testImplementation(libs.androidx.room.testing)

// Hilt, for dependency injection
implementation(libs.androidx.hilt)
implementation(libs.androidx.hilt.navigation)
ksp(libs.google.hilt.compiler)
implementation(libs.google.hilt)

Expand All @@ -124,7 +126,6 @@ dependencies {
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.biometric)
implementation(libs.androidx.datastore.preferences)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)

// Test
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
10 changes: 3 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@

<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.CAMERA" />
<uses-feature
android:name="android.hardware.camera"
android:required="false" />

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />

<queries>
Expand All @@ -36,15 +32,15 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:localeConfig="@xml/locales_config"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.OpenNote"
android:theme="@style/Theme.OpenNote.Starting"
android:usesCleartextTraffic="true"
tools:targetApi="tiramisu">
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.OpenNote.Starting"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/com/yangdai/opennote/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class MainActivity : AppCompatActivity() {
0f
)

animation.duration = 200L
animation.duration = 300L

// Call SplashScreenView.remove at the end of your custom animation.
animation.doOnEnd { splashScreenView.remove() }
Expand All @@ -54,7 +54,6 @@ class MainActivity : AppCompatActivity() {
}

enableEdgeToEdge()

super.onCreate(savedInstanceState)

setContent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.floatPreferencesKey
import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.core.stringSetPreferencesKey
Expand Down Expand Up @@ -38,6 +39,13 @@ class DataStoreRepositoryImpl @Inject constructor(
}
}

override suspend fun putFloat(key: String, value: Float) {
val preferencesKey = floatPreferencesKey(key)
context.dataStore.edit { preferences ->
preferences[preferencesKey] = value
}
}

override suspend fun putBoolean(key: String, value: Boolean) {
val preferencesKey = booleanPreferencesKey(key)
context.dataStore.edit { preferences ->
Expand Down Expand Up @@ -67,6 +75,17 @@ class DataStoreRepositoryImpl @Inject constructor(
}
}

override suspend fun getFloat(key: String): Float? {
return try {
val preferencesKey = floatPreferencesKey(key)
val preferences = context.dataStore.data.first()
preferences[preferencesKey]
} catch (e: Exception) {
e.printStackTrace()
null
}
}

override suspend fun getBoolean(key: String): Boolean? {
return try {
val preferencesKey = booleanPreferencesKey(key)
Expand Down Expand Up @@ -103,6 +122,13 @@ class DataStoreRepositoryImpl @Inject constructor(
}
}

override fun floatFlow(key: String): Flow<Float> {
val preferencesKey = floatPreferencesKey(key)
return context.dataStore.data.map { preferences ->
preferences[preferencesKey] ?: 0f
}
}

override fun stringFlow(key: String): Flow<String> {
val preferencesKey = stringPreferencesKey(key)
return context.dataStore.data.map { preferences ->
Expand All @@ -123,12 +149,4 @@ class DataStoreRepositoryImpl @Inject constructor(
preferences[preferencesKey] ?: setOf()
}
}

override fun preferencesFlow(): Flow<Preferences> {
return context.dataStore.data
}

override fun getDataStore(): DataStore<Preferences> {
return context.dataStore
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.yangdai.opennote.domain.repository

import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import kotlinx.coroutines.flow.Flow

interface DataStoreRepository {

suspend fun putString(key: String, value: String)
suspend fun putInt(key: String, value: Int)
suspend fun putFloat(key: String, value: Float)
suspend fun putBoolean(key: String, value: Boolean)
suspend fun putStringSet(key: String, value: Set<String>)

suspend fun getString(key: String): String?
suspend fun getInt(key: String): Int?
suspend fun putBoolean(key: String, value: Boolean)
suspend fun getFloat(key: String): Float?
suspend fun getBoolean(key: String): Boolean?
suspend fun putStringSet(key: String, value: Set<String>)
suspend fun getStringSet(key: String): Set<String>?

fun intFlow(key: String): Flow<Int>
fun floatFlow(key: String): Flow<Float>
fun stringFlow(key: String): Flow<String>
fun booleanFlow(key: String): Flow<Boolean>
fun stringSetFlow(key: String): Flow<Set<String>>
fun preferencesFlow(): Flow<Preferences>
fun getDataStore(): DataStore<Preferences>
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CurlyCornerShape(
topEnd: Float,
bottomEnd: Float,
bottomStart: Float,
layoutDirection: LayoutDirection,
layoutDirection: LayoutDirection
): Outline {
val d = 2.0
val r2: Double = size.width / d
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ fun MarkdownText(html: String) {
setPadding(0, 0, 0, 0)
setBackgroundColor(Color.TRANSPARENT)
}
}, update = {
},
update = {
val data = """
<!DOCTYPE html>
<html>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fun SelectableColorPlatte(
modifier = Modifier
.align(Alignment.Center)
.clip(CircleShape)
.background(MaterialTheme.colorScheme.primary),
.background(colorScheme.tertiaryContainer),
enter = fadeIn() + expandIn(expandFrom = Alignment.Center),
exit = shrinkOut(shrinkTowards = Alignment.Center) + fadeOut()
) {
Expand Down
Loading

0 comments on commit e048049

Please sign in to comment.