From a7efcf6a2f5d9ad32a016f954e6e403f3a28cf4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Carlos=20Gonz=C3=A1lez=20Cabrero?= Date: Mon, 29 Feb 2016 14:15:15 +0100 Subject: [PATCH] Add the remote suggestion to the MatrixCursor instead of the JSON array, wich could not parse the path correctly --- res/values/strings.xml | 1 + .../UsersAndGroupsSearchProvider.java | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index bb00b4ed0a..114b86994c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -388,6 +388,7 @@ Search users and groups %1$s (group) + %1$s (remote) Sorry, your server version does not allow share with users within clients. \nPlease contact your administrator diff --git a/src/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java b/src/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java index 3d2c6caf21..3e82231699 100644 --- a/src/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java +++ b/src/com/owncloud/android/providers/UsersAndGroupsSearchProvider.java @@ -72,6 +72,7 @@ public class UsersAndGroupsSearchProvider extends ContentProvider { public static final String ACTION_SHARE_WITH = AUTHORITY + ".action.SHARE_WITH"; public static final String DATA_USER = AUTHORITY + ".data.user"; public static final String DATA_GROUP = AUTHORITY + ".data.group"; + public static final String DATA_REMOTE = AUTHORITY + ".data.remote"; private UriMatcher mUriMatcher; @@ -140,31 +141,21 @@ public class UsersAndGroupsSearchProvider extends ContentProvider { // Get JSonObjects from response names.add((JSONObject) o); } - // add a remote user suggestion if the query has the character '@' - if (userQuery.contains("@")) { - try { - names.add(new JSONObject("{\"" + GetRemoteShareesOperation.NODE_VALUE + "\":{\"" + - GetRemoteShareesOperation.PROPERTY_SHARE_WITH + "\":" + userQuery + "\",\"" + - GetRemoteShareesOperation.PROPERTY_SHARE_TYPE + "\":6}," + - "\"" + GetRemoteShareesOperation.PROPERTY_LABEL + "\":\"" + userQuery + " (remote)\"}]}")); - } catch (JSONException e) { - e.printStackTrace(); - } - } } else { showErrorMessage(result); } /// convert the responses from the OC server to the expected format + int count = 0; if (names.size() > 0) { response = new MatrixCursor(COLUMNS); Iterator namesIt = names.iterator(); - int count = 0; JSONObject item; String displayName; Uri dataUri; Uri userBaseUri = new Uri.Builder().scheme("content").authority(DATA_USER).build(); Uri groupBaseUri = new Uri.Builder().scheme("content").authority(DATA_GROUP).build(); + try { while (namesIt.hasNext()) { item = namesIt.next(); @@ -184,11 +175,23 @@ public class UsersAndGroupsSearchProvider extends ContentProvider { .add(displayName) // SearchManager.SUGGEST_COLUMN_TEXT_1 .add(dataUri); } + } catch (JSONException e) { Log_OC.e(TAG, "Exception while parsing data of users/groups", e); } } + // add a remote user suggestion if the query has the character '@' + if (userQuery.contains("@")) { + if (response == null) + response = new MatrixCursor(COLUMNS); + + Uri remoteBaseUri = new Uri.Builder().scheme("content").authority(DATA_REMOTE).build(); + String displayName = getContext().getString(R.string.share_remote_clarification, userQuery); + Uri dataUri = Uri.withAppendedPath(remoteBaseUri, userQuery); + response.newRow().add(count++).add(displayName).add(dataUri); + } + return response; }