Skip to content

Commit 5ce0aee

Browse files
authored
Merge pull request #810 from redsolution/develop
Version 2.2.1 Beta Release
2 parents 2e26725 + a4d0b20 commit 5ce0aee

File tree

6 files changed

+69
-9
lines changed

6 files changed

+69
-9
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ If you want to support Xabber development you can buy [Xabber VIP](https://play.
3333

3434
[![Donate with PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=G9AYTUSXCWRVL)
3535

36+
[![Patreon](https://c5.patreon.com/external/logo/become_a_patron_button.png)](https://www.patreon.com/xabber)
37+
3638
## Feedback
3739

3840
info [at] xabber.com

xabber/build.gradle

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
defaultConfig {
1111
minSdkVersion 15
1212
targetSdkVersion 27
13-
versionCode 467
14-
versionName '2.2.1(467)'
13+
versionCode 468
14+
versionName '2.2.1(468)'
1515
}
1616

1717
lintOptions {
@@ -193,6 +193,15 @@ dependencies {
193193
}
194194

195195
implementation group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.58'
196+
197+
// leak canary
198+
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.4'
199+
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.4'
200+
201+
// block canary
202+
debugImplementation 'com.github.markzhai:blockcanary-android:1.5.0'
203+
releaseCompile 'com.github.markzhai:blockcanary-no-op:1.5.0'
204+
196205
}
197206
apply plugin: 'com.google.gms.google-services'
198207

xabber/src/main/java/com/xabber/android/data/Application.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717
import android.app.Activity;
1818
import android.content.Context;
1919
import android.os.Handler;
20+
import android.os.StrictMode;
2021
import android.support.annotation.NonNull;
2122
import android.support.multidex.MultiDex;
2223

2324
import com.crashlytics.android.Crashlytics;
2425
import com.crashlytics.android.core.CrashlyticsCore;
2526
import com.frogermcs.androiddevmetrics.AndroidDevMetrics;
27+
import com.github.moduth.blockcanary.BlockCanary;
28+
import com.squareup.leakcanary.LeakCanary;
2629
import com.xabber.android.BuildConfig;
2730
import com.xabber.android.R;
2831
import com.xabber.android.data.account.AccountManager;
@@ -57,8 +60,8 @@
5760
import com.xabber.android.data.roster.RosterManager;
5861
import com.xabber.android.data.xaccount.XabberAccountManager;
5962
import com.xabber.android.service.XabberService;
63+
import com.xabber.android.utils.AppBlockCanaryContext;
6064

61-
import io.fabric.sdk.android.Fabric;
6265
import org.jivesoftware.smack.provider.ProviderFileLoader;
6366
import org.jivesoftware.smack.provider.ProviderManager;
6467

@@ -74,6 +77,8 @@
7477
import java.util.concurrent.Future;
7578
import java.util.concurrent.ThreadFactory;
7679

80+
import io.fabric.sdk.android.Fabric;
81+
7782
/**
7883
* Base entry point.
7984
*
@@ -304,6 +309,30 @@ public boolean isClosing() {
304309
@Override
305310
public void onCreate() {
306311
super.onCreate();
312+
313+
if (BuildConfig.DEBUG) {
314+
/** Leak Canary */
315+
if (LeakCanary.isInAnalyzerProcess(this)) {
316+
// This process is dedicated to LeakCanary for heap analysis.
317+
// You should not init your app in this process.
318+
return;
319+
}
320+
LeakCanary.install(this);
321+
322+
/** Block Canary */
323+
BlockCanary.install(this, new AppBlockCanaryContext()).start();
324+
325+
/** Android Dev Metrics */
326+
AndroidDevMetrics.initWith(this);
327+
328+
/** Strict Mode */
329+
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
330+
.detectAll()
331+
.penaltyLog()
332+
.build());
333+
}
334+
335+
/** Crashlytics */
307336
// Set up Crashlytics, disabled for debug builds
308337
Crashlytics crashlyticsKit = new Crashlytics.Builder()
309338
.core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
@@ -314,10 +343,6 @@ public void onCreate() {
314343
Fabric.with(this, crashlyticsKit);
315344
}
316345

317-
if (BuildConfig.DEBUG) {
318-
AndroidDevMetrics.initWith(this);
319-
}
320-
321346
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
322347

323348
addManagers();

xabber/src/main/java/com/xabber/android/data/database/sqlite/PhraseTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public long write(Long id, String value, String user, String group,
133133
return id;
134134
}
135135

136-
void remove(long id) {
136+
public void remove(long id) {
137137
SQLiteDatabase db = databaseManager.getWritableDatabase();
138138
db.delete(NAME, Fields._ID + " = ?",
139139
new String[]{String.valueOf(id)});

xabber/src/main/java/com/xabber/android/data/message/phrase/PhraseManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,11 @@ public void updateOrCreatePhrase(Phrase phrase, String value, String user,
129129
* @param index
130130
*/
131131
public void removePhrase(int index) {
132-
phrases.remove(getPhrase(index));
132+
Phrase phrase = getPhrase(index);
133+
if (phrase != null) {
134+
phrases.remove(phrase); // remove from the local list
135+
PhraseTable.getInstance().remove(phrase.getId()); // remove from database
136+
}
133137
}
134138

135139
private void writePhrase(final Phrase phrase, final String value,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.xabber.android.utils;
2+
3+
import com.github.moduth.blockcanary.BlockCanaryContext;
4+
import com.xabber.android.BuildConfig;
5+
6+
7+
/**
8+
* Configuration class. Used in Block Canary - ui-block detection library for Android
9+
*/
10+
11+
public class AppBlockCanaryContext extends BlockCanaryContext {
12+
13+
public String provideQualifier() {
14+
return BuildConfig.VERSION_NAME;
15+
}
16+
17+
public int provideBlockThreshold() {
18+
return 1000;
19+
}
20+
}

0 commit comments

Comments
 (0)