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

Unverified Commit e5e096b1 authored by Andy Scherzinger's avatar Andy Scherzinger Committed by GitHub
Browse files

Merge pull request #179 from nextcloud/noteOnShare

Add note to OCShare
parents 8fd0dd40 b29090c2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@
    android:versionName="1.0.13" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="26"/>

    <uses-permission
+4 −1
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ android {
        }

        // Move the tests to tests/java, tests/res, etc...
        instrumentTest.setRoot('tests')
        // instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
@@ -58,4 +58,7 @@ android {
        htmlOutput file("$project.buildDir/reports/lint/lint.html")
        disable 'MissingTranslation'
    }
    defaultConfig {
        minSdkVersion 14
    }
}
+64 −22
Original line number Diff line number Diff line
@@ -49,6 +49,9 @@ public class WebdavEntry {
    public static final String EXTENDED_PROPERTY_FAVORITE = "favorite";
    public static final String EXTENDED_PROPERTY_IS_ENCRYPTED = "is-encrypted";
    public static final String EXTENDED_PROPERTY_MOUNT_TYPE = "mount-type";
    public static final String EXTENDED_PROPERTY_OWNER_ID = "owner-id";
    public static final String EXTENDED_PROPERTY_OWNER_DISPLAY_NAME = "owner-display-name";
    public static final String EXTENDED_PROPERTY_UNREAD_COMMENTS = "comments-unread";
    public static final String TRASHBIN_FILENAME = "trashbin-filename";
    public static final String TRASHBIN_ORIGINAL_LOCATION = "trashbin-original-location";
    public static final String TRASHBIN_DELETION_TIME = "trashbin-deletion-time";
@@ -76,11 +79,18 @@ public class WebdavEntry {
    private MountType mMountType;
    private long mContentLength, mCreateTimestamp, mModifiedTimestamp, mSize;
    private BigDecimal mQuotaUsedBytes, mQuotaAvailableBytes;
    private String ownerId;
    private String ownerDisplayName;
    private int mUnreadCommentsCount;

    public enum MountType {INTERNAL, EXTERNAL}

    public WebdavEntry(MultiStatusResponse ms, String splitElement) {
        resetData();

        Namespace ocNamespace = Namespace.getNamespace(NAMESPACE_OC);
        Namespace ncNamespace = Namespace.getNamespace(NAMESPACE_NC);
        
        if (ms.getStatus().length != 0) {
            mUri = ms.getHref();

@@ -94,7 +104,7 @@ public class WebdavEntry {
            @SuppressWarnings("rawtypes")
            DavProperty prop = propSet.get(DavPropertyName.DISPLAYNAME);
            if (prop != null) {
                mName = (String) prop.getName().toString();
                mName = prop.getName().toString();
                mName = mName.substring(1, mName.length()-1);
            }
            else {
@@ -135,21 +145,20 @@ public class WebdavEntry {

            // {DAV:}getcontentlength
            prop = propSet.get(DavPropertyName.GETCONTENTLENGTH);
            if (prop != null)
            if (prop != null) {
                mContentLength = Long.parseLong((String) prop.getValue());
            }

            // {DAV:}getlastmodified
            prop = propSet.get(DavPropertyName.GETLASTMODIFIED);
            if (prop != null) {
                Date d = WebdavUtils
                        .parseResponseDate((String) prop.getValue());
                Date d = WebdavUtils.parseResponseDate((String) prop.getValue());
                mModifiedTimestamp = (d != null) ? d.getTime() : 0;
            }

            prop = propSet.get(DavPropertyName.CREATIONDATE);
            if (prop != null) {
                Date d = WebdavUtils
                        .parseResponseDate((String) prop.getValue());
                Date d = WebdavUtils.parseResponseDate((String) prop.getValue());
                mCreateTimestamp = (d != null) ? d.getTime() : 0;
            }

@@ -189,32 +198,25 @@ public class WebdavEntry {
            }

            // OC permissions property <oc:permissions>
            prop = propSet.get(
            		EXTENDED_PROPERTY_NAME_PERMISSIONS, Namespace.getNamespace(NAMESPACE_OC)
    		);
            prop = propSet.get(EXTENDED_PROPERTY_NAME_PERMISSIONS, ocNamespace);
            if (prop != null && prop.getValue() != null) {
                mPermissions = prop.getValue().toString();
            }

            // OC remote id property <oc:id>
            prop = propSet.get(
            		EXTENDED_PROPERTY_NAME_REMOTE_ID, Namespace.getNamespace(NAMESPACE_OC)
    		);
            prop = propSet.get(EXTENDED_PROPERTY_NAME_REMOTE_ID, ocNamespace);
            if (prop != null) {
                mRemoteId = prop.getValue().toString();
            }

            // TODO: is it necessary?
            // OC size property <oc:size>
            prop = propSet.get(
            		EXTENDED_PROPERTY_NAME_SIZE, Namespace.getNamespace(NAMESPACE_OC)
    		);
            prop = propSet.get(EXTENDED_PROPERTY_NAME_SIZE, ocNamespace);
            if (prop != null) {
                mSize = Long.parseLong((String) prop.getValue());
            }

            // OC favorite property <oc:favorite>
            prop = propSet.get(EXTENDED_PROPERTY_FAVORITE,  Namespace.getNamespace(NAMESPACE_OC));
            prop = propSet.get(EXTENDED_PROPERTY_FAVORITE, ocNamespace);
            if (prop != null) {
                String favoriteValue = (String) prop.getValue();
                mIsFavorite = IS_ENCRYPTED.equals(favoriteValue);
@@ -223,7 +225,7 @@ public class WebdavEntry {
            }

            // NC encrypted property <nc:is-encrypted>
            prop = propSet.get(EXTENDED_PROPERTY_IS_ENCRYPTED,  Namespace.getNamespace(NAMESPACE_NC));
            prop = propSet.get(EXTENDED_PROPERTY_IS_ENCRYPTED, ncNamespace);
            if (prop != null) {
                String encryptedValue = (String) prop.getValue();
                mIsEncrypted = IS_ENCRYPTED.equals(encryptedValue);
@@ -232,7 +234,7 @@ public class WebdavEntry {
            }

            // NC mount-type property <nc:mount-type>
            prop = propSet.get(EXTENDED_PROPERTY_MOUNT_TYPE, Namespace.getNamespace(NAMESPACE_NC));
            prop = propSet.get(EXTENDED_PROPERTY_MOUNT_TYPE, ncNamespace);
            if (prop != null) {
                if ("external".equals(prop.getValue())) {
                    mMountType = MountType.EXTERNAL;
@@ -243,20 +245,44 @@ public class WebdavEntry {
                mMountType = MountType.INTERNAL;
            }

            // OC owner-id property <oc:owner-id>
            prop = propSet.get(EXTENDED_PROPERTY_OWNER_ID, ocNamespace);
            if (prop != null) {
                ownerId = (String) prop.getValue();
            } else {
                ownerId = "";
            }

            // OC owner-display-name property <oc:owner-display-name>
            prop = propSet.get(EXTENDED_PROPERTY_OWNER_DISPLAY_NAME, ocNamespace);
            if (prop != null) {
                ownerDisplayName = (String) prop.getValue();
            } else {
                ownerDisplayName = "";
            }

            // OC unread comments property <oc-comments-unread>
            prop = propSet.get(EXTENDED_PROPERTY_UNREAD_COMMENTS, ocNamespace);
            if (prop != null) {
                mUnreadCommentsCount = Integer.valueOf(prop.getValue().toString());
            } else {
                mUnreadCommentsCount = 0;
            }
            
            // NC trashbin-original-location <nc:trashbin-original-location>
            prop = propSet.get(TRASHBIN_ORIGINAL_LOCATION, Namespace.getNamespace(NAMESPACE_NC));
            prop = propSet.get(TRASHBIN_ORIGINAL_LOCATION, ncNamespace);
            if (prop != null) {
                mTrashbinOriginalLocation = prop.getValue().toString();
            }

            // NC trashbin-filename <nc:trashbin-filename>
            prop = propSet.get(TRASHBIN_FILENAME, Namespace.getNamespace(NAMESPACE_NC));
            prop = propSet.get(TRASHBIN_FILENAME, ncNamespace);
            if (prop != null) {
                mTrashbinFilename = prop.getValue().toString();
            }

            // NC trashbin-deletion-time <nc:trashbin-deletion-time>
            prop = propSet.get(TRASHBIN_DELETION_TIME, Namespace.getNamespace(NAMESPACE_NC));
            prop = propSet.get(TRASHBIN_DELETION_TIME, ncNamespace);
            if (prop != null) {
                mTrashbinDeletionTimestamp = Long.parseLong((String) prop.getValue());
            }
@@ -353,6 +379,22 @@ public class WebdavEntry {
        return mTrashbinDeletionTimestamp;
    }

    public String getOwnerId() {
        return ownerId;
    }

    public void setOwnerDisplayName(String ownerDisplayName) {
        this.ownerDisplayName = ownerDisplayName;
    }

    public String getOwnerDisplayName() {
        return ownerDisplayName;
    }

    public int getUnreadCommentsCount() {
        return mUnreadCommentsCount;
    }

    private void resetData() {
        mName = mUri = mContentType = mPermissions = null; mRemoteId = null;
        mContentLength = mCreateTimestamp = mModifiedTimestamp = 0;
+12 −7
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@ public class WebdavUtils {
     * @return
     */
    public static DavPropertyNameSet getAllPropSet() {
        Namespace ocNamespace = Namespace.getNamespace(WebdavEntry.NAMESPACE_OC);
        Namespace ncNamespace = Namespace.getNamespace(WebdavEntry.NAMESPACE_NC);
        DavPropertyNameSet propSet = new DavPropertyNameSet();
        propSet.add(DavPropertyName.DISPLAYNAME);
        propSet.add(DavPropertyName.GETCONTENTTYPE);
@@ -99,12 +101,15 @@ public class WebdavUtils {
        propSet.add(DavPropertyName.GETLASTMODIFIED);
        propSet.add(DavPropertyName.CREATIONDATE);
        propSet.add(DavPropertyName.GETETAG);
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PERMISSIONS, Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID, Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_FAVORITE, Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_IS_ENCRYPTED, Namespace.getNamespace(WebdavEntry.NAMESPACE_NC));
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_MOUNT_TYPE, Namespace.getNamespace(WebdavEntry.NAMESPACE_NC));
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_PERMISSIONS, ocNamespace);
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_REMOTE_ID, ocNamespace);
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_NAME_SIZE, ocNamespace);
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_FAVORITE, ocNamespace);
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_IS_ENCRYPTED, ncNamespace);
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_MOUNT_TYPE, ncNamespace);
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_OWNER_ID, ocNamespace);
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_OWNER_DISPLAY_NAME, ocNamespace);
        propSet.add(WebdavEntry.EXTENDED_PROPERTY_UNREAD_COMMENTS, ocNamespace);

        return propSet;
    }
+87 −0
Original line number Diff line number Diff line
/*
 * Nextcloud Android client application
 *
 * @author Tobias Kaminsky
 * Copyright (C) 2018 Tobias Kaminsky
 * Copyright (C) 2018 Nextcloud GmbH.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
 */

package com.owncloud.android.lib.resources.files;

import com.owncloud.android.lib.common.OwnCloudClient;
import com.owncloud.android.lib.common.network.WebdavEntry;
import com.owncloud.android.lib.common.operations.RemoteOperation;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;

import org.apache.commons.httpclient.HttpStatus;
import org.apache.jackrabbit.webdav.client.methods.PropPatchMethod;
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
import org.apache.jackrabbit.webdav.property.DavPropertySet;
import org.apache.jackrabbit.webdav.property.DefaultDavProperty;
import org.apache.jackrabbit.webdav.xml.Namespace;

import java.io.IOException;

/**
 * Mark all comments for a file as read
 */
public class MarkCommentsAsReadOperation extends RemoteOperation {
    private static final String COMMENTS_URL = "/comments/files/";

    private String fileId;

    public MarkCommentsAsReadOperation(String fileId) {
        this.fileId = fileId;
    }

    @Override
    protected RemoteOperationResult run(OwnCloudClient client) {
        RemoteOperationResult result;
        PropPatchMethod propPatchMethod = null;

        DavPropertySet newProps = new DavPropertySet();
        DavPropertyNameSet removeProperties = new DavPropertyNameSet();

        DefaultDavProperty<String> readMarkerProperty = new DefaultDavProperty<>("oc:readMarker", "",
                Namespace.getNamespace(WebdavEntry.NAMESPACE_OC));
        newProps.add(readMarkerProperty);

        String commentsPath = client.getNewWebdavUri() + COMMENTS_URL + fileId;

        try {
            propPatchMethod = new PropPatchMethod(commentsPath, newProps, removeProperties);
            int status = client.executeMethod(propPatchMethod);

            boolean isSuccess = status == HttpStatus.SC_NO_CONTENT || status == HttpStatus.SC_OK ||
                    status == HttpStatus.SC_MULTI_STATUS;

            if (isSuccess) {
                result = new RemoteOperationResult(true, status, propPatchMethod.getResponseHeaders());
            } else {
                client.exhaustResponse(propPatchMethod.getResponseBodyAsStream());
                result = new RemoteOperationResult(false, status, propPatchMethod.getResponseHeaders());
            }
        } catch (IOException e) {
            result = new RemoteOperationResult(e);
        } finally {
            if (propPatchMethod != null) {
                propPatchMethod.releaseConnection();
            }
        }

        return result;
    }
}
Loading