mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-12 23:34:31 +01:00
Hopefully fix a few crashing issues
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
64adf81e13
commit
e0f2a8cb58
@ -71,6 +71,7 @@ import com.nextcloud.talk.utils.ApiUtils;
|
||||
import com.nextcloud.talk.utils.animations.PulseAnimation;
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||
import com.nextcloud.talk.utils.preferences.AppPreferences;
|
||||
import com.nextcloud.talk.webrtc.MagicAudioManager;
|
||||
import com.nextcloud.talk.webrtc.MagicPeerConnectionWrapper;
|
||||
import com.nextcloud.talk.webrtc.MagicWebRTCUtils;
|
||||
@ -168,6 +169,8 @@ public class CallActivity extends AppCompatActivity {
|
||||
UserUtils userUtils;
|
||||
@Inject
|
||||
CookieManager cookieManager;
|
||||
@Inject
|
||||
AppPreferences appPreferences;
|
||||
|
||||
PeerConnectionFactory peerConnectionFactory;
|
||||
MediaConstraints audioConstraints;
|
||||
@ -223,7 +226,7 @@ public class CallActivity extends AppCompatActivity {
|
||||
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
|
||||
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
|
||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
|
||||
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
|
||||
getWindow().getDecorView().setSystemUiVisibility(getSystemUiVisibility());
|
||||
@ -396,26 +399,29 @@ public class CallActivity extends AppCompatActivity {
|
||||
public void onMicrophoneClick() {
|
||||
if (EffortlessPermissions.hasPermissions(this, PERMISSIONS_MICROPHONE)) {
|
||||
|
||||
spotlightView = new SpotlightView.Builder(this)
|
||||
.introAnimationDuration(300)
|
||||
.enableRevealAnimation(true)
|
||||
.performClick(false)
|
||||
.fadeinTextDuration(400)
|
||||
.headingTvColor(getResources().getColor(R.color.colorPrimary))
|
||||
.headingTvSize(20)
|
||||
.headingTvText(getString(R.string.nc_push_to_talk))
|
||||
.subHeadingTvColor(getResources().getColor(R.color.nc_white_color_complete))
|
||||
.subHeadingTvSize(16)
|
||||
.subHeadingTvText(getString(R.string.nc_push_to_talk_desc))
|
||||
.maskColor(Color.parseColor("#dc000000"))
|
||||
.target(microphoneControlButton)
|
||||
.lineAnimDuration(400)
|
||||
.lineAndArcColor(getResources().getColor(R.color.colorPrimary))
|
||||
.enableDismissAfterShown(true)
|
||||
.dismissOnBackPress(true)
|
||||
.usageId("pushToTalk")
|
||||
.show();
|
||||
if (!appPreferences.getPushToTalkIntroShown()) {
|
||||
spotlightView = new SpotlightView.Builder(this)
|
||||
.introAnimationDuration(300)
|
||||
.enableRevealAnimation(true)
|
||||
.performClick(false)
|
||||
.fadeinTextDuration(400)
|
||||
.headingTvColor(getResources().getColor(R.color.colorPrimary))
|
||||
.headingTvSize(20)
|
||||
.headingTvText(getString(R.string.nc_push_to_talk))
|
||||
.subHeadingTvColor(getResources().getColor(R.color.nc_white_color_complete))
|
||||
.subHeadingTvSize(16)
|
||||
.subHeadingTvText(getString(R.string.nc_push_to_talk_desc))
|
||||
.maskColor(Color.parseColor("#dc000000"))
|
||||
.target(microphoneControlButton)
|
||||
.lineAnimDuration(400)
|
||||
.lineAndArcColor(getResources().getColor(R.color.colorPrimary))
|
||||
.enableDismissAfterShown(true)
|
||||
.dismissOnBackPress(true)
|
||||
.usageId("pushToTalk")
|
||||
.show();
|
||||
|
||||
appPreferences.setPushToTalkIntroShown(true);
|
||||
}
|
||||
|
||||
if (!isPTTActive) {
|
||||
audioOn = !audioOn;
|
||||
@ -1457,7 +1463,7 @@ public class CallActivity extends AppCompatActivity {
|
||||
if (callControls != null) {
|
||||
if (!show) {
|
||||
callControls.setVisibility(View.GONE);
|
||||
if (spotlightView.getVisibility() != View.GONE) {
|
||||
if (spotlightView != null && spotlightView.getVisibility() != View.GONE) {
|
||||
spotlightView.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
|
@ -320,7 +320,6 @@ public class OperationsMenuController extends BaseController {
|
||||
roomType, null, conversationName);
|
||||
}
|
||||
|
||||
String finalCredentials1 = credentials;
|
||||
final boolean isGroupCallWorkaroundFinal = isGroupCallWorkaround;
|
||||
ncApi.createRoom(credentials, retrofitBucket.getUrl(), retrofitBucket.getQueryMap())
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
@ -336,33 +335,7 @@ public class OperationsMenuController extends BaseController {
|
||||
public void onNext(RoomOverall roomOverall) {
|
||||
room = roomOverall.getOcs().getData();
|
||||
if (conversationType.equals(Room.RoomType.ROOM_PUBLIC_CALL) && isGroupCallWorkaroundFinal) {
|
||||
ncApi.makeRoomPrivate(finalCredentials1, ApiUtils.getUrlForRoomVisibility
|
||||
(userEntity.getBaseUrl(), room.getToken()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.retry(1)
|
||||
.subscribe(new Observer<GenericOverall>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GenericOverall genericOverall) {
|
||||
inviteUsersToAConversation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
showResultImage(false, false);
|
||||
dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
performGroupCallWorkaround(credentials);
|
||||
} else {
|
||||
inviteUsersToAConversation();
|
||||
}
|
||||
@ -395,6 +368,36 @@ public class OperationsMenuController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
private void performGroupCallWorkaround(String credentials) {
|
||||
ncApi.makeRoomPrivate(credentials, ApiUtils.getUrlForRoomVisibility(userEntity.getBaseUrl(), room.getToken()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.retry(1)
|
||||
.subscribe(new Observer<GenericOverall>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(GenericOverall genericOverall) {
|
||||
inviteUsersToAConversation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
showResultImage(false, false);
|
||||
dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
private void showResultImage(boolean everythingOK, boolean isGuestSupportError) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
|
||||
|
@ -21,22 +21,27 @@
|
||||
package com.nextcloud.talk.jobs;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.bluelinelabs.logansquare.LoganSquare;
|
||||
import com.evernote.android.job.Job;
|
||||
import com.nextcloud.talk.api.NcApi;
|
||||
import com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
import com.nextcloud.talk.models.database.UserEntity;
|
||||
import com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall;
|
||||
import com.nextcloud.talk.utils.ApiUtils;
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys;
|
||||
import com.nextcloud.talk.utils.database.user.UserUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import autodagger.AutoInjector;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import okhttp3.JavaNetCookieJar;
|
||||
import okhttp3.OkHttpClient;
|
||||
@ -82,14 +87,63 @@ public class CapabilitiesJob extends Job {
|
||||
ncApi.getCapabilities(ApiUtils.getCredentials(internalUserEntity.getUsername(),
|
||||
internalUserEntity.getToken()), ApiUtils.getUrlForCapabilities(internalUserEntity.getBaseUrl()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribe(capabilitiesOverall -> userUtils.createOrUpdateUser(null, null,
|
||||
null, null,
|
||||
null, null, null, internalUserEntity.getId(),
|
||||
LoganSquare.serialize(capabilitiesOverall.getOcs().getData().getCapabilities()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribe());
|
||||
.subscribe(new Observer<CapabilitiesOverall>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(CapabilitiesOverall capabilitiesOverall) {
|
||||
updateUser(capabilitiesOverall, internalUserEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return Result.SUCCESS;
|
||||
}
|
||||
|
||||
private void updateUser(CapabilitiesOverall capabilitiesOverall, UserEntity internalUserEntity) {
|
||||
try {
|
||||
userUtils.createOrUpdateUser(null, null,
|
||||
null, null,
|
||||
null, null, null, internalUserEntity.getId(),
|
||||
LoganSquare.serialize(capabilitiesOverall.getOcs().getData().getCapabilities()))
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.subscribe(new Observer<UserEntity>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(UserEntity userEntity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete() {
|
||||
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Failed to create or update user");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -117,6 +117,16 @@ public interface AppPreferences {
|
||||
@KeyByString("push_token")
|
||||
void removePushToken();
|
||||
|
||||
@KeyByString("pushToTalk_intro_shown")
|
||||
boolean getPushToTalkIntroShown();
|
||||
|
||||
@KeyByString("pushToTalk_intro_shown")
|
||||
void setPushToTalkIntroShown(boolean shown);
|
||||
|
||||
@KeyByString("pushToTalk_intro_shown")
|
||||
void removePushToTalkIntroShown();
|
||||
|
||||
|
||||
@ClearMethod
|
||||
void clear();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user