Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import for GoogleKeep and Evernote #83

Merged
merged 5 commits into from
Oct 29, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/captures
.externalNativeBuild
.cxx
*/.attach_pid*
32 changes: 16 additions & 16 deletions .scripts/pre-commit
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/bin/sh

# Count the number of staged Kotlin files
staged_files_count=$(git diff --name-only --cached --numstat -- '*.kt' | wc -l)
# Capture the list of initially staged Kotlin files
initial_staged_files=$(git diff --name-only --cached -- '*.kt')

# Format only if there are Kotlin files in git's index
if [ "$staged_files_count" -gt 0 ]; then
# Format the staged Kotlin files and remove the "app/" prefix
formatted_files=$(git diff --name-only --cached -- '*.kt' | sed 's|^app/||' | paste -sd ",")
./gradlew ktfmtPrecommit --include-only="$formatted_files"
if [ -z "$initial_staged_files" ]; then
echo "No Kotlin files staged for commit."
exit 0
fi

# Check if the formatting command was successful
if [ $? -ne 0 ]; then
echo "Kotlin formatting failed. Please fix the issues."
exit 1
fi
formatted_files=$(echo "$initial_staged_files" | sed 's|^app/||' | paste -sd "," -)
echo "Formatting Kotlin files: $formatted_files"
./gradlew ktfmtPrecommit --include-only="$formatted_files"

# Add the formatted Kotlin files to the staging area
git add -A $(git diff --name-only -- '*.kt')
echo "Kotlin files formatted and changes staged."
if [ $? -ne 0 ]; then
echo "Kotlin formatting failed. Please fix the issues."
exit 1
fi

exit 0
# Re-stage only the initially staged Kotlin files
echo "$initial_staged_files" | xargs git add

echo "Kotlin files formatted"
56 changes: 31 additions & 25 deletions .scripts/pre-commit.bat
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
@echo off
setlocal enabledelayedexpansion

rem Count the number of staged Kotlin files
for /f %%i in ('git diff --name-only --cached --numstat -- "*.kt" ^| find /c /v ""') do set staged_files_count=%%i

