mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 22:34:15 +01:00
do not allow selecting files in files browser that are not allowed to be reshared
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
83c74713c9
commit
68c09d8e81
@ -18,6 +18,7 @@ Types of changes can be: Added/Changed/Deprecated/Removed/Fixed/Security
|
||||
- delete "chat via"-link from phonebook if phone number was deleted on server
|
||||
- remove all "chat via"-links from phonebook when sync is disabled
|
||||
- fix to show avatars for incoming pictures in group chats (@starypatyk)
|
||||
- do not allow selecting files in files browser that are not allowed to be reshared
|
||||
|
||||
## [11.1.0] - 2021-03-12
|
||||
### Added
|
||||
|
@ -26,6 +26,8 @@ import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import autodagger.AutoInjector;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
@ -102,17 +104,21 @@ public class BrowserFileItem extends AbstractFlexibleItem<BrowserFileItem.ViewHo
|
||||
@Override
|
||||
public void bindViewHolder(FlexibleAdapter<IFlexible> adapter, ViewHolder holder, int position, List<Object> payloads) {
|
||||
holder.fileIconImageView.setController(null);
|
||||
|
||||
if (browserFile.isEncrypted()) {
|
||||
holder.fileEncryptedImageView.setVisibility(View.VISIBLE);
|
||||
if (!browserFile.isAllowedToReShare() || browserFile.isEncrypted()) {
|
||||
holder.itemView.setEnabled(false);
|
||||
holder.itemView.setAlpha(0.38f);
|
||||
} else {
|
||||
holder.fileEncryptedImageView.setVisibility(View.GONE);
|
||||
holder.itemView.setEnabled(true);
|
||||
holder.itemView.setAlpha(1.0f);
|
||||
}
|
||||
|
||||
if (browserFile.isEncrypted()) {
|
||||
holder.fileEncryptedImageView.setVisibility(View.VISIBLE);
|
||||
|
||||
} else {
|
||||
holder.fileEncryptedImageView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (browserFile.isFavorite()) {
|
||||
holder.fileFavoriteImageView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
@ -146,7 +152,11 @@ public class BrowserFileItem extends AbstractFlexibleItem<BrowserFileItem.ViewHo
|
||||
holder.selectFileCheckbox.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (((CheckBox) v).isChecked() != isSelected()) {
|
||||
if (!browserFile.isAllowedToReShare()) {
|
||||
((CheckBox) v).setChecked(false);
|
||||
Toast.makeText(context, context.getResources().getString(R.string.nc_file_browser_reshare_forbidden),
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else if (((CheckBox) v).isChecked() != isSelected()) {
|
||||
setSelected(((CheckBox) v).isChecked());
|
||||
selectionInterface.toggleBrowserItemSelection(browserFile.getPath());
|
||||
}
|
||||
|
@ -51,6 +51,8 @@ public class BrowserFile {
|
||||
public boolean hasPreview;
|
||||
public boolean favorite;
|
||||
public boolean encrypted;
|
||||
public String permissions;
|
||||
private boolean isAllowedToReShare = false;
|
||||
|
||||
public static BrowserFile getModelFromResponse(Response response, String remotePath) {
|
||||
BrowserFile browserFile = new BrowserFile();
|
||||
@ -95,6 +97,14 @@ public class BrowserFile {
|
||||
if (property instanceof NCEncrypted) {
|
||||
browserFile.setEncrypted(((NCEncrypted) property).isNcEncrypted());
|
||||
}
|
||||
|
||||
if (property instanceof NCPermission) {
|
||||
browserFile.setPermissions(((NCPermission) property).getNcPermission());
|
||||
}
|
||||
}
|
||||
|
||||
if(browserFile.getPermissions().contains("R")){
|
||||
browserFile.isAllowedToReShare = true;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(browserFile.getMimeType()) && !browserFile.isFile()) {
|
||||
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.components.filebrowser.models.properties;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.nextcloud.talk.components.filebrowser.webdav.DavUtils;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import at.bitfire.dav4android.Property;
|
||||
import at.bitfire.dav4android.PropertyFactory;
|
||||
import at.bitfire.dav4android.XmlUtils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class NCPermission implements Property {
|
||||
public static final Name NAME = new Name(DavUtils.OC_NAMESPACE, DavUtils.EXTENDED_PROPERTY_NAME_PERMISSIONS);
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String ncPermission;
|
||||
|
||||
private NCPermission(String p) {
|
||||
ncPermission = p;
|
||||
}
|
||||
|
||||
public static class Factory implements PropertyFactory {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Property create(@NotNull XmlPullParser xmlPullParser) {
|
||||
try {
|
||||
String text = XmlUtils.INSTANCE.readText(xmlPullParser);
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
return new NCPermission(text);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (XmlPullParserException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return new NCPermission("");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Name getName() {
|
||||
return NAME;
|
||||
}
|
||||
}
|
||||
}
|
@ -68,7 +68,7 @@ public class DavUtils {
|
||||
propSet.add(GetETag.NAME);
|
||||
propSet.add(ResourceType.NAME);
|
||||
|
||||
propSet.add(new Property.Name(OC_NAMESPACE, EXTENDED_PROPERTY_NAME_PERMISSIONS));
|
||||
propSet.add(NCPermission.NAME);
|
||||
propSet.add(OCId.NAME);
|
||||
propSet.add(OCSize.NAME);
|
||||
propSet.add(OCFavorite.NAME);
|
||||
@ -97,6 +97,7 @@ public class DavUtils {
|
||||
reflectionMap.put(NCEncrypted.NAME, new NCEncrypted.Factory());
|
||||
reflectionMap.put(OCFavorite.NAME, new OCFavorite.Factory());
|
||||
reflectionMap.put(OCSize.NAME, new OCSize.Factory());
|
||||
reflectionMap.put(NCPermission.NAME, new NCPermission.Factory());
|
||||
|
||||
factories.set(propertyRegistry, reflectionMap);
|
||||
} catch (NoSuchFieldException e) {
|
||||
|
@ -304,6 +304,7 @@
|
||||
<string name="nc_file_browser_back">Back</string>
|
||||
<string name="nc_file_browser_refresh">Refresh</string>
|
||||
<string name="nc_last_modified">%1$s | Last modified: %2$s</string>
|
||||
<string name="nc_file_browser_reshare_forbidden">You are not allowed to re-share this file</string>
|
||||
|
||||
<!-- Lobby -->
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user