mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-23 20:55:02 +01:00
parent
323d9e16b1
commit
400c41e731
app/src/main/java/com/nextcloud/talk
@ -37,6 +37,7 @@ import android.os.Vibrator;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
import androidx.core.app.NotificationManagerCompat;
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
@ -44,6 +45,7 @@ import androidx.work.Data;
|
|||||||
import androidx.work.Worker;
|
import androidx.work.Worker;
|
||||||
import androidx.work.WorkerParameters;
|
import androidx.work.WorkerParameters;
|
||||||
import autodagger.AutoInjector;
|
import autodagger.AutoInjector;
|
||||||
|
|
||||||
import com.bluelinelabs.logansquare.LoganSquare;
|
import com.bluelinelabs.logansquare.LoganSquare;
|
||||||
import com.nextcloud.talk.R;
|
import com.nextcloud.talk.R;
|
||||||
import com.nextcloud.talk.activities.MagicCallActivity;
|
import com.nextcloud.talk.activities.MagicCallActivity;
|
||||||
@ -67,16 +69,20 @@ import com.nextcloud.talk.utils.bundle.BundleKeys;
|
|||||||
import com.nextcloud.talk.utils.database.arbitrarystorage.ArbitraryStorageUtils;
|
import com.nextcloud.talk.utils.database.arbitrarystorage.ArbitraryStorageUtils;
|
||||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
|
import com.nextcloud.talk.utils.singletons.ApplicationWideCurrentRoomHolder;
|
||||||
|
|
||||||
import io.reactivex.Observer;
|
import io.reactivex.Observer;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
import okhttp3.JavaNetCookieJar;
|
import okhttp3.JavaNetCookieJar;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.CookieManager;
|
import java.net.CookieManager;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
@ -424,69 +430,75 @@ public class NotificationWorker extends Worker {
|
|||||||
decryptedPushMessage = LoganSquare.parse(new String(decryptedSubject),
|
decryptedPushMessage = LoganSquare.parse(new String(decryptedSubject),
|
||||||
DecryptedPushMessage.class);
|
DecryptedPushMessage.class);
|
||||||
|
|
||||||
credentials = ApiUtils.getCredentials(signatureVerification.getUserEntity().getUsername(),
|
if (decryptedPushMessage.isDelete()) {
|
||||||
signatureVerification.getUserEntity().getToken());
|
NotificationUtils.cancelExistingNotificationWithId(context, signatureVerification.getUserEntity(), decryptedPushMessage.getNotificationId());
|
||||||
|
} else if (decryptedPushMessage.isDeleteAll()) {
|
||||||
|
NotificationUtils.cancelAllNotificationsForAccount(context, signatureVerification.getUserEntity());
|
||||||
|
} else {
|
||||||
|
credentials = ApiUtils.getCredentials(signatureVerification.getUserEntity().getUsername(),
|
||||||
|
signatureVerification.getUserEntity().getToken());
|
||||||
|
|
||||||
ncApi = retrofit.newBuilder().client(okHttpClient.newBuilder().cookieJar(new
|
ncApi = retrofit.newBuilder().client(okHttpClient.newBuilder().cookieJar(new
|
||||||
JavaNetCookieJar(new CookieManager())).build()).build().create(NcApi.class);
|
JavaNetCookieJar(new CookieManager())).build()).build().create(NcApi.class);
|
||||||
|
|
||||||
boolean hasChatSupport = signatureVerification.getUserEntity().
|
boolean hasChatSupport = signatureVerification.getUserEntity().
|
||||||
hasSpreedCapabilityWithName("chat-v2");
|
hasSpreedCapabilityWithName("chat-v2");
|
||||||
|
|
||||||
boolean shouldShowNotification = decryptedPushMessage.getApp().equals("spreed");
|
boolean shouldShowNotification = decryptedPushMessage.getApp().equals("spreed");
|
||||||
|
|
||||||
if (shouldShowNotification) {
|
if (shouldShowNotification) {
|
||||||
Intent intent;
|
Intent intent;
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
|
|
||||||
|
|
||||||
boolean startACall = decryptedPushMessage.getType().equals("call") || !hasChatSupport;
|
boolean startACall = decryptedPushMessage.getType().equals("call") || !hasChatSupport;
|
||||||
if (startACall) {
|
if (startACall) {
|
||||||
intent = new Intent(context, MagicCallActivity.class);
|
intent = new Intent(context, MagicCallActivity.class);
|
||||||
} else {
|
} else {
|
||||||
intent = new Intent(context, MainActivity.class);
|
intent = new Intent(context, MainActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
|
||||||
|
if (!signatureVerification.getUserEntity().hasSpreedCapabilityWithName
|
||||||
|
("no-ping")) {
|
||||||
|
bundle.putString(BundleKeys.KEY_ROOM_ID, decryptedPushMessage.getId());
|
||||||
|
} else {
|
||||||
|
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, decryptedPushMessage.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, signatureVerification.getUserEntity());
|
||||||
|
|
||||||
|
bundle.putBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL,
|
||||||
|
startACall);
|
||||||
|
|
||||||
|
intent.putExtras(bundle);
|
||||||
|
|
||||||
|
switch (decryptedPushMessage.getType()) {
|
||||||
|
case "call":
|
||||||
|
if (!bundle.containsKey(BundleKeys.KEY_ROOM_TOKEN)) {
|
||||||
|
context.startActivity(intent);
|
||||||
|
} else {
|
||||||
|
showNotificationForCallWithNoPing(intent);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "room":
|
||||||
|
if (bundle.containsKey(BundleKeys.KEY_ROOM_TOKEN)) {
|
||||||
|
showNotificationForCallWithNoPing(intent);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "chat":
|
||||||
|
if (decryptedPushMessage.getNotificationId() != Long.MIN_VALUE) {
|
||||||
|
showMessageNotificationWithObjectData(intent);
|
||||||
|
} else {
|
||||||
|
showNotification(intent);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
||||||
|
|
||||||
if (!signatureVerification.getUserEntity().hasSpreedCapabilityWithName
|
|
||||||
("no-ping")) {
|
|
||||||
bundle.putString(BundleKeys.KEY_ROOM_ID, decryptedPushMessage.getId());
|
|
||||||
} else {
|
|
||||||
bundle.putString(BundleKeys.KEY_ROOM_TOKEN, decryptedPushMessage.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, signatureVerification.getUserEntity());
|
|
||||||
|
|
||||||
bundle.putBoolean(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL,
|
|
||||||
startACall);
|
|
||||||
|
|
||||||
intent.putExtras(bundle);
|
|
||||||
|
|
||||||
switch (decryptedPushMessage.getType()) {
|
|
||||||
case "call":
|
|
||||||
if (!bundle.containsKey(BundleKeys.KEY_ROOM_TOKEN)) {
|
|
||||||
context.startActivity(intent);
|
|
||||||
} else {
|
|
||||||
showNotificationForCallWithNoPing(intent);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "room":
|
|
||||||
if (bundle.containsKey(BundleKeys.KEY_ROOM_TOKEN)) {
|
|
||||||
showNotificationForCallWithNoPing(intent);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "chat":
|
|
||||||
if (decryptedPushMessage.getNotificationId() != Long.MIN_VALUE) {
|
|
||||||
showMessageNotificationWithObjectData(intent);
|
|
||||||
} else {
|
|
||||||
showNotification(intent);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NoSuchAlgorithmException e1) {
|
} catch (NoSuchAlgorithmException e1) {
|
||||||
|
@ -45,6 +45,12 @@ public class DecryptedPushMessage {
|
|||||||
@JsonField(name = "nid")
|
@JsonField(name = "nid")
|
||||||
long notificationId;
|
long notificationId;
|
||||||
|
|
||||||
|
@JsonField(name = "delete")
|
||||||
|
boolean delete;
|
||||||
|
|
||||||
|
@JsonField(name = "delete-all")
|
||||||
|
boolean deleteAll;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
String text;
|
String text;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user