Skip to content

Commit 2c1ad69

Browse files
author
Arief Nur Putranto
committed
bugfix crash and update library
1 parent 018959a commit 2c1ad69

File tree

10 files changed

+52
-24
lines changed

10 files changed

+52
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Second, you need to add SDK dependencies inside your app .gradle. Then, you need
5454
```
5555
dependencies {
5656
...
57-
implementation 'com.qiscus.sdk:chat-core:1.10.0'
57+
implementation 'com.qiscus.sdk:chat-core:1.10.1'
5858
}
5959
```
6060

build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616

1717
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1818
buildscript {
19+
ext.kotlin_version = '1.5.20'
1920
repositories {
2021
mavenCentral()
2122
google()
2223
maven { url 'https://repo.grails.org/grails/core/' }
2324
}
2425
dependencies {
25-
classpath 'com.android.tools.build:gradle:8.5.0'
26+
classpath 'com.android.tools.build:gradle:8.7.3'
2627
classpath 'com.google.gms:google-services:4.4.2'
28+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2729

2830
// NOTE: Do not place your application dependencies here; they belong
2931
// in the individual module build.gradle files

chat-core/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ android {
2626
defaultConfig {
2727
minSdkVersion minSDKVersion
2828
targetSdkVersion targetSDKVersion
29-
versionCode 1
3029
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
31-
versionName "${chatCoreVersionMajor}.${chatCoreVersionMinor}.${chatCoreVersionPatch}"
3230
}
3331
buildTypes {
3432
release {

chat-core/src/main/java/com/qiscus/sdk/chat/core/data/local/QiscusDataBaseHelper.java

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
import android.database.Cursor;
2121
import android.database.DatabaseUtils;
2222
import android.database.sqlite.SQLiteDatabase;
23+
import android.database.sqlite.SQLiteDiskIOException;
24+
import android.os.Build;
25+
import android.os.Environment;
26+
import android.os.Handler;
27+
import android.os.Looper;
28+
import android.os.StatFs;
29+
import android.widget.Toast;
2330

2431
import com.qiscus.sdk.chat.core.QiscusCore;
2532
import com.qiscus.sdk.chat.core.data.model.QiscusAccount;
@@ -39,15 +46,43 @@
3946

4047
public class QiscusDataBaseHelper implements QiscusDataStore {
4148

42-
protected final SQLiteDatabase sqLiteReadDatabase;
43-
protected final SQLiteDatabase sqLiteWriteDatabase;
49+
protected SQLiteDatabase sqLiteReadDatabase;
50+
protected SQLiteDatabase sqLiteWriteDatabase;
4451

4552
public QiscusDataBaseHelper(Application application) {
4653
QiscusDbOpenHelper qiscusDbOpenHelper = new QiscusDbOpenHelper(application);
47-
sqLiteReadDatabase = qiscusDbOpenHelper.getReadableDatabase();
48-
sqLiteWriteDatabase = qiscusDbOpenHelper.getWritableDatabase();
49-
}
5054

55+
try {
56+
sqLiteReadDatabase = qiscusDbOpenHelper.getReadableDatabase();
57+
sqLiteWriteDatabase = qiscusDbOpenHelper.getWritableDatabase();
58+
}catch (SQLiteDiskIOException e){
59+
60+
File externalStorage = Environment.getExternalStorageDirectory();
61+
StatFs stat = new StatFs(externalStorage.getPath());
62+
long bytesAvailable;
63+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
64+
bytesAvailable = stat.getAvailableBytes();
65+
} else {
66+
bytesAvailable = (long) stat.getBlockSize() * (long) stat.getAvailableBlocks();
67+
}
68+
69+
long minRequiredBytes = 10 * 1024 * 1024;
70+
71+
if (bytesAvailable < minRequiredBytes) {
72+
Toast.makeText(application.getApplicationContext(), "There is not enough storage space. Please clean the storage space.", Toast.LENGTH_LONG).show();
73+
} else {
74+
new Handler(Looper.getMainLooper()).postDelayed(() -> {
75+
try {
76+
sqLiteReadDatabase = qiscusDbOpenHelper.getReadableDatabase();
77+
sqLiteWriteDatabase = qiscusDbOpenHelper.getWritableDatabase();
78+
}catch (SQLiteDiskIOException d){
79+
80+
}
81+
}, 3000);
82+
}
83+
}
84+
85+
}
5186
@Override
5287
public void add(QiscusChatRoom qiscusChatRoom) {
5388
sqLiteWriteDatabase.beginTransactionNonExclusive();

chat-core/src/main/java/com/qiscus/sdk/chat/core/QiscusActivityCallback.java renamed to chat-core/src/main/java/com/qiscus/sdk/chat/core/util/QiscusActivityCallback.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.qiscus.sdk.chat.core;
17+
package com.qiscus.sdk.chat.core.util;
1818

19-
import android.util.Log;
20-
21-
import androidx.annotation.NonNull;
22-
import androidx.lifecycle.DefaultLifecycleObserver;
2319
import androidx.lifecycle.Lifecycle;
2420
import androidx.lifecycle.LifecycleObserver;
25-
import androidx.lifecycle.LifecycleOwner;
2621
import androidx.lifecycle.OnLifecycleEvent;
2722

23+
import com.qiscus.sdk.chat.core.QiscusCore;
2824
import com.qiscus.sdk.chat.core.data.remote.QiscusPusherApi;
29-
import com.qiscus.sdk.chat.core.util.QiscusAndroidUtil;
30-
import com.qiscus.sdk.chat.core.util.QiscusServiceUtil;
3125

3226
import java.util.concurrent.ScheduledFuture;
3327

chat/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ android {
2626
defaultConfig {
2727
minSdkVersion minSDKVersion
2828
targetSdkVersion targetSDKVersion
29-
versionCode 1
3029

3130
}
3231
buildTypes {

dependencies.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ repositories {
3030
ext {
3131

3232
minSDKVersion = 21
33-
targetSDKVersion = 34
34-
compileSDKVersion = 34
33+
targetSDKVersion = 35
34+
compileSDKVersion = 35
3535

3636
versions = [
37-
support : "31.0.0",
37+
support : "34.0.0",
3838
firebaseCore : "21.1.1",
3939
firebaseMessaging: "23.1.2",
4040
okHttp : "4.11.0",

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ Secondly, you need to add SDK dependencies inside your app .gradle. Then, you ne
8080
```
8181
dependencies {
8282
...
83-
implementation 'com.qiscus.sdk:chat-core:1.10.0'
83+
implementation 'com.qiscus.sdk:chat-core:1.10.1'
8484
}
8585
```
8686

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ android.useAndroidX=true
5959

6060
libraryGroupId=com.qiscus.sdk
6161
libraryArtifactId=chat-core
62-
libraryVersion=1.10.0
62+
libraryVersion=1.10.1
6363

6464
libraryGroupIdChat=com.qiscus.sdk
6565
libraryArtifactIdChat=chat
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Tue May 02 22:11:28 WIB 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)