rem Format only if there are Kotlin files in git's index
if %staged_files_count% gtr 0 (
rem Format the staged Kotlin files and remove the "app/" prefix
for /f "delims=" %%f in ('git diff --name-only --cached -- "*.kt" ^| sed "s|^app/||"') do (
set formatted_files=%%f
set formatted_files=!formatted_files!, %%f
)
rem Remove the trailing comma if necessary
set formatted_files=%formatted_files:~, -1%

call gradlew ktfmtPrecommit --include-only="%formatted_files%"

rem Check if the formatting command was successful
if errorlevel 1 (
echo Kotlin formatting failed. Please fix the issues.
exit /b 1
)

rem Add the formatted Kotlin files to the staging area
git add -A git diff --name-only -- "*.kt"
echo Kotlin files formatted and changes staged.
rem Capture the list of initially staged Kotlin files
set "initial_staged_files="
for /f "delims=" %%f in ('git diff --name-only --cached -- "*.kt"') do (
set "initial_staged_files=!initial_staged_files! %%f,"
)

exit /b 0
rem Check if there are any staged Kotlin files
if "%initial_staged_files%"=="" (
echo No Kotlin files staged for commit.
exit /b 0
)

rem Remove the trailing comma from the list of formatted files
set "formatted_files=%initial_staged_files:~0,-1%"

echo Formatting Kotlin files: %formatted_files%
call gradlew ktfmtPrecommit --include-only="%formatted_files%"

rem Check if the formatting command was successful
if errorlevel 1 (
echo Kotlin formatting failed. Please fix the issues.
exit /b 1
)

rem Re-stage only the initially staged Kotlin files
for %%f in (%initial_staged_files%) do (
git add "%%f"
)

echo Kotlin files formatted

exit /b 0
22 changes: 22 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ plugins {
id 'kotlin-parcelize'
id 'com.google.devtools.ksp'
id 'com.ncorti.ktfmt.gradle' version '0.20.1'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.0'

}

android {
Expand Down Expand Up @@ -54,6 +56,12 @@ android {
packagingOptions.resources {
excludes += ["DebugProbesKt.bin", "META-INF/**.version", "kotlin/**.kotlin_builtins", "kotlin-tooling-metadata.json"]
}

testOptions {
unitTests {
includeAndroidResources true
}
}
}

tasks.withType(KotlinCompile).configureEach {
Expand Down Expand Up @@ -111,10 +119,24 @@ dependencies {
implementation "com.github.bumptech.glide:glide:4.15.1"
implementation "com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0"

implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
implementation("org.simpleframework:simple-xml:2.7.1") {
exclude group: 'xpp3', module: 'xpp3'
}
implementation 'org.jsoup:jsoup:1.18.1'

testImplementation "junit:junit:4.13.2"
testImplementation "androidx.test:core:1.6.1"
testImplementation "androidx.test:core-ktx:1.6.1"
testImplementation "org.mockito:mockito-core:5.13.0"
testImplementation "org.mockito.kotlin:mockito-kotlin:5.4.0"
testImplementation "io.mockk:mockk:1.13.12"
testImplementation "org.json:json:20180813"
testImplementation "org.assertj:assertj-core:3.24.2"
testImplementation "org.robolectric:robolectric:4.13"

androidTestImplementation "androidx.room:room-testing:$roomVersion"
androidTestImplementation "androidx.work:work-testing:2.9.1"

}
25 changes: 24 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,28 @@
-keep class ** extends androidx.navigation.Navigator
-keep class ** implements org.ocpsoft.prettytime.TimeUnit

# SQLCipher
-keep class net.sqlcipher.** { *; }
-keep class net.sqlcipher.database.** { *; }
-keep class net.sqlcipher.database.** { *; }

# SimpleXML
-keepattributes Signature
-keepattributes *Annotation
-keep interface org.simpleframework.xml.core.Label {
public *;
}
-keep class * implements org.simpleframework.xml.core.Label {
public *;
}
-keep interface org.simpleframework.xml.core.Parameter {
public *;
}
-keep class * implements org.simpleframework.xml.core.Parameter {
public *;
}
-keep interface org.simpleframework.xml.core.Extractor {
public *;
}
-keep class * implements org.simpleframework.xml.core.Extractor {
public *;
}
9 changes: 5 additions & 4 deletions app/src/main/java/com/philkes/notallyx/Preferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ class Preferences private constructor(app: Application) {
private val preferences = PreferenceManager.getDefaultSharedPreferences(app)
private val editor = preferences.edit()

private val encryptedPreferences =
private val encryptedPreferences by lazy {
EncryptedSharedPreferences.create(
app,
"secret_shared_prefs",
MasterKey.Builder(app).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build(),
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM,
)
}

// Main thread (unfortunately)
val view = BetterLiveData(getListPref(View))
Expand All @@ -68,7 +69,7 @@ class Preferences private constructor(app: Application) {
val autoBackupPath = BetterLiveData(getTextPref(AutoBackup))
var autoBackupPeriodDays = BetterLiveData(getSeekbarPref(AutoBackupPeriodDays))
var autoBackupMax = getSeekbarPref(AutoBackupMax)
var backupPassword = BetterLiveData(getEncryptedTextPref(BackupPassword))
val backupPassword by lazy { BetterLiveData(getEncryptedTextPref(BackupPassword)) }

val biometricLock = BetterLiveData(getListPref(BiometricLock))
var iv: ByteArray?
Expand Down Expand Up @@ -119,7 +120,7 @@ class Preferences private constructor(app: Application) {
requireNotNull(preferences.getString(info.key, info.defaultValue))

private fun getEncryptedTextPref(info: TextInfo) =
requireNotNull(encryptedPreferences.getString(info.key, info.defaultValue))
requireNotNull(encryptedPreferences!!.getString(info.key, info.defaultValue))

private fun getSeekbarPref(info: SeekbarInfo) =
requireNotNull(preferences.getInt(info.key, info.defaultValue))
Expand Down Expand Up @@ -192,7 +193,7 @@ class Preferences private constructor(app: Application) {
}

fun savePreference(info: TextInfo, value: String) {
val editor = if (info is BackupPassword) encryptedPreferences.edit() else this.editor
val editor = if (info is BackupPassword) encryptedPreferences!!.edit() else this.editor
editor.putString(info.key, value)
editor.commit()
when (info) {
Expand Down
Loading