mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-22 21:15:30 +03:00
add ability to set status type
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
19060bddbd
commit
45cfbc7257
3 changed files with 24 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue