Skip to content
Open
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
2 changes: 1 addition & 1 deletion .idea/compiler.xml

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

11 changes: 8 additions & 3 deletions .idea/deploymentTargetSelector.xml

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

3 changes: 1 addition & 2 deletions .idea/gradle.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/misc.xml

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

3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ dependencies {
implementation("androidx.glance:glance-appwidget:1.1.1")
implementation("androidx.glance:glance-material3:1.1.1")

//noinspection Aligned16KB
implementation("net.zetetic:android-database-sqlcipher:4.5.4")


testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<application
android:name=".SnaptickApplication"
android:allowBackup="true"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import androidx.room.Room
import androidx.room.RoomDatabase
import com.vishal2376.snaptick.domain.model.Task

import net.sqlcipher.database.SQLiteDatabase
import net.sqlcipher.database.SupportFactory

@Database(
entities = [Task::class],
version = 2,
Expand All @@ -23,13 +26,24 @@ abstract class TaskDatabase : RoomDatabase() {
*/
fun getInstance(context: Context): TaskDatabase {
return INSTANCE ?: synchronized(this) {

// Initialize SQLCipher engine (Required for this version!)
SQLiteDatabase.loadLibs(context)

// Define the encryption key
val passphrase = "SuperSecretKey123!".toByteArray()

// Create the SQLCipher factory
val factory = SupportFactory(passphrase)

val instance = Room.databaseBuilder(
context.applicationContext,
TaskDatabase::class.java,
"local_db"
)
.fallbackToDestructiveMigration()
.addMigrations(MIGRATION_1_2)
.openHelperFactory(factory) // ATTACH THE ENCRYPTION FIX HERE
.build()
INSTANCE = instance
instance
Expand Down
13 changes: 2 additions & 11 deletions app/src/main/res/xml/backup_rules.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<?xml version="1.0" encoding="utf-8"?>
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
<exclude domain="database" path="."/>
</full-backup-content>
16 changes: 3 additions & 13 deletions app/src/main/res/xml/data_extraction_rules.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<?xml version="1.0" encoding="utf-8"?>
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
<exclude domain="database" path="."/>
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
<exclude domain="database" path="."/>
</device-transfer>
-->
</data-extraction-rules>