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

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

Merge pull request #196 from nextcloud/hideDownload

Add hide_download on files
parents 41696836 cf8513d6
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -98,6 +98,7 @@ public class OCShare implements Parcelable, Serializable {
    private String shareLink;
    private boolean isPasswordProtected;
    private String note;
    private boolean hideFileDownload;
    
    public OCShare() {
    	super();
@@ -134,6 +135,7 @@ public class OCShare implements Parcelable, Serializable {
        shareLink = "";
        isPasswordProtected = false;
        note = "";
        hideFileDownload = false;
    }	
    
    /// Getters and Setters
@@ -278,6 +280,14 @@ public class OCShare implements Parcelable, Serializable {
        return this.note;
    }

    public boolean isHideFileDownload() {
        return hideFileDownload;
    }

    public void setHideFileDownload(boolean hideFileDownload) {
        this.hideFileDownload = hideFileDownload;
    }

    /** 
     * Parcelable Methods
     */
@@ -324,6 +334,7 @@ public class OCShare implements Parcelable, Serializable {
        remoteId = source.readLong();
        shareLink = source.readString();
        isPasswordProtected = source.readInt() == 1;
        hideFileDownload = source.readInt() == 1;
    }


@@ -351,5 +362,6 @@ public class OCShare implements Parcelable, Serializable {
        dest.writeLong(remoteId);
        dest.writeString(shareLink);
        dest.writeInt(isPasswordProtected ? 1 : 0);
        dest.writeInt(hideFileDownload ? 1 : 0);
    }
}
+13 −9
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class ShareXMLParser {
	private static final String NODE_PASSWORD = "password";
	private static final String NODE_SHARE_WITH_DISPLAY_NAME = "share_with_displayname";
	private static final String NODE_NOTE = "note";
    private static final String NODE_HIDE_DOWNLOAD = "hide_download";
	
	private static final String NODE_URL = "url";

@@ -137,14 +138,12 @@ public class ShareXMLParser {

	/**
	 * Parse is as response of Share API
	 * @param is
     * @param is InputStream to parse
	 * @return List of ShareRemoteFiles
	 * @throws XmlPullParserException
	 * @throws IOException
	 */
	public ArrayList<OCShare> parseXMLResponse(InputStream is) throws XmlPullParserException,
			IOException {

    public ArrayList<OCShare> parseXMLResponse(InputStream is) throws XmlPullParserException, IOException {
		try {
			// XMLPullParser
			XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
@@ -361,6 +360,11 @@ public class ShareXMLParser {

            } else if (name.equalsIgnoreCase(NODE_NOTE)) {
                share.setNote(readNode(parser, NODE_NOTE));

            } else if (name.equalsIgnoreCase(NODE_HIDE_DOWNLOAD)) {
                boolean b = "1".equalsIgnoreCase(readNode(parser, NODE_HIDE_DOWNLOAD));
                share.setHideFileDownload(b);

            } else {
                skip(parser);
            } 
+17 −3
Original line number Diff line number Diff line
@@ -58,6 +58,7 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
    private static final String PARAM_PERMISSIONS = "permissions";
    private static final String PARAM_PUBLIC_UPLOAD = "publicUpload";
    private static final String PARAM_NOTE = "note";
    private static final String PARAM_HIDE_DOWNLOAD = "hideDownload";
    private static final String FORMAT_EXPIRATION_DATE = "yyyy-MM-dd";
    private static final String ENTITY_CONTENT_TYPE = "application/x-www-form-urlencoded";
    private static final String ENTITY_CHARSET = "UTF-8";
@@ -88,6 +89,11 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
     */
    private Boolean publicUpload;

    /**
     * Permission if file can be downloaded via share link (only for single file)
     */
    private Boolean hideFileDownload;

    private String note;


@@ -150,6 +156,10 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
        this.publicUpload = publicUpload;
    }

    public void setHideFileDownload(Boolean hideFileDownload) {
        this.hideFileDownload = hideFileDownload;
    }

    public void setNote(String note) {
        this.note = note;
    }
@@ -164,10 +174,10 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
        if (password != null) {
            parametersToUpdate.add(new Pair<>(PARAM_PASSWORD, password));
        }

        if (expirationDateInMillis < 0) {
            // clear expiration date
            parametersToUpdate.add(new Pair<>(PARAM_EXPIRATION_DATE, ""));

        } else if (expirationDateInMillis > 0) {
            // set expiration date
            DateFormat dateFormat = new SimpleDateFormat(FORMAT_EXPIRATION_DATE);
@@ -175,8 +185,8 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
            expirationDate.setTimeInMillis(expirationDateInMillis);
            String formattedExpirationDate = dateFormat.format(expirationDate.getTime());
            parametersToUpdate.add(new Pair<>(PARAM_EXPIRATION_DATE, formattedExpirationDate));
        }
        
        } // else, ignore - no update
        if (permissions > 0) {
            // set permissions
            parametersToUpdate.add(new Pair<>(PARAM_PERMISSIONS, Integer.toString(permissions)));
@@ -186,6 +196,10 @@ public class UpdateRemoteShareOperation extends RemoteOperation {
            parametersToUpdate.add(new Pair<>(PARAM_PUBLIC_UPLOAD, Boolean.toString(publicUpload)));
        }

        if (hideFileDownload != null) {
            parametersToUpdate.add(new Pair<>(PARAM_HIDE_DOWNLOAD, Boolean.toString(hideFileDownload)));
        }

        parametersToUpdate.add(new Pair<>(PARAM_NOTE, note));

        /// perform required PUT requests