mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 03:59:35 +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)
|
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 {
|
} else {
|
||||||
hideCallRecordingIndicator();
|
hideCallRecordingIndicator();
|
||||||
}
|
}
|
||||||
@ -462,15 +465,12 @@ public class CallActivity extends CallBaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initFeaturesVisibility() {
|
private void initFeaturesVisibility() {
|
||||||
// TODO: check for isAllowedToRecordCall once api is ready
|
boolean showMoreCallActionsItem = isAllowedToRecordCall();
|
||||||
// boolean showMoreCallActionsItem = isAllowedToRecordCall();
|
if (showMoreCallActionsItem) {
|
||||||
// if (showMoreCallActionsItem) {
|
|
||||||
// binding.moreCallActions.setVisibility(View.VISIBLE);
|
|
||||||
// } else {
|
|
||||||
// binding.moreCallActions.setVisibility(View.GONE);
|
|
||||||
// }
|
|
||||||
|
|
||||||
binding.moreCallActions.setVisibility(View.VISIBLE);
|
binding.moreCallActions.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
binding.moreCallActions.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initClickListeners() {
|
private void initClickListeners() {
|
||||||
|
@ -574,11 +574,13 @@ public interface NcApi {
|
|||||||
@Url String url,
|
@Url String url,
|
||||||
@Query("reference") String urlToFindPreviewFor);
|
@Query("reference") String urlToFindPreviewFor);
|
||||||
|
|
||||||
|
@FormUrlEncoded
|
||||||
@POST
|
@POST
|
||||||
Observable<GenericOverall> startRecording(@Header("Authorization") String authorization,
|
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,
|
Observable<GenericOverall> stopRecording(@Header("Authorization") String authorization,
|
||||||
@Url String url);
|
@Url String url);
|
||||||
}
|
}
|
||||||
|
@ -35,46 +35,47 @@ class CallRecordingRepositoryImpl(private val ncApi: NcApi, currentUserProvider:
|
|||||||
val currentUser: User = currentUserProvider.currentUser.blockingGet()
|
val currentUser: User = currentUserProvider.currentUser.blockingGet()
|
||||||
val credentials: String = ApiUtils.getCredentials(currentUser.username, currentUser.token)
|
val credentials: String = ApiUtils.getCredentials(currentUser.username, currentUser.token)
|
||||||
|
|
||||||
var apiVersion = ApiUtils.getCallApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, 1))
|
var apiVersion = 1
|
||||||
|
|
||||||
override fun startRecording(
|
|
||||||
roomToken: String
|
|
||||||
): Observable<StartCallRecordingModel> {
|
|
||||||
return Observable.just<StartCallRecordingModel>(StartCallRecordingModel(true))
|
|
||||||
}
|
|
||||||
|
|
||||||
// override fun startRecording(
|
// override fun startRecording(
|
||||||
// roomToken: String
|
// roomToken: String
|
||||||
// ): Observable<StartCallRecordingModel> {
|
// ): Observable<StartCallRecordingModel> {
|
||||||
// return ncApi.startRecording(
|
// return Observable.just<StartCallRecordingModel>(StartCallRecordingModel(true))
|
||||||
// credentials,
|
|
||||||
// ApiUtils.getUrlForRecording(
|
|
||||||
// apiVersion,
|
|
||||||
// currentUser.baseUrl,
|
|
||||||
// roomToken
|
|
||||||
// )
|
|
||||||
// ).map { mapToStartCallRecordingModel(it.ocs?.meta!!) }
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
override fun stopRecording(
|
override fun startRecording(
|
||||||
roomToken: String
|
roomToken: String
|
||||||
): Observable<StopCallRecordingModel> {
|
): Observable<StartCallRecordingModel> {
|
||||||
return Observable.just<StopCallRecordingModel>(StopCallRecordingModel(true))
|
return ncApi.startRecording(
|
||||||
|
credentials,
|
||||||
|
ApiUtils.getUrlForRecording(
|
||||||
|
apiVersion,
|
||||||
|
currentUser.baseUrl,
|
||||||
|
roomToken
|
||||||
|
),
|
||||||
|
1
|
||||||
|
).map { mapToStartCallRecordingModel(it.ocs?.meta!!) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// override fun stopRecording(
|
// override fun stopRecording(
|
||||||
// roomToken: String
|
// roomToken: String
|
||||||
// ): Observable<StopCallRecordingModel> {
|
// ): Observable<StopCallRecordingModel> {
|
||||||
// return ncApi.stopRecording(
|
// return Observable.just<StopCallRecordingModel>(StopCallRecordingModel(true))
|
||||||
// credentials,
|
|
||||||
// ApiUtils.getUrlForRecording(
|
|
||||||
// apiVersion,
|
|
||||||
// currentUser.baseUrl,
|
|
||||||
// roomToken
|
|
||||||
// )
|
|
||||||
// ).map { mapToStopCallRecordingModel(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!!) }
|
||||||
|
}
|
||||||
|
|
||||||
private fun mapToStartCallRecordingModel(
|
private fun mapToStartCallRecordingModel(
|
||||||
response: GenericMeta
|
response: GenericMeta
|
||||||
): StartCallRecordingModel {
|
): StartCallRecordingModel {
|
||||||
|
@ -67,8 +67,7 @@ class MoreCallActionsDialog(private val callActivity: CallActivity) : BottomShee
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initItemsVisibility() {
|
private fun initItemsVisibility() {
|
||||||
// if (callActivity.isAllowedToRecordCall) {
|
if (callActivity.isAllowedToRecordCall) {
|
||||||
if (true) {
|
|
||||||
binding.recordCall.visibility = View.VISIBLE
|
binding.recordCall.visibility = View.VISIBLE
|
||||||
} else {
|
} else {
|
||||||
binding.recordCall.visibility = View.GONE
|
binding.recordCall.visibility = View.GONE
|
||||||
|
@ -496,6 +496,6 @@ public class ApiUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getUrlForRecording(int version, String baseUrl, String token) {
|
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 RecordingStartLoadingState : ViewState
|
||||||
object RecordingStopLoadingState : ViewState
|
object RecordingStopLoadingState : ViewState
|
||||||
object RecordingConfirmStopState : ViewState
|
object RecordingConfirmStopState : ViewState
|
||||||
|
object RecordingErrorState : ViewState
|
||||||
|
|
||||||
private val _viewState: MutableLiveData<ViewState> = MutableLiveData(RecordingStoppedState)
|
private val _viewState: MutableLiveData<ViewState> = MutableLiveData(RecordingStoppedState)
|
||||||
val viewState: LiveData<ViewState>
|
val viewState: LiveData<ViewState>
|
||||||
@ -60,21 +61,28 @@ class CallRecordingViewModel @Inject constructor(private val repository: CallRec
|
|||||||
_viewState.value = RecordingConfirmStopState
|
_viewState.value = RecordingConfirmStopState
|
||||||
}
|
}
|
||||||
RecordingStoppedState -> {
|
RecordingStoppedState -> {
|
||||||
_viewState.value = RecordingStartLoadingState
|
startRecording()
|
||||||
repository.startRecording(roomToken)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
?.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
?.subscribe(CallStartRecordingObserver())
|
|
||||||
}
|
}
|
||||||
RecordingConfirmStopState -> {
|
RecordingConfirmStopState -> {
|
||||||
// confirm dialog to stop recording might have been dismissed without to click an action.
|
// confirm dialog to stop recording might have been dismissed without to click an action.
|
||||||
// just show it again.
|
// just show it again.
|
||||||
_viewState.value = RecordingConfirmStopState
|
_viewState.value = RecordingConfirmStopState
|
||||||
}
|
}
|
||||||
|
RecordingErrorState -> {
|
||||||
|
stopRecording()
|
||||||
|
}
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun startRecording() {
|
||||||
|
_viewState.value = RecordingStartLoadingState
|
||||||
|
repository.startRecording(roomToken)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
?.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
?.subscribe(CallStartRecordingObserver())
|
||||||
|
}
|
||||||
|
|
||||||
fun stopRecording() {
|
fun stopRecording() {
|
||||||
_viewState.value = RecordingStopLoadingState
|
_viewState.value = RecordingStopLoadingState
|
||||||
repository.stopRecording(roomToken)
|
repository.stopRecording(roomToken)
|
||||||
@ -109,6 +117,7 @@ class CallRecordingViewModel @Inject constructor(private val repository: CallRec
|
|||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
Log.e(TAG, "failure in CallStartRecordingObserver", e)
|
Log.e(TAG, "failure in CallStartRecordingObserver", e)
|
||||||
|
_viewState.value = RecordingErrorState
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
@ -122,11 +131,14 @@ class CallRecordingViewModel @Inject constructor(private val repository: CallRec
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onNext(stopCallRecordingModel: StopCallRecordingModel) {
|
override fun onNext(stopCallRecordingModel: StopCallRecordingModel) {
|
||||||
|
if (stopCallRecordingModel.success) {
|
||||||
_viewState.value = RecordingStoppedState
|
_viewState.value = RecordingStoppedState
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onError(e: Throwable) {
|
override fun onError(e: Throwable) {
|
||||||
Log.e(TAG, "failure in CallStopRecordingObserver", e)
|
Log.e(TAG, "failure in CallStopRecordingObserver", e)
|
||||||
|
_viewState.value = RecordingErrorState
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
|
Loading…
Reference in New Issue
Block a user