Skip to content

Commit 4dd55f5

Browse files
Merge pull request #642 from Kommunicate-io/development
Release/2.14.3
2 parents 6b6a903 + 3a5b985 commit 4dd55f5

File tree

21 files changed

+80
-57
lines changed

21 files changed

+80
-57
lines changed

app/proguard-rules.pro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@
2323
-printconfiguration proguard-merged-config.txt
2424
-keep class net.sqlcipher.** { *; }
2525
-keep class javax.crypto.** { *; }
26+
-keep class net.zetetic.database.sqlcipher.* { *; }
27+
-keep class net.zetetic.database.sqlcipher.** { *; }
2628
-keepattributes *Annotation*

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
android.enableJetifier=true
22
android.useAndroidX=true
3-
org.gradle.jvmargs=-Xmx4096m
3+
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g

gradle/libs.versions.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[versions]
2-
androidDatabaseSqlcipher = "4.5.0"
32
androidGradlePlugin = '8.5.2'
43
appcompat = "1.7.0"
54
browser = "1.8.0"
@@ -34,15 +33,14 @@ retrofit = "2.11.0"
3433
robolectric = "4.13"
3534
runner = "1.6.2"
3635
seleniumJava = "4.1.0"
37-
sentryAndroid = "6.28.0"
36+
sentryAndroid = "7.18.0"
3837
silicompressor = "2.2.4"
3938
swiperefreshlayout = "1.1.0"
4039
googleSecret = "2.0.1"
4140
coreKtxVersion = "1.6.1"
4241
sentryPluginVersion = "4.11.0"
4342

4443
[libraries]
45-
android-database-sqlcipher = { module = "net.zetetic:android-database-sqlcipher", version.ref = "androidDatabaseSqlcipher" }
4644
browser = { module = "androidx.browser:browser", version.ref = "browser" }
4745
cardview = { module = "androidx.cardview:cardview", version.ref = "cardview" }
4846
circleimageview = { module = "de.hdodenhof:circleimageview", version.ref = "circleimageview" }

