mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Do some further work on notifications
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
621468b81f
commit
3480f4b593
@ -66,5 +66,10 @@
|
|||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:launchMode="singleTask"/>
|
android:launchMode="singleTask"/>
|
||||||
|
|
||||||
|
<receiver android:name=".receivers.PackageReplacedReceiver">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -102,7 +102,6 @@ import org.webrtc.RendererCommon;
|
|||||||
import org.webrtc.SessionDescription;
|
import org.webrtc.SessionDescription;
|
||||||
import org.webrtc.SurfaceViewRenderer;
|
import org.webrtc.SurfaceViewRenderer;
|
||||||
import org.webrtc.VideoCapturer;
|
import org.webrtc.VideoCapturer;
|
||||||
import org.webrtc.VideoRenderer;
|
|
||||||
import org.webrtc.VideoSource;
|
import org.webrtc.VideoSource;
|
||||||
import org.webrtc.VideoTrack;
|
import org.webrtc.VideoTrack;
|
||||||
|
|
||||||
@ -165,6 +164,7 @@ public class CallController extends BaseController {
|
|||||||
FlipView cameraControlButton;
|
FlipView cameraControlButton;
|
||||||
@BindView(R.id.call_control_switch_camera)
|
@BindView(R.id.call_control_switch_camera)
|
||||||
FlipView cameraSwitchButton;
|
FlipView cameraSwitchButton;
|
||||||
|
|
||||||
@BindView(R.id.connectingRelativeLayoutView)
|
@BindView(R.id.connectingRelativeLayoutView)
|
||||||
RelativeLayout connectingView;
|
RelativeLayout connectingView;
|
||||||
|
|
||||||
@ -182,23 +182,22 @@ public class CallController extends BaseController {
|
|||||||
@Inject
|
@Inject
|
||||||
Cache cache;
|
Cache cache;
|
||||||
|
|
||||||
PeerConnectionFactory peerConnectionFactory;
|
private PeerConnectionFactory peerConnectionFactory;
|
||||||
MediaConstraints audioConstraints;
|
private MediaConstraints audioConstraints;
|
||||||
MediaConstraints videoConstraints;
|
private MediaConstraints videoConstraints;
|
||||||
MediaConstraints sdpConstraints;
|
private MediaConstraints sdpConstraints;
|
||||||
MagicAudioManager audioManager;
|
private MagicAudioManager audioManager;
|
||||||
VideoSource videoSource;
|
private VideoSource videoSource;
|
||||||
VideoTrack localVideoTrack;
|
private VideoTrack localVideoTrack;
|
||||||
AudioSource audioSource;
|
private AudioSource audioSource;
|
||||||
AudioTrack localAudioTrack;
|
private AudioTrack localAudioTrack;
|
||||||
VideoCapturer videoCapturer;
|
private VideoCapturer videoCapturer;
|
||||||
VideoRenderer localRenderer;
|
private EglBase rootEglBase;
|
||||||
EglBase rootEglBase;
|
private boolean leavingCall = false;
|
||||||
boolean leavingCall = false;
|
private boolean inCall = false;
|
||||||
boolean inCall = false;
|
private Disposable signalingDisposable;
|
||||||
Disposable signalingDisposable;
|
private Disposable pingDisposable;
|
||||||
Disposable pingDisposable;
|
private List<PeerConnection.IceServer> iceServers;
|
||||||
List<PeerConnection.IceServer> iceServers;
|
|
||||||
private CameraEnumerator cameraEnumerator;
|
private CameraEnumerator cameraEnumerator;
|
||||||
private String roomToken;
|
private String roomToken;
|
||||||
private UserEntity userEntity;
|
private UserEntity userEntity;
|
||||||
@ -252,8 +251,7 @@ public class CallController extends BaseController {
|
|||||||
baseUrl = userEntity.getBaseUrl();
|
baseUrl = userEntity.getBaseUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
isFromNotification = args.containsKey(BundleKeys.KEY_FROM_NOTIFICATION_START_CALL) && TextUtils.isEmpty
|
isFromNotification = TextUtils.isEmpty(roomToken);
|
||||||
(roomToken);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -636,12 +634,14 @@ public class CallController extends BaseController {
|
|||||||
R.string.nc_microphone_permission_permanently_denied,
|
R.string.nc_microphone_permission_permanently_denied,
|
||||||
R.string.nc_permissions_settings, (AppCompatActivity) getActivity());
|
R.string.nc_permissions_settings, (AppCompatActivity) getActivity());
|
||||||
} else {
|
} else {
|
||||||
|
if (getActivity() != null) {
|
||||||
EffortlessPermissions.requestPermissions(getActivity(), R.string.nc_permissions_audio,
|
EffortlessPermissions.requestPermissions(getActivity(), R.string.nc_permissions_audio,
|
||||||
R.string.nc_proceed, R.string.nc_empty, 100, PERMISSIONS_MICROPHONE);
|
R.string.nc_proceed, R.string.nc_empty, 100, PERMISSIONS_MICROPHONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@OnClick(R.id.call_control_hangup)
|
@OnClick(R.id.callControlHangupView)
|
||||||
public void onHangupClick() {
|
public void onHangupClick() {
|
||||||
if (inCall) {
|
if (inCall) {
|
||||||
hangup(false);
|
hangup(false);
|
||||||
@ -652,7 +652,7 @@ public class CallController extends BaseController {
|
|||||||
|
|
||||||
@OnClick(R.id.call_control_camera)
|
@OnClick(R.id.call_control_camera)
|
||||||
public void onCameraClick() {
|
public void onCameraClick() {
|
||||||
if (EffortlessPermissions.hasPermissions(getActivity(), PERMISSIONS_CAMERA)) {
|
if (getActivity() != null && EffortlessPermissions.hasPermissions(getActivity(), PERMISSIONS_CAMERA)) {
|
||||||
videoOn = !videoOn;
|
videoOn = !videoOn;
|
||||||
|
|
||||||
if (videoOn) {
|
if (videoOn) {
|
||||||
@ -824,7 +824,7 @@ public class CallController extends BaseController {
|
|||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startPullingSignalingMessages() {
|
private void startPullingSignalingMessages() {
|
||||||
leavingCall = false;
|
leavingCall = false;
|
||||||
|
|
||||||
ncApi.getSignalingSettings(credentials, ApiUtils.getUrlForSignalingSettings(baseUrl))
|
ncApi.getSignalingSettings(credentials, ApiUtils.getUrlForSignalingSettings(baseUrl))
|
||||||
@ -1055,6 +1055,7 @@ public class CallController extends BaseController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e) {
|
public void onError(Throwable e) {
|
||||||
|
Log.d("MARIO", e.getLocalizedMessage());
|
||||||
dispose(signalingDisposable);
|
dispose(signalingDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1396,7 +1397,7 @@ public class CallController extends BaseController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeMediaStream(String sessionId) {
|
private void removeMediaStream(String sessionId) {
|
||||||
if (remoteRenderersLayout.getChildCount() > 0) {
|
if (remoteRenderersLayout != null && remoteRenderersLayout.getChildCount() > 0) {
|
||||||
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
|
RelativeLayout relativeLayout = remoteRenderersLayout.findViewWithTag(sessionId);
|
||||||
if (relativeLayout != null) {
|
if (relativeLayout != null) {
|
||||||
SurfaceViewRenderer surfaceViewRenderer = relativeLayout.findViewById(R.id.surface_view);
|
SurfaceViewRenderer surfaceViewRenderer = relativeLayout.findViewById(R.id.surface_view);
|
||||||
|
@ -126,16 +126,16 @@ public class CallNotificationController extends BaseController {
|
|||||||
@OnClick(R.id.callAnswerCameraView)
|
@OnClick(R.id.callAnswerCameraView)
|
||||||
void answerWithCamera() {
|
void answerWithCamera() {
|
||||||
originalBundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false);
|
originalBundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, false);
|
||||||
setBackstackAndProceed();
|
proceedToCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.callAnswerVoiceOnlyView)
|
@OnClick(R.id.callAnswerVoiceOnlyView)
|
||||||
void answerVoiceOnly() {
|
void answerVoiceOnly() {
|
||||||
originalBundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true);
|
originalBundle.putBoolean(BundleKeys.KEY_CALL_VOICE_ONLY, true);
|
||||||
setBackstackAndProceed();
|
proceedToCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBackstackAndProceed() {
|
private void proceedToCall() {
|
||||||
originalBundle.putString(BundleKeys.KEY_ROOM_TOKEN, currentRoom.getToken());
|
originalBundle.putString(BundleKeys.KEY_ROOM_TOKEN, currentRoom.getToken());
|
||||||
|
|
||||||
getRouter().setRoot(RouterTransaction.with(new CallController(originalBundle))
|
getRouter().setRoot(RouterTransaction.with(new CallController(originalBundle))
|
||||||
|
@ -21,12 +21,16 @@
|
|||||||
package com.nextcloud.talk.jobs;
|
package com.nextcloud.talk.jobs;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.bluelinelabs.logansquare.LoganSquare;
|
import com.bluelinelabs.logansquare.LoganSquare;
|
||||||
import com.evernote.android.job.Job;
|
import com.evernote.android.job.Job;
|
||||||
|
import com.nextcloud.talk.R;
|
||||||
import com.nextcloud.talk.api.NcApi;
|
import com.nextcloud.talk.api.NcApi;
|
||||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||||
import com.nextcloud.talk.models.database.UserEntity;
|
import com.nextcloud.talk.models.database.UserEntity;
|
||||||
@ -38,6 +42,7 @@ import com.nextcloud.talk.utils.database.user.UserUtils;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.CookieManager;
|
import java.net.CookieManager;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@ -113,6 +118,21 @@ public class AccountRemovalJob extends Job {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(Void aVoid) {
|
public void onNext(Void aVoid) {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
String groupName = String.format(getContext().getResources().getString(R.string
|
||||||
|
.nc_notification_channel), userEntity.getUserId(), userEntity.getBaseUrl());
|
||||||
|
CRC32 crc32 = new CRC32();
|
||||||
|
crc32.update(groupName.getBytes());
|
||||||
|
NotificationManager notificationManager =
|
||||||
|
(NotificationManager) getContext().getSystemService(Context
|
||||||
|
.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
if (notificationManager != null) {
|
||||||
|
notificationManager.deleteNotificationChannelGroup(Long
|
||||||
|
.toString(crc32.getValue()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
userUtils.deleteUser(userEntity.getId()).subscribe(new
|
userUtils.deleteUser(userEntity.getId()).subscribe(new
|
||||||
CompletableObserver() {
|
CompletableObserver() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,7 +26,10 @@ import android.app.PendingIntent;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@ -44,6 +47,7 @@ import com.nextcloud.talk.models.RingtoneSettings;
|
|||||||
import com.nextcloud.talk.models.SignatureVerification;
|
import com.nextcloud.talk.models.SignatureVerification;
|
||||||
import com.nextcloud.talk.models.json.push.DecryptedPushMessage;
|
import com.nextcloud.talk.models.json.push.DecryptedPushMessage;
|
||||||
import com.nextcloud.talk.utils.ApplicationWideCurrentRoomHolder;
|
import com.nextcloud.talk.utils.ApplicationWideCurrentRoomHolder;
|
||||||
|
import com.nextcloud.talk.utils.NotificationUtils;
|
||||||
import com.nextcloud.talk.utils.PushUtils;
|
import com.nextcloud.talk.utils.PushUtils;
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||||
@ -55,6 +59,8 @@ import java.io.IOException;
|
|||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.PrivateKey;
|
import java.security.PrivateKey;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.zip.CRC32;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.NoSuchPaddingException;
|
import javax.crypto.NoSuchPaddingException;
|
||||||
@ -110,10 +116,11 @@ public class NotificationJob extends Job {
|
|||||||
.getInstance().getUserInRoom());
|
.getInstance().getUserInRoom());
|
||||||
|
|
||||||
boolean shouldShowNotification = decryptedPushMessage.getApp().equals("spreed") &&
|
boolean shouldShowNotification = decryptedPushMessage.getApp().equals("spreed") &&
|
||||||
|
!decryptedPushMessage.getType().equals("room") &&
|
||||||
(!isInTheSameRoomAsNotification || decryptedPushMessage.getType().equals("call"));
|
(!isInTheSameRoomAsNotification || decryptedPushMessage.getType().equals("call"));
|
||||||
|
|
||||||
if (shouldShowNotification) {
|
if (shouldShowNotification) {
|
||||||
int smallIcon;
|
int smallIcon = 0;
|
||||||
Bitmap largeIcon;
|
Bitmap largeIcon;
|
||||||
String category = "";
|
String category = "";
|
||||||
int priority = Notification.PRIORITY_HIGH;
|
int priority = Notification.PRIORITY_HIGH;
|
||||||
@ -152,8 +159,7 @@ public class NotificationJob extends Job {
|
|||||||
getContext().startActivity(intent);
|
getContext().startActivity(intent);
|
||||||
break;
|
break;
|
||||||
case "room":
|
case "room":
|
||||||
smallIcon = R.drawable.ic_notifications_white_24dp;
|
// do absolutely nothing, we won't even come to this point
|
||||||
category = Notification.CATEGORY_CALL;
|
|
||||||
break;
|
break;
|
||||||
case "chat":
|
case "chat":
|
||||||
ringtonePreferencesString = appPreferences.getMessageRingtoneUri();
|
ringtonePreferencesString = appPreferences.getMessageRingtoneUri();
|
||||||
@ -177,7 +183,8 @@ public class NotificationJob extends Job {
|
|||||||
smallIcon = R.drawable.ic_logo;
|
smallIcon = R.drawable.ic_logo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*largeIcon = BitmapFactory.decodeResource(context.getResources(), smallIcon);
|
if (decryptedPushMessage.getType().equals("chat")) {
|
||||||
|
largeIcon = BitmapFactory.decodeResource(context.getResources(), smallIcon);
|
||||||
CRC32 crc32 = new CRC32();
|
CRC32 crc32 = new CRC32();
|
||||||
|
|
||||||
Notification.Builder notificationBuilder = new Notification.Builder(context)
|
Notification.Builder notificationBuilder = new Notification.Builder(context)
|
||||||
@ -189,7 +196,7 @@ public class NotificationJob extends Job {
|
|||||||
.setShowWhen(true)
|
.setShowWhen(true)
|
||||||
.setSubText(signatureVerification.getUserEntity().getDisplayName())
|
.setSubText(signatureVerification.getUserEntity().getDisplayName())
|
||||||
.setContentTitle(decryptedPushMessage.getSubject())
|
.setContentTitle(decryptedPushMessage.getSubject())
|
||||||
.setFullScreenIntent(pendingIntent, true)
|
.setContentIntent(pendingIntent)
|
||||||
.setAutoCancel(true);
|
.setAutoCancel(true);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 23) {
|
if (Build.VERSION.SDK_INT >= 23) {
|
||||||
@ -202,35 +209,20 @@ public class NotificationJob extends Job {
|
|||||||
|
|
||||||
String groupName = String.format(context.getResources().getString(R.string
|
String groupName = String.format(context.getResources().getString(R.string
|
||||||
.nc_notification_channel), signatureVerification.getUserEntity()
|
.nc_notification_channel), signatureVerification.getUserEntity()
|
||||||
.getDisplayName(), signatureVerification.getUserEntity().getBaseUrl());
|
.getUserId(), signatureVerification.getUserEntity().getBaseUrl());
|
||||||
crc32.update(groupName.getBytes());
|
crc32.update(groupName.getBytes());
|
||||||
|
|
||||||
NotificationUtils.createNotificationChannelGroup(notificationManager,
|
NotificationUtils.createNotificationChannelGroup(notificationManager,
|
||||||
Long.toString(crc32.getValue()),
|
Long.toString(crc32.getValue()),
|
||||||
groupName);
|
groupName);
|
||||||
|
|
||||||
if (category.equals(Notification.CATEGORY_CALL)) {
|
|
||||||
NotificationUtils.createNotificationChannel(notificationManager,
|
NotificationUtils.createNotificationChannel(notificationManager,
|
||||||
NotificationUtils.NOTIFICATION_CHANNEL_CALLS, context.getResources()
|
NotificationUtils.NOTIFICATION_CHANNEL_CALLS_V2, context.getResources()
|
||||||
.getString(R
|
.getString(R.string.nc_notification_channel_messages), context.getResources()
|
||||||
.string.nc_notification_channel_calls), context.getResources()
|
.getString(R.string.nc_notification_channel_messages_description), true,
|
||||||
.getString
|
|
||||||
(R.string.nc_notification_channel_calls_description), true,
|
|
||||||
NotificationManager.IMPORTANCE_HIGH);
|
NotificationManager.IMPORTANCE_HIGH);
|
||||||
|
|
||||||
notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_CALLS);
|
notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_CALLS_V2);
|
||||||
} else {
|
|
||||||
NotificationUtils.createNotificationChannel(notificationManager,
|
|
||||||
NotificationUtils.NOTIFICATION_CHANNEL_MESSAGES, context.getResources()
|
|
||||||
.getString(R
|
|
||||||
.string.nc_notification_channel_messages), context.getResources()
|
|
||||||
.getString
|
|
||||||
(R.string.nc_notification_channel_messages_description), true,
|
|
||||||
NotificationManager.IMPORTANCE_DEFAULT);
|
|
||||||
|
|
||||||
notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_MESSAGES);
|
|
||||||
}
|
|
||||||
|
|
||||||
notificationBuilder.setGroup(Long.toString(crc32.getValue()));
|
notificationBuilder.setGroup(Long.toString(crc32.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +230,7 @@ public class NotificationJob extends Job {
|
|||||||
|
|
||||||
String stringForCrc = decryptedPushMessage.getSubject() + " " + signatureVerification
|
String stringForCrc = decryptedPushMessage.getSubject() + " " + signatureVerification
|
||||||
.getUserEntity().getDisplayName() + " " + signatureVerification.getUserEntity
|
.getUserEntity().getDisplayName() + " " + signatureVerification.getUserEntity
|
||||||
().getBaseUrl();
|
().getBaseUrl() + System.currentTimeMillis();
|
||||||
|
|
||||||
crc32 = new CRC32();
|
crc32 = new CRC32();
|
||||||
crc32.update(stringForCrc.getBytes());
|
crc32.update(stringForCrc.getBytes());
|
||||||
@ -252,9 +244,9 @@ public class NotificationJob extends Job {
|
|||||||
mediaPlayer.setOnCompletionListener(MediaPlayer::release);
|
mediaPlayer.setOnCompletionListener(MediaPlayer::release);
|
||||||
|
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (NoSuchAlgorithmException e1) {
|
} catch (NoSuchAlgorithmException e1) {
|
||||||
Log.d(TAG, "No proper algorithm to decrypt the message " + e1.getLocalizedMessage());
|
Log.d(TAG, "No proper algorithm to decrypt the message " + e1.getLocalizedMessage());
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* Nextcloud Talk application
|
||||||
|
*
|
||||||
|
* @author Mario Danic
|
||||||
|
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.nextcloud.talk.receivers;
|
||||||
|
|
||||||
|
import android.app.NotificationManager;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.nextcloud.talk.utils.NotificationUtils;
|
||||||
|
|
||||||
|
public class PackageReplacedReceiver extends BroadcastReceiver {
|
||||||
|
private static final String TAG = "PackageReplacedReceiver";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if (intent != null && intent.getAction() != null &&
|
||||||
|
intent.getAction().equals("android.intent.action.MY_PACKAGE_REPLACED")) {
|
||||||
|
try {
|
||||||
|
PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||||
|
if (packageInfo.versionCode == 99 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
NotificationManager notificationManager =
|
||||||
|
(NotificationManager) context.getSystemService(Context
|
||||||
|
.NOTIFICATION_SERVICE);
|
||||||
|
|
||||||
|
if (notificationManager != null) {
|
||||||
|
notificationManager.deleteNotificationChannel(NotificationUtils.NOTIFICATION_CHANNEL_CALLS);
|
||||||
|
notificationManager.deleteNotificationChannel(NotificationUtils.NOTIFICATION_CHANNEL_MESSAGES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
Log.e(TAG, "Failed to find package info");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -30,6 +30,8 @@ import android.os.Build;
|
|||||||
public class NotificationUtils {
|
public class NotificationUtils {
|
||||||
public static final String NOTIFICATION_CHANNEL_CALLS = "NOTIFICATION_CHANNEL_CALLS";
|
public static final String NOTIFICATION_CHANNEL_CALLS = "NOTIFICATION_CHANNEL_CALLS";
|
||||||
public static final String NOTIFICATION_CHANNEL_MESSAGES = "NOTIFICATION_CHANNEL_MESSAGES";
|
public static final String NOTIFICATION_CHANNEL_MESSAGES = "NOTIFICATION_CHANNEL_MESSAGES";
|
||||||
|
public static final String NOTIFICATION_CHANNEL_CALLS_V2 = "NOTIFICATION_CHANNEL_CALLS_V2";
|
||||||
|
public static final String NOTIFICATION_CHANNEL_MESSAGES_V2 = "NOTIFICATION_CHANNEL_MESSAGES_V2";
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.O)
|
@TargetApi(Build.VERSION_CODES.O)
|
||||||
public static void createNotificationChannel(NotificationManager notificationManager,
|
public static void createNotificationChannel(NotificationManager notificationManager,
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
|
|
||||||
<com.nextcloud.talk.utils.MagicFlipView
|
<com.nextcloud.talk.utils.MagicFlipView
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/call_control_hangup"
|
android:id="@+id/callControlHangupView"
|
||||||
android:layout_width="60dp"
|
android:layout_width="60dp"
|
||||||
android:layout_height="60dp"
|
android:layout_height="60dp"
|
||||||
app:checked="false"
|
app:checked="false"
|
||||||
|
Loading…
Reference in New Issue
Block a user