Skip to content

Commit

Permalink
Notification updates (#11)
Browse files Browse the repository at this point in the history
* Add notification update receiver

* Fix bug in call activity intent
  • Loading branch information
jlewis13 authored Oct 16, 2019
1 parent 80c064b commit 921a179
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 16 deletions.
13 changes: 13 additions & 0 deletions app/src/dev/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@
<action android:name="io.forsta.librelay.dev.notifications.REPLY"/>
</intent-filter>
</receiver>
<receiver
android:name="io.forsta.librelay.notifications.NotificationUpdateReceiver"
android:exported="false">
<intent-filter>
<action android:name="io.forsta.librelay.dev.notifications.UPDATE"/>
</intent-filter>
</receiver>
<receiver android:name="io.forsta.librelay.service.DirectoryRefreshListener">
<intent-filter>
<action android:name="io.forsta.librelay.dev.DIRECTORY_REFRESH"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.forsta.relay.receivers;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class NotificationUpdateReceiver extends BroadcastReceiver {
private static final String TAG = io.forsta.librelay.notifications.NotificationUpdateReceiver.class.getSimpleName();


@Override
public void onReceive(Context context, Intent intent) {
Log.w(TAG, "Received notification update");


}
}
6 changes: 3 additions & 3 deletions app/src/prod/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
android:name="io.forsta.relay.receivers.RegistrationReceiver"
android:exported="false">
<intent-filter>
<action android:name="io.forsta.librelay.REGISTRATION_EVENT"/>
<action android:name="io.forsta.librelay.prod.REGISTRATION_EVENT"/>
</intent-filter>
</receiver>
<receiver
android:name="io.forsta.relay.receivers.FirebaseReceiver"
android:exported="false">
<intent-filter>
<action android:name="io.forsta.librelay.FCM_EVENT"/>
<action android:name="io.forsta.librelay.prod.FCM_EVENT"/>
</intent-filter>
</receiver>

<receiver
android:name="io.forsta.relay.receivers.NotificationReplyReceiver"
android:exported="false">
<intent-filter>
<action android:name="io.forsta.librelay.notifications.REPLY"/>
<action android:name="io.forsta.librelay.prod.notifications.REPLY"/>
</intent-filter>
</receiver>
</application>
Expand Down
2 changes: 0 additions & 2 deletions librelay/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@
<service
android:name="io.forsta.librelay.service.RegistrationService"
android:enabled="true"/>
<service android:enabled="true"
android:name="io.forsta.librelay.service.IncomingMessageObserver$ForegroundService"/>
<service
android:name="io.forsta.librelay.service.AccountAuthenticatorService"
android:exported="true">
Expand Down
8 changes: 4 additions & 4 deletions librelay/prod/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="io.forsta.librelay.notifications.CLEAR"/>
<action android:name="io.forsta.librelay.prod.notifications.CLEAR"/>
</intent-filter>
</receiver>
<receiver android:name="io.forsta.librelay.notifications.ReplyReceiver">
<intent-filter>
<action android:name="io.forsta.librelay.notifications.REPLY"/>
<action android:name="io.forsta.librelay.prod.notifications.REPLY"/>
</intent-filter>
</receiver>
<receiver
android:name="io.forsta.librelay.service.RegistrationReceiver"
android:exported="false">
<intent-filter>
<action android:name="io.forsta.librelay.REGISTRATION_EVENT"/>
<action android:name="io.forsta.librelay.prod.REGISTRATION_EVENT"/>
</intent-filter>
</receiver>
<receiver android:name="io.forsta.librelay.service.DirectoryRefreshListener">
<intent-filter>
<action android:name="io.forsta.librelay.DIRECTORY_REFRESH"/>
<action android:name="io.forsta.librelay.prod.DIRECTORY_REFRESH"/>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
Expand Down
1 change: 0 additions & 1 deletion librelay/src/io/forsta/librelay/jobs/PushDecryptJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.forsta.librelay.database.DbFactory;
import io.forsta.librelay.database.MessageDatabase;
import io.forsta.librelay.messaging.MessageFactory;
import io.forsta.librelay.recipients.Recipient;
import io.forsta.librelay.service.ForstaServiceAccountManager;
import io.forsta.librelay.util.InvalidMessagePayloadException;
import io.forsta.librelay.BuildConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

public class MarkReadReceiver extends BroadcastReceiver {

private static final String TAG = MarkReadReceiver.class.getSimpleName();
public static final String CLEAR_ACTION = BuildConfig.APPLICATION_ID + "." + BuildConfig.FLAVOR + ".notifications.CLEAR";
private static final String TAG = MarkReadReceiver.class.getSimpleName();
public static final String CLEAR_ACTION = BuildConfig.APPLICATION_ID + "." + BuildConfig.FLAVOR + ".notifications.CLEAR";
public static final String THREAD_IDS_EXTRA = "thread_ids";

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public static void notifyMessageDeliveryFailed(Context context, long threadId) {
.notify((int)threadId, builder.build());
}

// Main entry point for incoming message notifications.
public static void updateNotification(@NonNull Context context,
long threadId)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.forsta.librelay.notifications;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

import io.forsta.librelay.BuildConfig;

public class NotificationUpdateReceiver extends BroadcastReceiver {
private static final String TAG = NotificationUpdateReceiver.class.getSimpleName();

public static final String UPDATE_ACTION = BuildConfig.APPLICATION_ID + "." + BuildConfig.FLAVOR + ".notifications.UPDATE";
public static final String THREAD_ID = "thread_id";

@Override
public void onReceive(Context context, Intent intent) {
Log.w(TAG, "Notification update received");
long threadId = intent.getLongExtra(THREAD_ID, -1);
if (threadId > 0) {
MessageNotifier.updateNotification(context, threadId);
} else {
MessageNotifier.updateNotification(context);
}
}

public static Intent getUpdateIntent(Context context, long threadId) {
Intent intent = new Intent(UPDATE_ACTION);
intent.putExtra(ReplyReceiver.THREAD_ID, threadId);
intent.setPackage(context.getPackageName());
return intent;
}

}
11 changes: 10 additions & 1 deletion librelay/src/io/forsta/librelay/notifications/ReplyReceiver.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.forsta.librelay.notifications;

import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
Expand All @@ -10,11 +11,19 @@
public class ReplyReceiver extends BroadcastReceiver {
private static final String TAG = ReplyReceiver.class.getSimpleName();

public static final String REPLY_ACTION = BuildConfig.APPLICATION_ID + "." + BuildConfig.FLAVOR + ".notifications.REPLY";
public static final String REPLY_ACTION = BuildConfig.APPLICATION_ID + "." + BuildConfig.FLAVOR + ".notifications.REPLY";
public static final String THREAD_ID = "thread_id";

@Override
public void onReceive(Context context, Intent intent) {
Log.w(TAG, "onReceive");
}


public static PendingIntent getReplyIntent(Context context, long threadId) {
Intent intent = new Intent(ReplyReceiver.REPLY_ACTION);
intent.putExtra(ReplyReceiver.THREAD_ID, threadId);
intent.setPackage(context.getPackageName());
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1473,8 +1473,7 @@ public Boolean call() throws Exception {
}

private void startCallCardActivity() {
Intent activityIntent = new Intent();
activityIntent.setClass(this, WebRtcCallActivity.class);
Intent activityIntent = new Intent(this, WebRtcCallActivity.class);
activityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(activityIntent);
}
Expand Down

0 comments on commit 921a179

Please sign in to comment.