Add web button and use capabilities

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-02-12 12:57:05 +01:00
parent ea35890f7e
commit 209b0b3103
2 changed files with 63 additions and 7 deletions

View file

@ -21,6 +21,7 @@
package com.nextcloud.talk.controllers.bottomsheet;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
@ -39,6 +40,7 @@ import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.controllers.base.BaseController;
import com.nextcloud.talk.events.BottomSheetLockEvent;
import com.nextcloud.talk.models.database.UserEntity;
import com.nextcloud.talk.models.json.capabilities.CapabilitiesOverall;
import com.nextcloud.talk.models.json.rooms.Room;
import com.nextcloud.talk.models.json.rooms.RoomOverall;
import com.nextcloud.talk.utils.ApiUtils;
@ -76,6 +78,9 @@ public class OperationsMenuController extends BaseController {
@BindView(R.id.ok_button)
Button okButton;
@BindView(R.id.web_button)
Button webButton;
@Inject
NcApi ncApi;
@ -203,11 +208,42 @@ public class OperationsMenuController extends BaseController {
@Override
public void onNext(RoomOverall roomOverall) {
room = roomOverall.getOcs().getData();
if (room.isHasPassword() && room.isGuest()) {
ncApi.getCapabilities(null, ApiUtils.getUrlForCapabilities(baseUrl))
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Observer<CapabilitiesOverall>() {
@Override
public void onSubscribe(Disposable d) {
} else {
initiateCall();
}
}
@Override
public void onNext(CapabilitiesOverall capabilitiesOverall) {
if (capabilitiesOverall.getOcs().getData()
.getCapabilities().getSpreedCapability() != null &&
capabilitiesOverall.getOcs().getData()
.getCapabilities().getSpreedCapability()
.getFeatures() != null) {
if (room.isHasPassword() && room.isGuest()) {
} else {
initiateCall();
}
} else {
showResultImage(false, true);
}
}
@Override
public void onError(Throwable e) {
showResultImage(false, false);
}
@Override
public void onComplete() {
}
});
}
@Override
@ -236,7 +272,7 @@ public class OperationsMenuController extends BaseController {
}
}
private void showResultImage(boolean everythingOK, boolean isSignalingSettingsError) {
private void showResultImage(boolean everythingOK, boolean isGuestSupportError) {
progressBar.setVisibility(View.GONE);
if (everythingOK) {
@ -253,10 +289,16 @@ public class OperationsMenuController extends BaseController {
resultsTextView.setText(R.string.nc_all_ok_operation);
} else {
resultsTextView.setTextColor(getResources().getColor(R.color.nc_darkRed));
if (!isSignalingSettingsError) {
if (!isGuestSupportError) {
resultsTextView.setText(R.string.nc_failed_to_perform_operation);
} else {
resultsTextView.setText(R.string.nc_failed_signaling_settings);
webButton.setOnClickListener(v -> {
new BottomSheetLockEvent(true, 0, false, true);
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(callUrl));
startActivity(browserIntent);
});
webButton.setVisibility(View.VISIBLE);
}
}

View file

@ -74,4 +74,18 @@
android:text="@string/nc_ok"
android:textColor="@color/colorPrimary"
android:visibility="gone"/>
</RelativeLayout>
<Button
android:id="@+id/web_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/result_text_view"
android:layout_marginBottom="12dp"
android:layout_marginEnd="8dp"
android:layout_toStartOf="@id/ok_button"
android:background="#0000"
android:text="@string/nc_join_via_web"
android:textColor="@color/nc_darkGreen"
android:visibility="gone"/>
</RelativeLayout>