Add support for favorite api

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2018-07-14 16:12:03 +02:00
parent 92377f1309
commit 969a095f61
4 changed files with 18 additions and 2 deletions

View File

@ -289,4 +289,13 @@ public interface NcApi {
@Url String url, @Query("search") String query,
@Nullable @Query("limit") Integer limit);
// Url is: /api/{apiVersion}/room/{token}/favorite
@POST
Observable<GenericOverall> addConversationToFavorites(@Header("Authorization") String authorization,
@Url String url);
// Url is: /api/{apiVersion}/room/{token}/favorite
@DELETE
Observable<GenericOverall> removeConversationFromFavorites(@Header("Authorization") String authorization,
@Url String url);
}

View File

@ -63,6 +63,8 @@ public class Room {
@JsonField(name = "sessionId")
public String sessionId;
public String password;
@JsonField(name = "isFavorite")
public boolean isFavorite;
public boolean isPublic() {
return (RoomType.ROOM_PUBLIC_CALL.equals(type));

View File

@ -187,4 +187,8 @@ public class ApiUtils {
return NextcloudTalkApplication.getSharedApplication().
getApplicationContext().getResources().getString(R.string.nc_push_server_url) + "/devices";
}
public static String getUrlForConversationFavorite(String baseUrl, String roomToken) {
return baseUrl + ocsApiVersion + "/room/" + roomToken + "/favorite";
}
}

View File

@ -132,7 +132,7 @@ public final class EmoticonUtils {
if (!TextUtils.isEmpty(text)) {
// Regexp acquired from https://gist.github.com/sergeychilingaryan/94902985a636658496cb69c300bba05f
String regexString = "(?:[\\u2700-\\u27bf]|" +
String unicode10regexString = "(?:[\\u2700-\\u27bf]|" +
"(?:[\\ud83c\\udde6-\\ud83c\\uddff]){2}|" +
"[\\ud800\\udc00-\\uDBFF\\uDFFF]|[\\u2600-\\u26FF])[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|[\\ud83c\\udffb-\\ud83c\\udfff])?" +
@ -143,7 +143,8 @@ public final class EmoticonUtils {
"[\\ud800\\udc00-\\uDBFF\\uDFFF]|[\\u2600-\\u26FF])[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe23\\u20d0-\\u20f0]|[\\ud83c\\udffb-\\ud83c\\udfff])?)*|" +
"[\\u0023-\\u0039]\\ufe0f?\\u20e3|\\u3299|\\u3297|\\u303d|\\u3030|\\u24c2|[\\ud83c\\udd70-\\ud83c\\udd71]|[\\ud83c\\udd7e-\\ud83c\\udd7f]|\\ud83c\\udd8e|[\\ud83c\\udd91-\\ud83c\\udd9a]|[\\ud83c\\udde6-\\ud83c\\uddff]|[\\ud83c\\ude01-\\ud83c\\ude02]|\\ud83c\\ude1a|\\ud83c\\ude2f|[\\ud83c\\ude32-\\ud83c\\ude3a]|[\\ud83c\\ude50-\\ud83c\\ude51]|\\u203c|\\u2049|[\\u25aa-\\u25ab]|\\u25b6|\\u25c0|[\\u25fb-\\u25fe]|\\u00a9|\\u00ae|\\u2122|\\u2139|\\ud83c\\udc04|[\\u2600-\\u26FF]|\\u2b05|\\u2b06|\\u2b07|\\u2b1b|\\u2b1c|\\u2b50|\\u2b55|\\u231a|\\u231b|\\u2328|\\u23cf|[\\u23e9-\\u23f3]|[\\u23f8-\\u23fa]|\\ud83c\\udccf|\\u2934|\\u2935|[\\u2190-\\u21ff]";
final Matcher matcher = Pattern.compile(regexString, Pattern.UNICODE_CASE).matcher(text);
final Matcher matcher = Pattern.compile(unicode10regexString, Pattern.UNICODE_CASE).matcher(text);
while (matcher.find()) {
String unicode = text.subSequence(matcher.start(), matcher.end()).toString();
// quick hack