add ability to set status type

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2022-02-08 12:25:30 +01:00
parent 19060bddbd
commit 45cfbc7257
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
3 changed files with 24 additions and 13 deletions

View file

@ -472,4 +472,10 @@ public interface NcApi {
@Field("statusIcon") String statusIcon,
@Field("message") String message,
@Field("clearAt") Long clearAt);
@FormUrlEncoded
@PUT
Observable<GenericOverall> setStatusType(@Header("Authorization") String authorization,
@Url String url,
@Field("statusType") String statusType);
}

View file

@ -352,19 +352,20 @@ class SetStatusDialogFragment :
private fun setStatus(statusType: StatusType) {
visualizeStatus(statusType)
// asyncRunner.postQuickTask(
// SetStatusTask(
// statusType,
// accountManager.currentOwnCloudAccount?.savedAccount,
// context
// ),
// {
// if (!it) {
// clearTopStatus()
// }
// },
// { clearTopStatus() }
// )
ncApi.setStatusType(credentials, ApiUtils.getUrlForSetStatusType(currentUser?.baseUrl), statusType.string)
.subscribeOn(Schedulers
.io())
.observeOn(AndroidSchedulers.mainThread()).subscribe(object : Observer<GenericOverall> {
override fun onSubscribe(d: Disposable) {}
override fun onNext(statusOverall: GenericOverall) {
Log.d(TAG, "statusType successfully set")
}
override fun onError(e: Throwable) {
Log.e(logTag, "Failed to set statusType", e)
clearTopStatus()
}
override fun onComplete() {}
})
}
private fun visualizeStatus(statusType: String) {

View file

@ -425,6 +425,10 @@ public class ApiUtils {
return baseUrl + ocsApiVersion + "/apps/user_status/api/v1/user_status";
}
public static String getUrlForSetStatusType(String baseUrl) {
return getUrlForStatus(baseUrl) + "/status";
}
public static String getUrlForPredefinedStatuses(String baseUrl) {
return baseUrl + ocsApiVersion + "/apps/user_status/api/v1/predefined_statuses";
}