mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
use real endpoints instead faked ones
- fix api - add error state for recording model Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
cdf70282e4
commit
1d002b6a4d
@ -409,6 +409,9 @@ public class CallActivity extends CallBaseActivity {
|
||||
dialog.getButton(AlertDialog.BUTTON_NEGATIVE)
|
||||
);
|
||||
|
||||
} else if (viewState instanceof CallRecordingViewModel.RecordingErrorState) {
|
||||
Toast.makeText(context, context.getResources().getString(R.string.nc_common_error_sorry),
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
hideCallRecordingIndicator();
|
||||
}
|
||||
@ -462,15 +465,12 @@ public class CallActivity extends CallBaseActivity {
|
||||
}
|
||||
|
||||
private void initFeaturesVisibility() {
|
||||
// TODO: check for isAllowedToRecordCall once api is ready
|
||||
// boolean showMoreCallActionsItem = isAllowedToRecordCall();
|
||||
// if (showMoreCallActionsItem) {
|
||||
// binding.moreCallActions.setVisibility(View.VISIBLE);
|
||||
// } else {
|
||||
// binding.moreCallActions.setVisibility(View.GONE);
|
||||
// }
|
||||
|
||||
binding.moreCallActions.setVisibility(View.VISIBLE);
|
||||
boolean showMoreCallActionsItem = isAllowedToRecordCall();
|
||||
if (showMoreCallActionsItem) {
|
||||
binding.moreCallActions.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
binding.moreCallActions.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void initClickListeners() {
|
||||
|
@ -574,11 +574,13 @@ public interface NcApi {
|
||||
@Url String url,
|
||||
@Query("reference") String urlToFindPreviewFor);
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST
|
||||
Observable<GenericOverall> startRecording(@Header("Authorization") String authorization,
|
||||
@Url String url);
|
||||
@Url String url,
|
||||
@Field("status") Integer status);
|
||||
|
||||
@POST
|
||||
@DELETE
|
||||
Observable<GenericOverall> stopRecording(@Header("Authorization") String authorization,
|
||||
@Url String url);
|
||||
}
|
||||
|
@ -35,46 +35,47 @@ class CallRecordingRepositoryImpl(private val ncApi: NcApi, currentUserProvider:
|
||||
val currentUser: User = currentUserProvider.currentUser.blockingGet()
|
||||
val credentials: String = ApiUtils.getCredentials(currentUser.username, currentUser.token)
|
||||
|
||||
var apiVersion = ApiUtils.getCallApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, 1))
|
||||
|
||||
override fun startRecording(
|
||||
roomToken: String
|
||||
): Observable<StartCallRecordingModel> {
|
||||
return Observable.just<StartCallRecordingModel>(StartCallRecordingModel(true))
|
||||
}
|
||||
var apiVersion = 1
|
||||
|
||||
// override fun startRecording(
|
||||
// roomToken: String
|
||||
// ): Observable<StartCallRecordingModel> {
|
||||
// return ncApi.startRecording(
|
||||
// credentials,
|
||||
// ApiUtils.getUrlForRecording(
|
||||
// apiVersion,
|
||||
// currentUser.baseUrl,
|
||||
// roomToken
|
||||
// )
|
||||
// ).map { mapToStartCallRecordingModel(it.ocs?.meta!!) }
|
||||
// return Observable.just<StartCallRecordingModel>(StartCallRecordingModel(true))
|
||||
// }
|
||||
|
||||
override fun stopRecording(
|
||||
override fun startRecording(
|
||||
roomToken: String
|
||||
): Observable<StopCallRecordingModel> {
|
||||
return Observable.just<StopCallRecordingModel>(StopCallRecordingModel(true))
|
||||
): Observable<StartCallRecordingModel> {
|
||||
return ncApi.startRecording(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRecording(
|
||||
apiVersion,
|
||||
currentUser.baseUrl,
|
||||
roomToken
|
||||
),
|
||||
1
|
||||
).map { mapToStartCallRecordingModel(it.ocs?.meta!!) }
|
||||
}
|
||||
|
||||
// override fun stopRecording(
|
||||
// roomToken: String
|
||||
// ): Observable<StopCallRecordingModel> {
|
||||
// return ncApi.stopRecording(
|
||||
// credentials,
|
||||
// ApiUtils.getUrlForRecording(
|
||||
// apiVersion,
|
||||
// currentUser.baseUrl,
|
||||
// roomToken
|
||||
// )
|
||||
// ).map { mapToStopCallRecordingModel(it.ocs?.meta!!) }
|
||||
// return Observable.just<StopCallRecordingModel>(StopCallRecordingModel(true))
|
||||
// }
|
||||
|
||||
override fun stopRecording(
|
||||
roomToken: String
|
||||
): Observable<StopCallRecordingModel> {
|
||||
return ncApi.stopRecording(
|
||||
credentials,
|
||||
ApiUtils.getUrlForRecording(
|
||||
apiVersion,
|
||||
currentUser.baseUrl,
|
||||
roomToken
|
||||
)
|
||||
).map { mapToStopCallRecordingModel(it.ocs?.meta!!) }
|
||||
}
|
||||
|
||||
private fun mapToStartCallRecordingModel(
|
||||
response: GenericMeta
|
||||
): StartCallRecordingModel {
|
||||
|
@ -67,8 +67,7 @@ class MoreCallActionsDialog(private val callActivity: CallActivity) : BottomShee
|
||||
}
|
||||
|
||||
private fun initItemsVisibility() {
|
||||
// if (callActivity.isAllowedToRecordCall) {
|
||||
if (true) {
|
||||
if (callActivity.isAllowedToRecordCall) {
|
||||
binding.recordCall.visibility = View.VISIBLE
|
||||
} else {
|
||||
binding.recordCall.visibility = View.GONE
|
||||
|
@ -496,6 +496,6 @@ public class ApiUtils {
|
||||
}
|
||||
|
||||
public static String getUrlForRecording(int version, String baseUrl, String token) {
|
||||
return getUrlForCall(version, baseUrl, token) + "/recording";
|
||||
return getUrlForApi(version, baseUrl) + "/recording/" + token;
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ class CallRecordingViewModel @Inject constructor(private val repository: CallRec
|
||||
object RecordingStartLoadingState : ViewState
|
||||
object RecordingStopLoadingState : ViewState
|
||||
object RecordingConfirmStopState : ViewState
|
||||
object RecordingErrorState : ViewState
|
||||
|
||||
private val _viewState: MutableLiveData<ViewState> = MutableLiveData(RecordingStoppedState)
|
||||
val viewState: LiveData<ViewState>
|
||||
@ -60,21 +61,28 @@ class CallRecordingViewModel @Inject constructor(private val repository: CallRec
|
||||
_viewState.value = RecordingConfirmStopState
|
||||
}
|
||||
RecordingStoppedState -> {
|
||||
_viewState.value = RecordingStartLoadingState
|
||||
repository.startRecording(roomToken)
|
||||
.subscribeOn(Schedulers.io())
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
?.subscribe(CallStartRecordingObserver())
|
||||
startRecording()
|
||||
}
|
||||
RecordingConfirmStopState -> {
|
||||
// confirm dialog to stop recording might have been dismissed without to click an action.
|
||||
// just show it again.
|
||||
_viewState.value = RecordingConfirmStopState
|
||||
}
|
||||
RecordingErrorState -> {
|
||||
stopRecording()
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
private fun startRecording() {
|
||||
_viewState.value = RecordingStartLoadingState
|
||||
repository.startRecording(roomToken)
|
||||
.subscribeOn(Schedulers.io())
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
?.subscribe(CallStartRecordingObserver())
|
||||
}
|
||||
|
||||
fun stopRecording() {
|
||||
_viewState.value = RecordingStopLoadingState
|
||||
repository.stopRecording(roomToken)
|
||||
@ -109,6 +117,7 @@ class CallRecordingViewModel @Inject constructor(private val repository: CallRec
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "failure in CallStartRecordingObserver", e)
|
||||
_viewState.value = RecordingErrorState
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
@ -122,11 +131,14 @@ class CallRecordingViewModel @Inject constructor(private val repository: CallRec
|
||||
}
|
||||
|
||||
override fun onNext(stopCallRecordingModel: StopCallRecordingModel) {
|
||||
_viewState.value = RecordingStoppedState
|
||||
if (stopCallRecordingModel.success) {
|
||||
_viewState.value = RecordingStoppedState
|
||||
}
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.e(TAG, "failure in CallStopRecordingObserver", e)
|
||||
_viewState.value = RecordingErrorState
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
|
Loading…
Reference in New Issue
Block a user