Browse Source

Use status from lib

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 years ago
parent
commit
cfb3778a9a

+ 0 - 36
src/main/java/com/nextcloud/ui/ClearStatusTask.kt

@@ -1,36 +0,0 @@
-/*
- *
- * Nextcloud Android client application
- *
- * @author Tobias Kaminsky
- * Copyright (C) 2020 Tobias Kaminsky
- * Copyright (C) 2020 Nextcloud GmbH
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package com.nextcloud.ui
-
-import android.accounts.Account
-import android.content.Context
-import com.owncloud.android.lib.common.OwnCloudClientFactory
-import com.owncloud.android.lib.resources.users.ClearStatusMessageRemoteOperation
-
-public class ClearStatusTask(val account: Account?, val context: Context?) : Function0<Boolean> {
-    override fun invoke(): Boolean {
-        val client = OwnCloudClientFactory.createNextcloudClient(account, context)
-
-        return ClearStatusMessageRemoteOperation().execute(client).isSuccess
-    }
-}

+ 18 - 15
src/main/java/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java

@@ -73,10 +73,14 @@ import androidx.annotation.Nullable;
 import dagger.android.AndroidInjection;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
+import static com.owncloud.android.lib.resources.shares.GetShareesRemoteOperation.PROPERTY_CLEAR_AT;
+import static com.owncloud.android.lib.resources.shares.GetShareesRemoteOperation.PROPERTY_ICON;
+import static com.owncloud.android.lib.resources.shares.GetShareesRemoteOperation.PROPERTY_MESSAGE;
+import static com.owncloud.android.lib.resources.shares.GetShareesRemoteOperation.PROPERTY_STATUS;
+
 
 /**
- * Content provider for search suggestions, to search for users and groups existing in an ownCloud
- * server.
+ * Content provider for search suggestions, to search for users and groups existing in an ownCloud server.
  */
 public class UsersAndGroupsSearchProvider extends ContentProvider {
 
@@ -112,7 +116,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
     @Inject
     protected UserAccountManager accountManager;
 
-    private static Map<String, ShareType> sShareTypes = new HashMap<>();
+    private static final Map<String, ShareType> sShareTypes = new HashMap<>();
 
     public static ShareType getShareType(String authority) {
 
@@ -181,13 +185,10 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
         Log_OC.d(TAG, "query received in thread " + Thread.currentThread().getName());
 
         int match = mUriMatcher.match(uri);
-        switch (match) {
-            case SEARCH:
-                return searchForUsersOrGroups(uri);
-
-            default:
-                return null;
+        if (match == SEARCH) {
+            return searchForUsersOrGroups(uri);
         }
+        return null;
     }
 
     private Cursor searchForUsersOrGroups(Uri uri) {
@@ -258,13 +259,14 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
                     String shareWith = value.getString(GetShareesRemoteOperation.PROPERTY_SHARE_WITH);
 
                     Status status;
-                    JSONObject statusObject = item.optJSONObject("status");
+                    JSONObject statusObject = item.optJSONObject(PROPERTY_STATUS);
 
                     if (statusObject != null) {
-                        status = new Status(StatusType.valueOf(statusObject.getString("status")),
-                                            statusObject.isNull("message") ? "" : statusObject.getString("message"),
-                                            statusObject.isNull("icon") ? "" : statusObject.getString("icon"),
-                                            statusObject.isNull("clearAt") ? -1 : statusObject.getLong("clearAt"));
+                        status = new Status(
+                            StatusType.valueOf(statusObject.getString(PROPERTY_STATUS)),
+                            statusObject.isNull(PROPERTY_MESSAGE) ? "" : statusObject.getString(PROPERTY_MESSAGE),
+                            statusObject.isNull(PROPERTY_ICON) ? "" : statusObject.getString(PROPERTY_ICON),
+                            statusObject.isNull(PROPERTY_CLEAR_AT) ? -1 : statusObject.getLong(PROPERTY_CLEAR_AT));
                     } else {
                         status = new Status(StatusType.OFFLINE, "", "", -1);
                     }
@@ -295,7 +297,8 @@ public class UsersAndGroupsSearchProvider extends ContentProvider {
 
                         case USER:
                             displayName = userName;
-                            subline = status.getMessage().isEmpty() ? null : status.getMessage();
+                            subline = (status.getMessage() == null || status.getMessage().isEmpty()) ? null :
+                                status.getMessage();
                             Uri.Builder builder =
                                 Uri.parse("content://com.nextcloud.android.providers.UsersAndGroupsSearchProvider/icon")
                                     .buildUpon();

+ 0 - 29
src/main/java/com/owncloud/android/ui/adapter/PredefinedStatusClickListener.kt

@@ -1,29 +0,0 @@
-/*
- *
- * Nextcloud Android client application
- *
- * @author Tobias Kaminsky
- * Copyright (C) 2020 Tobias Kaminsky
- * Copyright (C) 2020 Nextcloud GmbH
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-package com.owncloud.android.ui.adapter
-
-import com.owncloud.android.lib.resources.users.PredefinedStatus
-
-interface PredefinedStatusClickListener {
-    fun onClick(predefinedStatus: PredefinedStatus)
-}

+ 1 - 0
src/main/res/drawable/ic_talk.xml

@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
 <!--
   Nextcloud Android client application