Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 1303dc7a authored by Tobias Kaminsky's avatar Tobias Kaminsky Committed by GitHub
Browse files

Merge branch 'master' into lint

parents b0115529 6f3211a8
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -94,7 +94,10 @@ public class ExternalLinksOperation extends RemoteOperation {
                        if (link != null) {
                            Integer id = link.getInt(NODE_ID);
                            String iconUrl = link.getString(NODE_ICON);
                            String language = link.getString(NODE_LANGUAGE);
                            String language = "";
                            if (link.has(NODE_LANGUAGE)) {
                                language = link.getString(NODE_LANGUAGE);
                            }

                            ExternalLinkType type;
                            switch (link.getString(NODE_TYPE)) {
+2 −2
Original line number Diff line number Diff line
@@ -558,13 +558,13 @@ public class RemoteOperationResult implements Serializable {
        }

        if (mCode == ResultCode.INSTANCE_NOT_CONFIGURED) {
            return "The ownCloud server is not configured!";
            return "The Nextcloud server is not configured!";

        } else if (mCode == ResultCode.NO_NETWORK_CONNECTION) {
            return "No network connection";

        } else if (mCode == ResultCode.BAD_OC_VERSION) {
            return "No valid ownCloud version was found at the server";
            return "No valid Nextcloud version was found at the server";

        } else if (mCode == ResultCode.LOCAL_STORAGE_FULL) {
            return "Local storage full";
+37 −6
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.owncloud.android.lib.resources.activities.models.RichElement;
import com.owncloud.android.lib.resources.activities.models.RichElementTypeAdapter;
import com.owncloud.android.lib.resources.status.OwnCloudVersion;

import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
import org.json.JSONException;
@@ -68,18 +69,28 @@ public class GetRemoteActivitiesOperation extends RemoteOperation{

    private static final String NODE_DATA = "data";

    private String nextUrl = "";

    public void setNextUrl(String url) {
        nextUrl = url;
    }

    @Override
    protected RemoteOperationResult run(OwnCloudClient client) {
        RemoteOperationResult result = null;
        int status = -1;
        GetMethod get = null;
        ArrayList<Object> activities;
        ArrayList<Activity> activities;
        String url;
        if (nextUrl.isEmpty()) {
            if (client.getOwnCloudVersion().compareTo(OwnCloudVersion.nextcloud_12) >= 0) {
                url = client.getBaseUri() + OCS_ROUTE_V12_AND_UP;
            } else {
                url = client.getBaseUri() + OCS_ROUTE_PRE_V12;
            }
        } else {
            url = nextUrl;
        }
        Log_OC.d(TAG, "URL: " + url);

        try {
@@ -89,12 +100,28 @@ public class GetRemoteActivitiesOperation extends RemoteOperation{
            status = client.executeMethod(get);
            String response = get.getResponseBodyAsString();

            Header nextPageHeader = get.getResponseHeader("Link");
            if (nextPageHeader != null) {
                String link = nextPageHeader.getValue();
                if (link.startsWith("<") && link.endsWith(">; rel=\"next\"")) {
                    nextUrl = nextPageHeader.getValue().substring(1, link.length() - 13);
                } else {
                    nextUrl = "";
                }
            } else {
                nextUrl = "";
            }

            if (isSuccess(status)) {
                Log_OC.d(TAG, "Successful response: " + response);
                result = new RemoteOperationResult(true, status, get.getResponseHeaders());
                // Parse the response
                activities = parseResult(response);
                result.setData(activities);

                ArrayList<Object> data = new ArrayList<>();
                data.add(activities);
                data.add(nextUrl);
                result.setData(data);
            } else {
                result = new RemoteOperationResult(false, status, get.getResponseHeaders());
                Log_OC.e(TAG, "Failed response while getting user activities ");
@@ -116,7 +143,11 @@ public class GetRemoteActivitiesOperation extends RemoteOperation{
        return result;
    }

    private ArrayList<Object> parseResult(String response) throws JSONException {
    public boolean hasMoreActivities() {
        return !nextUrl.isEmpty();
    }

    private ArrayList<Activity> parseResult(String response) throws JSONException {
        JsonParser jsonParser = new JsonParser();
        JsonObject jo = (JsonObject)jsonParser.parse(response);
        JsonArray jsonDataArray = jo.getAsJsonObject(NODE_OCS).getAsJsonArray(NODE_DATA);
+12 −1
Original line number Diff line number Diff line
@@ -137,7 +137,16 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
                        }
                    }
                }
                if (transferred == totalToTransfer) {  // Check if the file is completed
                // Check if the file is completed
                // if transfer-encoding: chunked we cannot check if the file is complete
                Header transferEncodingHeader = mGet.getResponseHeader("Transfer-Encoding");
                boolean transferEncoding = false;

                if (transferEncodingHeader != null) {
                    transferEncoding = transferEncodingHeader.getValue().equals("chunked");
                }
                
                if (transferred == totalToTransfer || transferEncoding) {  
                    savedFile = true;
                    Header modificationTime = mGet.getResponseHeader("Last-Modified");
                    if (modificationTime == null) {
@@ -164,6 +173,8 @@ public class DownloadRemoteFileOperation extends RemoteOperation {
                client.exhaustResponse(mGet.getResponseBodyAsStream());
            }

        } catch (Exception e) {
          Log_OC.e(TAG, e.getMessage());  
        } finally {
            if (fos != null) fos.close();
            if (!savedFile && targetFile.exists()) {
+36 −0
Original line number Diff line number Diff line
@@ -107,6 +107,8 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation {
    private static final String PROPERTY_SERVERNAME = "name";
    private static final String PROPERTY_SERVERSLOGAN = "slogan";
    private static final String PROPERTY_SERVERCOLOR = "color";
    private static final String PROPERTY_SERVERTEXTCOLOR = "color-text";
    private static final String PROPERTY_SERVERELEMENTCOLOR = "color-element";
    private static final String PROPERTY_SERVERLOGO = "logo";
    private static final String PROPERTY_SERVERBACKGROUND = "background";

@@ -287,6 +289,14 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation {
                                    respTheming.getString(PROPERTY_SERVERBACKGROUND) != null) {
                                capability.setServerBackground(respTheming.getString(PROPERTY_SERVERBACKGROUND));
                            }
                            if (respTheming.has(PROPERTY_SERVERTEXTCOLOR) && 
                                    respTheming.getString(PROPERTY_SERVERTEXTCOLOR) != null) {
                                capability.setServerTextColor(respTheming.getString(PROPERTY_SERVERTEXTCOLOR));
                            }
                            if (respTheming.has(PROPERTY_SERVERELEMENTCOLOR) && 
                                    respTheming.getString(PROPERTY_SERVERELEMENTCOLOR) != null) {
                                capability.setServerElementColor(respTheming.getString(PROPERTY_SERVERELEMENTCOLOR));
                            }
                            Log_OC.d(TAG, "*** Added " + NODE_THEMING);
                        }

@@ -323,7 +333,33 @@ public class GetRemoteCapabilitiesOperation extends RemoteOperation {
                            }
                        }
                        
                        if (respCapabilities.has("fullnextsearch")) {
                            JSONObject respFullNextSearch = respCapabilities.getJSONObject("fullnextsearch");

                            if (respFullNextSearch.getBoolean("remote")) {
                                capability.setFullNextSearchEnabled(CapabilityBooleanType.TRUE);
                            } else {
                                capability.setFullNextSearchEnabled(CapabilityBooleanType.FALSE);
                            }

                            JSONArray providers = respFullNextSearch.getJSONArray("providers");
                            
                            for (int i = 0; i < providers.length(); i++) {
                                JSONObject provider = (JSONObject) providers.get(i);
                                
                                String id = provider.getString("id");
                                
                                switch (id) {
                                    case "files":
                                        capability.setFullNextSearchFiles(CapabilityBooleanType.TRUE);
                                        Log_OC.d(TAG, "full next search: file provider enabled");
                                    default:
                                        // do nothing
                                }
                            }
                        }
                    }
                    
                    // Result
                    data.add(capability);
                    result = new RemoteOperationResult(true, get);
Loading