mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-22 13:05:31 +03:00
Fix issues and add support for ringtone
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
717ec324b7
commit
1c4ba6f6ee
3 changed files with 69 additions and 11 deletions
|
@ -33,7 +33,6 @@ import android.content.Intent;
|
|||
import android.content.IntentFilter;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
@ -56,6 +55,8 @@ import com.nextcloud.talk.api.NcApi;
|
|||
import com.nextcloud.talk.api.helpers.api.ApiHelper;
|
||||
import com.nextcloud.talk.api.models.json.call.CallOverall;
|
||||
import com.nextcloud.talk.api.models.json.generic.GenericOverall;
|
||||
import com.nextcloud.talk.api.models.json.rooms.Room;
|
||||
import com.nextcloud.talk.api.models.json.rooms.RoomsOverall;
|
||||
import com.nextcloud.talk.api.models.json.signaling.DataChannelMessage;
|
||||
import com.nextcloud.talk.api.models.json.signaling.NCIceCandidate;
|
||||
import com.nextcloud.talk.api.models.json.signaling.NCMessagePayload;
|
||||
|
@ -221,14 +222,14 @@ public class CallActivity extends AppCompatActivity {
|
|||
ButterKnife.bind(this);
|
||||
|
||||
roomToken = getIntent().getExtras().getString("roomToken", "");
|
||||
userEntity = Parcels.unwrap((Parcelable) getIntent().getExtras().get("userEntity"));
|
||||
userEntity = Parcels.unwrap(getIntent().getExtras().getParcelable("userEntity"));
|
||||
callSession = "0";
|
||||
credentials = ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken());
|
||||
|
||||
callControls.setZ(100.0f);
|
||||
basicInitialization();
|
||||
|
||||
if (userUtils.getCurrentUser() != null && userUtils.getCurrentUser() != userEntity) {
|
||||
if (!userEntity.getCurrent()) {
|
||||
userUtils.createOrUpdateUser(userEntity.getUsername(),
|
||||
userEntity.getToken(), userEntity.getBaseUrl(), null,
|
||||
null, true)
|
||||
|
@ -242,6 +243,52 @@ public class CallActivity extends AppCompatActivity {
|
|||
public void onNext(UserEntity userEntity) {
|
||||
cookieManager.getCookieStore().removeAll();
|
||||
userUtils.disableAllUsersWithoutId(userEntity.getId());
|
||||
if (getIntent().getExtras().containsKey("fromNotification")) {
|
||||
handleFromNotification();
|
||||
} else {
|
||||
initViews();
|
||||
checkPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} else if (getIntent().getExtras().containsKey("fromNotification")) {
|
||||
handleFromNotification();
|
||||
} else {
|
||||
initViews();
|
||||
checkPermissions();
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFromNotification() {
|
||||
ncApi.getRooms(credentials, ApiHelper.getUrlForGetRooms(userEntity.getBaseUrl()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new Observer<RoomsOverall>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(RoomsOverall roomsOverall) {
|
||||
for (Room room : roomsOverall.getOcs().getData()) {
|
||||
if (roomToken.equals(room.getRoomId())) {
|
||||
roomToken = room.getToken();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
initViews();
|
||||
checkPermissions();
|
||||
}
|
||||
|
@ -256,13 +303,8 @@ public class CallActivity extends AppCompatActivity {
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
initViews();
|
||||
checkPermissions();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void toggleMedia(boolean enable, boolean video) {
|
||||
String message;
|
||||
|
@ -731,6 +773,7 @@ public class CallActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
Log.d("MARIO_DEBUG", e.getLocalizedMessage());
|
||||
dispose(signalingDisposable);
|
||||
}
|
||||
|
||||
|
@ -745,7 +788,7 @@ public class CallActivity extends AppCompatActivity {
|
|||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
Log.d("MARIO_DEBUG", e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,6 +46,8 @@ import com.nextcloud.talk.utils.NotificationUtils;
|
|||
import com.nextcloud.talk.utils.PushUtils;
|
||||
import com.nextcloud.talk.utils.bundle.BundleBuilder;
|
||||
|
||||
import org.parceler.Parcels;
|
||||
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PrivateKey;
|
||||
|
@ -93,7 +95,9 @@ public class MagicFirebaseMessagingService extends FirebaseMessagingService {
|
|||
Intent intent = new Intent(this, CallActivity.class);
|
||||
BundleBuilder bundleBuilder = new BundleBuilder(new Bundle());
|
||||
bundleBuilder.putString("roomToken", decryptedPushMessage.getId());
|
||||
bundleBuilder.putParcelable("userEntity", signatureVerification.getUserEntity());
|
||||
bundleBuilder.putParcelable("userEntity", Parcels.wrap(signatureVerification
|
||||
.getUserEntity()));
|
||||
bundleBuilder.putBoolean("fromNotification", true);
|
||||
intent.putExtras(bundleBuilder.build());
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this,
|
||||
|
@ -155,7 +159,7 @@ public class MagicFirebaseMessagingService extends FirebaseMessagingService {
|
|||
NotificationUtils.NOTIFICATION_CHANNEL_CALLS, getResources().getString(R
|
||||
.string.nc_notification_channel_calls), getResources().getString
|
||||
(R.string.nc_notification_channel_calls_description), true,
|
||||
NotificationManager.IMPORTANCE_HIGH);
|
||||
NotificationManager.IMPORTANCE_HIGH, soundUri);
|
||||
|
||||
notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_CALLS);
|
||||
} else {
|
||||
|
@ -163,7 +167,7 @@ public class MagicFirebaseMessagingService extends FirebaseMessagingService {
|
|||
NotificationUtils.NOTIFICATION_CHANNEL_MESSAGES, getResources().getString(R
|
||||
.string.nc_notification_channel_messages), getResources().getString
|
||||
(R.string.nc_notification_channel_messages_description), true,
|
||||
NotificationManager.IMPORTANCE_DEFAULT);
|
||||
NotificationManager.IMPORTANCE_DEFAULT, soundUri);
|
||||
|
||||
notificationBuilder.setChannelId(NotificationUtils.NOTIFICATION_CHANNEL_MESSAGES);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ import android.app.NotificationChannel;
|
|||
import android.app.NotificationChannelGroup;
|
||||
import android.app.NotificationManager;
|
||||
import android.graphics.Color;
|
||||
import android.media.AudioAttributes;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
||||
public class NotificationUtils {
|
||||
|
@ -36,7 +38,7 @@ public class NotificationUtils {
|
|||
public static void createNotificationChannel(NotificationManager notificationManager,
|
||||
String channelId, String channelName,
|
||||
String channelDescription, boolean vibrate,
|
||||
int importance) {
|
||||
int importance, Uri soundUri) {
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O
|
||||
&& notificationManager.getNotificationChannel(channelId) == null) {
|
||||
|
@ -44,6 +46,15 @@ public class NotificationUtils {
|
|||
NotificationChannel channel = new NotificationChannel(channelId, channelName,
|
||||
importance);
|
||||
|
||||
int usage;
|
||||
|
||||
if (channelId.equals(NotificationUtils.NOTIFICATION_CHANNEL_CALLS)) {
|
||||
usage = AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_REQUEST;
|
||||
} else {
|
||||
usage = AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT;
|
||||
}
|
||||
|
||||
channel.setSound(soundUri, new AudioAttributes.Builder().setUsage(usage).build());
|
||||
channel.setDescription(channelDescription);
|
||||
channel.enableLights(vibrate);
|
||||
channel.enableVibration(vibrate);
|
||||
|
|
Loading…
Reference in a new issue