Skip to content

Commit e796968

Browse files
cody-signalgreyson-signal
authored andcommitted
Add new notification system.
1 parent c8f17e2 commit e796968

23 files changed

+2030
-56
lines changed

.editorconfig

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
root = true
2+
3+
[*.kt]
4+
indent_size = 2

app/build.gradle

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ import org.signal.signing.ApkSignerUtil
33
import java.security.MessageDigest
44

55
apply plugin: 'com.android.application'
6+
apply plugin: 'kotlin-android'
7+
apply plugin: 'kotlin-kapt'
68
apply plugin: 'com.google.protobuf'
79
apply plugin: 'androidx.navigation.safeargs'
810
apply plugin: 'witness'
11+
apply plugin: 'org.jlleitschuh.gradle.ktlint'
912
apply from: 'translations.gradle'
1013
apply from: 'witness-verifications.gradle'
1114

@@ -388,8 +391,8 @@ dependencies {
388391
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5'
389392
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
390393
implementation 'com.github.bumptech.glide:glide:4.11.0'
391-
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
392-
annotationProcessor 'androidx.annotation:annotation:1.1.0'
394+
kapt 'com.github.bumptech.glide:compiler:4.11.0'
395+
kapt 'androidx.annotation:annotation:1.1.0'
393396
implementation 'com.makeramen:roundedimageview:2.1.0'
394397
implementation 'com.pnikosis:materialish-progress:1.5'
395398
implementation 'org.greenrobot:eventbus:3.0.0'
@@ -449,6 +452,8 @@ dependencies {
449452

450453
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
451454
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
455+
456+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
452457
}
453458

454459
dependencyVerification {

app/src/main/java/org/thoughtcrime/securesms/database/MmsSmsDatabase.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import java.util.Collection;
4141
import java.util.Collections;
4242
import java.util.HashSet;
43-
import java.util.LinkedList;
4443
import java.util.List;
4544
import java.util.Set;
4645

@@ -744,11 +743,11 @@ private Cursor queryTables(String[] projection, String selection, String order,
744743
return db.rawQuery(query, null);
745744
}
746745

747-
public Reader readerFor(@NonNull Cursor cursor) {
746+
public static Reader readerFor(@NonNull Cursor cursor) {
748747
return new Reader(cursor);
749748
}
750749

751-
public class Reader implements Closeable {
750+
public static class Reader implements Closeable {
752751

753752
private final Cursor cursor;
754753
private SmsDatabase.Reader smsReader;

app/src/main/java/org/thoughtcrime/securesms/dependencies/ApplicationDependencyProvider.java

+9-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.thoughtcrime.securesms.net.PipeConnectivityListener;
3737
import org.thoughtcrime.securesms.notifications.DefaultMessageNotifier;
3838
import org.thoughtcrime.securesms.notifications.MessageNotifier;
39+
import org.thoughtcrime.securesms.notifications.v2.MessageNotifierV2;
3940
import org.thoughtcrime.securesms.notifications.OptimizedMessageNotifier;
4041
import org.thoughtcrime.securesms.payments.MobileCoinConfig;
4142
import org.thoughtcrime.securesms.payments.Payments;
@@ -185,7 +186,14 @@ public ApplicationDependencyProvider(@NonNull Application context) {
185186

186187
@Override
187188
public @NonNull MessageNotifier provideMessageNotifier() {
188-
return new OptimizedMessageNotifier(new DefaultMessageNotifier());
189+
MessageNotifier inner;
190+
if (FeatureFlags.useNewNotificationSystem()) {
191+
inner = new MessageNotifierV2();
192+
} else {
193+
inner = new DefaultMessageNotifier();
194+
}
195+
196+
return new OptimizedMessageNotifier(inner);
189197
}
190198

191199
@Override

app/src/main/java/org/thoughtcrime/securesms/mms/Slide.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import android.content.Context;
2020
import android.content.res.Resources.Theme;
2121
import android.net.Uri;
22+
import android.os.Build;
2223

2324
import androidx.annotation.DrawableRes;
2425
import androidx.annotation.NonNull;
@@ -56,7 +57,11 @@ public Uri getUri() {
5657
}
5758

5859
public @Nullable Uri getPublicUri() {
59-
return attachment.getPublicUri();
60+
if (Build.VERSION.SDK_INT >= 28) {
61+
return attachment.getPublicUri();
62+
} else {
63+
return attachment.getUri();
64+
}
6065
}
6166

6267
@NonNull

app/src/main/java/org/thoughtcrime/securesms/notifications/AbstractNotificationBuilder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public abstract class AbstractNotificationBuilder extends NotificationCompat.Bui
2424
@SuppressWarnings("unused")
2525
private static final String TAG = Log.tag(AbstractNotificationBuilder.class);
2626

27-
private static final int MAX_DISPLAY_LENGTH = 500;
27+
public static final int MAX_DISPLAY_LENGTH = 500;
2828

2929
protected Context context;
3030
protected NotificationPrivacyPreference privacy;

app/src/main/java/org/thoughtcrime/securesms/notifications/DefaultMessageNotifier.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ public class DefaultMessageNotifier implements MessageNotifier {
102102
public static final String NOTIFICATION_GROUP = "messages";
103103

104104
private static final String EMOJI_REPLACEMENT_STRING = "__EMOJI__";
105-
private static final long MIN_AUDIBLE_PERIOD_MILLIS = TimeUnit.SECONDS.toMillis(2);
106-
private static final long DESKTOP_ACTIVITY_PERIOD = TimeUnit.MINUTES.toMillis(1);
105+
public static final long MIN_AUDIBLE_PERIOD_MILLIS = TimeUnit.SECONDS.toMillis(2);
106+
public static final long DESKTOP_ACTIVITY_PERIOD = TimeUnit.MINUTES.toMillis(1);
107107

108108
private volatile long visibleThread = -1;
109109
private volatile long lastDesktopActivityTimestamp = -1;

app/src/main/java/org/thoughtcrime/securesms/notifications/NotificationCancellationHelper.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ private NotificationCancellationHelper() {}
4343
* We utilize our wrapped cancellation methods and a counter to make sure that we do not lose
4444
* bubble notifications that do not have unread messages in them.
4545
*/
46-
static void cancelAllMessageNotifications(@NonNull Context context) {
46+
public static void cancelAllMessageNotifications(@NonNull Context context) {
4747
if (Build.VERSION.SDK_INT >= 23) {
4848
try {
4949
NotificationManager notifications = ServiceUtil.getNotificationManager(context);

app/src/main/java/org/thoughtcrime/securesms/notifications/PendingMessageNotificationBuilder.java

-40
This file was deleted.

0 commit comments

Comments
 (0)