From 209b0b3103b8f79b61494bea3307487e5e75a330 Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Mon, 12 Feb 2018 12:57:05 +0100 Subject: [PATCH] Add web button and use capabilities Signed-off-by: Mario Danic --- .../bottomsheet/OperationsMenuController.java | 54 ++++++++++++++++--- .../res/layout/controller_operations_menu.xml | 16 +++++- 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java index 53929345d..0acc2fae3 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/OperationsMenuController.java @@ -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() { + @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); } } diff --git a/app/src/main/res/layout/controller_operations_menu.xml b/app/src/main/res/layout/controller_operations_menu.xml index d4091b497..474f6f27f 100644 --- a/app/src/main/res/layout/controller_operations_menu.xml +++ b/app/src/main/res/layout/controller_operations_menu.xml @@ -74,4 +74,18 @@ android:text="@string/nc_ok" android:textColor="@color/colorPrimary" android:visibility="gone"/> - \ No newline at end of file + +