kommunicate/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ android {
1818
compileSdk 34
1919
targetSdkVersion 35
2020
versionCode 1
21-
versionName "2.14.2"
21+
versionName "2.14.3"
2222
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2323
buildConfigField "String", "KOMMUNICATE_VERSION", "\"" + versionName + "\""
2424
buildConfigField "String", "CHAT_SERVER_URL", '"https://chat.kommunicate.io"'
@@ -52,7 +52,8 @@ android {
5252
dependencies {
5353
implementation fileTree(include: ['*.jar'], dir: 'libs')
5454
implementation libs.core.ktx
55-
implementation libs.android.database.sqlcipher
55+
implementation 'net.zetetic:sqlcipher-android:4.9.0@aar'
56+
implementation 'androidx.sqlite:sqlite-framework:2.2.0'
5657
api libs.org.eclipse.paho.client.mqttv3
5758
api libs.localbroadcastmanager
5859
api libs.appcompat

kommunicate/src/main/java/io/kommunicate/commons/commons/core/utils/DBUtils.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
import android.content.Context;
44
import android.database.Cursor;
5-
import net.sqlcipher.database.SQLiteDatabase;
6-
import net.sqlcipher.database.SQLiteStatement;
5+
import net.zetetic.database.sqlcipher.SQLiteDatabase;
6+
import net.zetetic.database.sqlcipher.SQLiteStatement;
77

8+
import android.database.sqlite.SQLiteException;
89
import android.util.Log;
910

1011
import io.kommunicate.devkit.api.MobiComKitClientService;
@@ -60,10 +61,13 @@ public static boolean isDatabaseEncrypted(Context context, String dbName) {
6061
// Attempt to open the database with the given password
6162
SQLiteDatabase db = null;
6263
try {
63-
db = SQLiteDatabase.openDatabase(dbFile.getPath(), appId, null, SQLiteDatabase.OPEN_READONLY);
64+
// Corrected method call with byte array for password
65+
db = SQLiteDatabase.openDatabase(dbFile.getPath(), appId.getBytes(), null, SQLiteDatabase.OPEN_READONLY, null, null);
6466
db.close();
6567
return true;
66-
} catch (net.sqlcipher.database.SQLiteException e) {
68+
} catch (SQLiteException e) { // Updated exception package
69+
// This exception is thrown if the password is wrong or the DB is not encrypted,
70+
// which for this check, means it's not encrypted with the given key.
6771
return false;
6872
} finally {
6973
if (db != null && db.isOpen()) {

kommunicate/src/main/java/io/kommunicate/database/DatabaseMigrationHelper.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import android.content.Context
44
import android.database.Cursor
55
import io.kommunicate.devkit.api.MobiComKitClientService
66
import io.kommunicate.commons.AppContextService
7-
import net.sqlcipher.database.SQLiteDatabase
8-
import net.sqlcipher.database.SQLiteException
9-
import kotlin.Throws
7+
import net.zetetic.database.sqlcipher.SQLiteDatabase
8+
import android.database.sqlite.SQLiteException
109

1110
object DatabaseMigrationHelper {
1211
private const val TEMP_ENCRYPTED_DB_NAME = "temp_encrypted.db"
@@ -34,7 +33,7 @@ object DatabaseMigrationHelper {
3433
MobiComKitClientService.getApplicationKey(AppContextService.getContext(context))
3534

3635
// Load SQLCipher libraries
37-
SQLiteDatabase.loadLibs(context)
36+
System.loadLibrary("sqlcipher")
3837

3938
// File paths for unencrypted and temporary encrypted databases
4039
val unencryptedDbFile = context.getDatabasePath(databaseName)
@@ -45,18 +44,19 @@ object DatabaseMigrationHelper {
4544
}
4645

4746
// Open the unencrypted database
48-
val unencryptedDb = SQLiteDatabase.openDatabase(
47+
val unencryptedDb = android.database.sqlite.SQLiteDatabase.openDatabase(
4948
unencryptedDbFile.path,
50-
"", // Empty string since it's not encrypted
5149
null,
52-
SQLiteDatabase.OPEN_READWRITE
50+
android.database.sqlite.SQLiteDatabase.OPEN_READWRITE
5351
)
5452

53+
5554
// Create the temporary encrypted database
5655
val encryptedDb = SQLiteDatabase.openOrCreateDatabase(
5756
encryptedTempDbFile.path,
58-
password, // Password for encryption
59-
null
57+
password.toByteArray(Charsets.UTF_8), // Convert the password String to a byte array
58+
null, // CursorFactory
59+
null // SQLiteDatabaseHook
6060
)
6161

6262
// Copy data from unencrypted to encrypted database
@@ -81,7 +81,7 @@ object DatabaseMigrationHelper {
8181

8282
// Copy tables and data from one database to another
8383
@Throws(Exception::class)
84-
private fun copyDataBetweenDatabases(sourceDb: SQLiteDatabase, destinationDb: SQLiteDatabase) {
84+
private fun copyDataBetweenDatabases(sourceDb: android.database.sqlite.SQLiteDatabase, destinationDb: SQLiteDatabase) {
8585
val cursor: Cursor =
8686
sourceDb.rawQuery("SELECT name FROM sqlite_master WHERE type='table'", null)
8787
if (cursor.moveToFirst()) {
@@ -126,7 +126,7 @@ object DatabaseMigrationHelper {
126126
}
127127

128128
// Get the CREATE TABLE SQL statement for a specific table
129-
private fun getTableCreateSql(db: SQLiteDatabase, tableName: String): String? {
129+
private fun getTableCreateSql(db: android.database.sqlite.SQLiteDatabase, tableName: String): String? {
130130
val cursor: Cursor = db.rawQuery(
131131
"SELECT sql FROM sqlite_master WHERE type='table' AND name=?",
132132
arrayOf(tableName)

kommunicate/src/main/java/io/kommunicate/database/KmAutoSuggestionDatabase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import android.content.ContentValues;
44
import android.content.Context;
55
import android.database.Cursor;
6-
import net.sqlcipher.database.SQLiteDatabase;
7-
import net.sqlcipher.database.SQLiteStatement;
6+
import net.zetetic.database.sqlcipher.SQLiteDatabase;
7+
import net.zetetic.database.sqlcipher.SQLiteStatement;
88
import android.net.Uri;
99
import androidx.loader.content.CursorLoader;
1010
import androidx.loader.content.Loader;

kommunicate/src/main/java/io/kommunicate/database/KmDatabaseHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.kommunicate.database;
22

33
import android.content.Context;
4-
import net.sqlcipher.database.SQLiteDatabase;
4+
import net.zetetic.database.sqlcipher.SQLiteDatabase;
55
import android.text.TextUtils;
66

77
import io.kommunicate.devkit.api.MobiComKitClientService;

kommunicate/src/main/java/io/kommunicate/devkit/api/conversation/Message.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public void setAttDownloadInProgress(boolean attDownloadInProgress) {
208208
}
209209

210210
public Boolean isRead() {
211-
return read || isTypeOutbox() || getScheduledAt() != null;
211+
return (read != null && read) || isTypeOutbox() || getScheduledAt() != null;
212212
}
213213

214214
public void setRead(Boolean read) {

kommunicate/src/main/java/io/kommunicate/devkit/api/conversation/database/ConversationDatabaseService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import android.content.ContentValues;
44
import android.content.Context;
55
import android.database.Cursor;
6-
import net.sqlcipher.database.SQLiteDatabase;
7-
import net.sqlcipher.database.SQLiteStatement;
6+
import net.zetetic.database.sqlcipher.SQLiteDatabase;
7+
import net.zetetic.database.sqlcipher.SQLiteStatement;
88
import android.text.TextUtils;
99

1010
import io.kommunicate.devkit.database.MobiComDatabaseHelper;

0 commit comments

Comments
 (0)