mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
commit
9cf0999cbf
18 changed files with 50 additions and 213 deletions
|
@ -121,19 +121,6 @@ public interface UserAccountManager extends CurrentAccountProvider {
|
|||
@NonNull
|
||||
OwnCloudVersion getServerVersion(Account account);
|
||||
|
||||
/**
|
||||
* Check if user's account supports media streaming. This is a property of server where user has his account.
|
||||
*
|
||||
* @deprecated Please use {@link OwnCloudVersion#isMediaStreamingSupported()} directly,
|
||||
* obtainable from {@link User#getServer()} and {@link Server#getVersion()}
|
||||
*
|
||||
* @param account Account used to perform {@link android.accounts.AccountManager} lookup.
|
||||
*
|
||||
* @return true is server supports media streaming, false otherwise
|
||||
*/
|
||||
@Deprecated
|
||||
boolean isMediaStreamingSupported(@Nullable Account account);
|
||||
|
||||
void resetOwnCloudAccount();
|
||||
|
||||
/**
|
||||
|
|
|
@ -327,11 +327,6 @@ public class UserAccountManagerImpl implements UserAccountManager {
|
|||
return serverVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMediaStreamingSupported(Account account) {
|
||||
return account != null && getServerVersion(account).isMediaStreamingSupported();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetOwnCloudAccount() {
|
||||
SharedPreferences.Editor appPrefs = PreferenceManager.getDefaultSharedPreferences(context).edit();
|
||||
|
|
|
@ -26,12 +26,10 @@ import android.net.NetworkInfo;
|
|||
import com.nextcloud.client.account.Server;
|
||||
import com.nextcloud.client.account.UserAccountManager;
|
||||
import com.nextcloud.client.logger.Logger;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -79,35 +77,14 @@ class ConnectivityServiceImpl implements ConnectivityService {
|
|||
if (baseServerAddress.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
String url;
|
||||
if (server.getVersion().compareTo(OwnCloudVersion.nextcloud_13) > 0) {
|
||||
url = baseServerAddress + "/index.php/204";
|
||||
} else {
|
||||
url = baseServerAddress + "/status.php";
|
||||
}
|
||||
|
||||
get = requestBuilder.invoke(url);
|
||||
get = requestBuilder.invoke(baseServerAddress + "/index.php/204");
|
||||
HttpClient client = clientFactory.createPlainClient();
|
||||
|
||||
int status = client.executeMethod(get);
|
||||
|
||||
if (server.getVersion().compareTo(OwnCloudVersion.nextcloud_13) > 0) {
|
||||
return !(status == HttpStatus.SC_NO_CONTENT &&
|
||||
(get.getResponseContentLength() == -1 || get.getResponseContentLength() == 0));
|
||||
} else {
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
try {
|
||||
// try parsing json to verify response
|
||||
// check if json contains maintenance and it should be false
|
||||
String json = get.getResponseBodyAsString();
|
||||
return new JSONObject(json).getBoolean("maintenance");
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return !(status == HttpStatus.SC_NO_CONTENT &&
|
||||
(get.getResponseContentLength() == -1 || get.getResponseContentLength() == 0));
|
||||
} catch (IOException e) {
|
||||
logger.e(TAG, "Error checking internet connection", e);
|
||||
} finally {
|
||||
|
|
|
@ -115,13 +115,13 @@ import static com.owncloud.android.ui.activity.ContactsPreferenceActivity.PREFER
|
|||
|
||||
/**
|
||||
* Main Application of the project
|
||||
*
|
||||
* <p>
|
||||
* Contains methods to build the "static" strings. These strings were before constants in different classes
|
||||
*/
|
||||
public class MainApp extends MultiDexApplication implements HasAndroidInjector {
|
||||
|
||||
public static final OwnCloudVersion OUTDATED_SERVER_VERSION = OwnCloudVersion.nextcloud_16;
|
||||
public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_13;
|
||||
public static final OwnCloudVersion OUTDATED_SERVER_VERSION = OwnCloudVersion.nextcloud_17;
|
||||
public static final OwnCloudVersion MINIMUM_SUPPORTED_SERVER_VERSION = OwnCloudVersion.nextcloud_16;
|
||||
|
||||
private static final String TAG = MainApp.class.getSimpleName();
|
||||
public static final String DOT = ".";
|
||||
|
|
|
@ -116,21 +116,20 @@ public class FileMenuFilter {
|
|||
}
|
||||
|
||||
/**
|
||||
* Filters out the file actions available in the passed {@link Menu} taken into account
|
||||
* the state of the {@link OCFile} held by the filter.
|
||||
* Filters out the file actions available in the passed {@link Menu} taken into account the state of the {@link
|
||||
* OCFile} held by the filter.
|
||||
*
|
||||
* @param menu Options or context menu to filter.
|
||||
* @param inSingleFileFragment True if this is not listing, but single file fragment, like preview or details.
|
||||
* @param isMediaSupported True is media playback is supported for this user
|
||||
* @param menu Options or context menu to filter.
|
||||
* @param inSingleFileFragment True if this is not listing, but single file fragment, like preview or details.
|
||||
*/
|
||||
public void filter(Menu menu, boolean inSingleFileFragment, boolean isMediaSupported) {
|
||||
public void filter(Menu menu, boolean inSingleFileFragment) {
|
||||
if (files == null || files.isEmpty()) {
|
||||
hideAll(menu);
|
||||
} else {
|
||||
List<Integer> toShow = new ArrayList<>();
|
||||
List<Integer> toHide = new ArrayList<>();
|
||||
|
||||
filter(toShow, toHide, inSingleFileFragment, isMediaSupported);
|
||||
filter(toShow, toHide, inSingleFileFragment);
|
||||
|
||||
for (int i : toShow) {
|
||||
showMenuItem(menu.findItem(i));
|
||||
|
@ -179,16 +178,13 @@ public class FileMenuFilter {
|
|||
|
||||
/**
|
||||
* Decides what actions must be shown and hidden implementing the different rule sets.
|
||||
*
|
||||
* @param toShow List to save the options that must be shown in the menu.
|
||||
* @param toShow List to save the options that must be shown in the menu.
|
||||
* @param toHide List to save the options that must be shown in the menu.
|
||||
* @param inSingleFileFragment True if this is not listing, but single file fragment, like preview or details.
|
||||
* @param isMediaSupported True is media playback is supported for this user
|
||||
*/
|
||||
private void filter(List<Integer> toShow,
|
||||
List<Integer> toHide,
|
||||
boolean inSingleFileFragment,
|
||||
boolean isMediaSupported) {
|
||||
boolean inSingleFileFragment) {
|
||||
boolean synchronizing = anyFileSynchronizing();
|
||||
OCCapability capability = componentsGetter.getStorageManager().getCapability(user.getAccountName());
|
||||
boolean endToEndEncryptionEnabled = capability.getEndToEndEncryption().isTrue();
|
||||
|
@ -211,7 +207,7 @@ public class FileMenuFilter {
|
|||
filterEncrypt(toShow, toHide, endToEndEncryptionEnabled);
|
||||
filterUnsetEncrypted(toShow, toHide, endToEndEncryptionEnabled);
|
||||
filterSetPictureAs(toShow, toHide);
|
||||
filterStream(toShow, toHide, isMediaSupported);
|
||||
filterStream(toShow, toHide);
|
||||
}
|
||||
|
||||
private void filterShareFile(List<Integer> toShow, List<Integer> toHide, OCCapability capability) {
|
||||
|
@ -429,8 +425,8 @@ public class FileMenuFilter {
|
|||
}
|
||||
}
|
||||
|
||||
private void filterStream(List<Integer> toShow, List<Integer> toHide, boolean isMediaSupported) {
|
||||
if (files.isEmpty() || !isSingleFile() || !isSingleMedia() || !isMediaSupported) {
|
||||
private void filterStream(List<Integer> toShow, List<Integer> toHide) {
|
||||
if (files.isEmpty() || !isSingleFile() || !isSingleMedia()) {
|
||||
toHide.add(R.id.action_stream_media);
|
||||
} else {
|
||||
toShow.add(R.id.action_stream_media);
|
||||
|
|
|
@ -303,7 +303,7 @@ public abstract class DrawerActivity extends ToolbarActivity
|
|||
OCCapability capability = storageManager.getCapability(user.getAccountName());
|
||||
|
||||
DrawerMenuUtil.filterSearchMenuItems(menu, user, getResources());
|
||||
DrawerMenuUtil.filterTrashbinMenuItem(menu, user, capability);
|
||||
DrawerMenuUtil.filterTrashbinMenuItem(menu, capability);
|
||||
DrawerMenuUtil.filterActivityMenuItem(menu, capability);
|
||||
|
||||
DrawerMenuUtil.setupHomeMenuItem(menu, getResources());
|
||||
|
|
|
@ -689,9 +689,7 @@ public class FileDisplayActivity extends FileActivity
|
|||
mWaitingToPreview = getStorageManager().getFileById(mWaitingToPreview.getFileId());
|
||||
|
||||
if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) {
|
||||
boolean streaming = AccountUtils.getServerVersionForAccount(getAccount(), this)
|
||||
.isMediaStreamingSupported();
|
||||
startMediaPreview(mWaitingToPreview, 0, true, true, streaming);
|
||||
startMediaPreview(mWaitingToPreview, 0, true, true, true);
|
||||
detailsFragmentChanged = true;
|
||||
} else if (MimeTypeUtil.isVCard(mWaitingToPreview.getMimeType())) {
|
||||
startContactListFragment(mWaitingToPreview);
|
||||
|
@ -1876,9 +1874,7 @@ public class FileDisplayActivity extends FileActivity
|
|||
((PreviewMediaFragment) details).updateFile(renamedFile);
|
||||
if (PreviewMediaFragment.canBePreviewed(renamedFile)) {
|
||||
int position = ((PreviewMediaFragment) details).getPosition();
|
||||
boolean streaming = AccountUtils.getServerVersionForAccount(getAccount(), this)
|
||||
.isMediaStreamingSupported();
|
||||
startMediaPreview(renamedFile, position, true, true, streaming);
|
||||
startMediaPreview(renamedFile, position, true, true, true);
|
||||
} else {
|
||||
getFileOperationsHelper().openFile(renamedFile);
|
||||
}
|
||||
|
@ -2342,11 +2338,9 @@ public class FileDisplayActivity extends FileActivity
|
|||
if (event.getIntent().getBooleanExtra(TEXT_PREVIEW, false)) {
|
||||
startTextPreview((OCFile) bundle.get(EXTRA_FILE), true);
|
||||
} else if (bundle.containsKey(PreviewVideoActivity.EXTRA_START_POSITION)) {
|
||||
boolean streaming = AccountUtils.getServerVersionForAccount(getAccount(), this)
|
||||
.isMediaStreamingSupported();
|
||||
startMediaPreview((OCFile)bundle.get(EXTRA_FILE),
|
||||
(int)bundle.get(PreviewVideoActivity.EXTRA_START_POSITION),
|
||||
(boolean) bundle.get(PreviewVideoActivity.EXTRA_AUTOPLAY), true, streaming);
|
||||
startMediaPreview((OCFile) bundle.get(EXTRA_FILE),
|
||||
(int) bundle.get(PreviewVideoActivity.EXTRA_START_POSITION),
|
||||
(boolean) bundle.get(PreviewVideoActivity.EXTRA_AUTOPLAY), true, true);
|
||||
} else if (bundle.containsKey(PreviewImageActivity.EXTRA_VIRTUAL_TYPE)) {
|
||||
startImagePreview((OCFile)bundle.get(EXTRA_FILE),
|
||||
(VirtualFolderType)bundle.get(PreviewImageActivity.EXTRA_VIRTUAL_TYPE),
|
||||
|
|
|
@ -59,15 +59,12 @@ import com.nextcloud.common.NextcloudClient;
|
|||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.FileDataStorageManager;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.lib.resources.activities.model.Activity;
|
||||
import com.owncloud.android.lib.resources.activities.model.RichElement;
|
||||
import com.owncloud.android.lib.resources.activities.model.RichObject;
|
||||
import com.owncloud.android.lib.resources.activities.models.PreviewObject;
|
||||
import com.owncloud.android.lib.resources.files.FileUtils;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.ui.interfaces.ActivityListInterface;
|
||||
import com.owncloud.android.utils.DisplayUtils;
|
||||
import com.owncloud.android.utils.MimeTypeUtil;
|
||||
|
@ -230,23 +227,14 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
}
|
||||
});
|
||||
|
||||
if (capability.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_15)) {
|
||||
for (PreviewObject previewObject : activity.getPreviews()) {
|
||||
if (!isDetailView || MimeTypeUtil.isImageOrVideo(previewObject.getMimeType()) ||
|
||||
MimeTypeUtil.isVideo(previewObject.getMimeType())) {
|
||||
ImageView imageView = createThumbnailNew(previewObject,
|
||||
activity
|
||||
.getRichSubjectElement()
|
||||
.getRichObjectList());
|
||||
activityViewHolder.list.addView(imageView);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (RichObject richObject : activity.getRichSubjectElement().getRichObjectList()) {
|
||||
if (richObject.getPath() != null) {
|
||||
ImageView imageView = createThumbnailOld(richObject, isDetailView);
|
||||
activityViewHolder.list.addView(imageView);
|
||||
}
|
||||
for (PreviewObject previewObject : activity.getPreviews()) {
|
||||
if (!isDetailView || MimeTypeUtil.isImageOrVideo(previewObject.getMimeType()) ||
|
||||
MimeTypeUtil.isVideo(previewObject.getMimeType())) {
|
||||
ImageView imageView = createThumbnailNew(previewObject,
|
||||
activity
|
||||
.getRichSubjectElement()
|
||||
.getRichObjectList());
|
||||
activityViewHolder.list.addView(imageView);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -301,68 +289,6 @@ public class ActivityListAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
|||
return imageView;
|
||||
}
|
||||
|
||||
private ImageView createThumbnailOld(final RichObject richObject, boolean isDetailView) {
|
||||
String path = FileUtils.PATH_SEPARATOR + richObject.getPath();
|
||||
OCFile file = storageManager.getFileByPath(path);
|
||||
|
||||
if (file == null) {
|
||||
file = storageManager.getFileByPath(path + FileUtils.PATH_SEPARATOR);
|
||||
}
|
||||
if (file == null) {
|
||||
file = new OCFile(path);
|
||||
file.setRemoteId(richObject.getId());
|
||||
}
|
||||
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(px, px);
|
||||
params.setMargins(10, 10, 10, 10);
|
||||
ImageView imageView = new ImageView(context);
|
||||
imageView.setLayoutParams(params);
|
||||
imageView.setOnClickListener(v -> activityListInterface.onActivityClicked(richObject));
|
||||
setBitmap(file, imageView, isDetailView);
|
||||
|
||||
return imageView;
|
||||
}
|
||||
|
||||
private void setBitmap(OCFile file, ImageView fileIcon, boolean isDetailView) {
|
||||
// No Folder
|
||||
if (!file.isFolder()) {
|
||||
if (MimeTypeUtil.isImage(file) || MimeTypeUtil.isVideo(file)) {
|
||||
int placeholder;
|
||||
|
||||
if (MimeTypeUtil.isImage(file)) {
|
||||
placeholder = R.drawable.file_image;
|
||||
} else {
|
||||
placeholder = R.drawable.file_movie;
|
||||
}
|
||||
|
||||
String uri = client.getBaseUri() + "/index.php/apps/files/api/v1/thumbnail/" + px + "/" + px +
|
||||
Uri.encode(file.getRemotePath(), "/");
|
||||
|
||||
Glide.with(context).using(new CustomGlideStreamLoader(currentAccountProvider, clientFactory))
|
||||
.load(uri).placeholder(placeholder)
|
||||
.error(placeholder)
|
||||
.into(fileIcon); // using custom fetcher
|
||||
|
||||
} else {
|
||||
if (isDetailView) {
|
||||
fileIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
fileIcon.setImageDrawable(MimeTypeUtil.getFileTypeIcon(file.getMimeType(), file.getFileName(),
|
||||
context));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Folder
|
||||
if (isDetailView) {
|
||||
fileIcon.setVisibility(View.GONE);
|
||||
} else {
|
||||
fileIcon.setImageDrawable(
|
||||
MimeTypeUtil.getFolderTypeIcon(file.isSharedWithMe() || file.isSharedWithSharee(),
|
||||
file.isSharedViaLink(), file.isEncrypted(), file.getMountType(), context));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void downloadIcon(Activity activity, ImageView itemViewType) {
|
||||
GenericRequestBuilder<Uri, InputStream, SVG, Bitmap> requestBuilder = Glide.with(context)
|
||||
.using(Glide.buildStreamModelLoader(Uri.class, context), InputStream.class)
|
||||
|
|
|
@ -55,7 +55,6 @@ import com.owncloud.android.lib.resources.comments.MarkCommentsAsReadRemoteOpera
|
|||
import com.owncloud.android.lib.resources.files.ReadFileVersionsRemoteOperation;
|
||||
import com.owncloud.android.lib.resources.files.model.FileVersion;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
import com.owncloud.android.operations.CommentFileOperation;
|
||||
import com.owncloud.android.ui.activity.ComponentsGetter;
|
||||
import com.owncloud.android.ui.adapter.ActivityAndVersionListAdapter;
|
||||
|
@ -255,9 +254,7 @@ public class FileDetailActivitiesFragment extends Fragment implements
|
|||
operationsHelper = ((ComponentsGetter) requireActivity()).getFileOperationsHelper();
|
||||
|
||||
OCCapability capability = storageManager.getCapability(user.getAccountName());
|
||||
OwnCloudVersion serverVersion = user.getServer().getVersion();
|
||||
restoreFileVersionSupported = capability.getFilesVersioning().isTrue() &&
|
||||
serverVersion.compareTo(OwnCloudVersion.nextcloud_14) >= 0;
|
||||
restoreFileVersionSupported = capability.getFilesVersioning().isTrue();
|
||||
|
||||
emptyContentProgressBar.getIndeterminateDrawable().setColorFilter(ThemeUtils.primaryAccentColor(getContext()),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
|
|
|
@ -412,9 +412,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
|
|||
currentUser
|
||||
);
|
||||
|
||||
mf.filter(menu,
|
||||
true,
|
||||
currentUser.getServer().getVersion().isMediaStreamingSupported());
|
||||
mf.filter(menu, true);
|
||||
}
|
||||
|
||||
if (getFile().isFolder()) {
|
||||
|
|
|
@ -326,7 +326,6 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
MenuItem allowDeletingItem = menu.findItem(R.id.allow_deleting);
|
||||
MenuItem expirationDateItem = menu.findItem(R.id.action_expiration_date);
|
||||
MenuItem reshareItem = menu.findItem(R.id.allow_resharing);
|
||||
MenuItem sendNoteItem = menu.findItem(R.id.action_share_send_note);
|
||||
|
||||
allowEditingItem.setChecked(canEdit(share));
|
||||
|
||||
|
@ -350,8 +349,6 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
SharingMenuHelper.setupExpirationDateMenuItem(menu.findItem(R.id.action_expiration_date),
|
||||
share.getExpirationDate(),
|
||||
getResources());
|
||||
|
||||
sendNoteItem.setVisible(capabilities.getVersion().isNoteOnShareSupported());
|
||||
}
|
||||
|
||||
public void showLinkOverflowMenu(OCShare publicShare, ImageView overflowMenuShareLink) {
|
||||
|
@ -399,8 +396,7 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
Resources res = requireContext().getResources();
|
||||
SharingMenuHelper.setupHideFileDownload(menu.findItem(R.id.action_hide_file_download),
|
||||
publicShare.isHideFileDownload(),
|
||||
isFileDrop(publicShare),
|
||||
capabilities);
|
||||
isFileDrop(publicShare));
|
||||
|
||||
SharingMenuHelper.setupPasswordMenuItem(menu.findItem(R.id.action_password),
|
||||
publicShare.isPasswordProtected());
|
||||
|
@ -408,8 +404,6 @@ public class FileDetailSharingFragment extends Fragment implements ShareeListAda
|
|||
SharingMenuHelper.setupExpirationDateMenuItem(menu.findItem(R.id.action_share_expiration_date),
|
||||
publicShare.getExpirationDate(),
|
||||
res);
|
||||
|
||||
menu.findItem(R.id.action_share_send_note).setVisible(capabilities.getVersion().isNoteOnShareSupported());
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
|
|
@ -522,17 +522,13 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
public void onOverflowIconClicked(OCFile file, View view) {
|
||||
PopupMenu popup = new PopupMenu(getActivity(), view);
|
||||
popup.inflate(R.menu.item_file);
|
||||
User currentUser = ((FileActivity) getActivity()).getUser().orElseThrow(IllegalStateException::new);
|
||||
FileMenuFilter mf = new FileMenuFilter(mAdapter.getFiles().size(),
|
||||
Collections.singleton(file),
|
||||
mContainerActivity, getActivity(),
|
||||
true,
|
||||
deviceInfo,
|
||||
accountManager.getUser());
|
||||
final boolean isMediaStreamingSupported = currentUser.getServer().getVersion().isMediaStreamingSupported();
|
||||
mf.filter(popup.getMenu(),
|
||||
true,
|
||||
isMediaStreamingSupported);
|
||||
mf.filter(popup.getMenu(), true);
|
||||
popup.setOnMenuItemClickListener(item -> {
|
||||
Set<OCFile> checkedFiles = new HashSet<>();
|
||||
checkedFiles.add(file);
|
||||
|
@ -683,7 +679,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
Set<OCFile> checkedFiles = mAdapter.getCheckedItems();
|
||||
String title = getResources().getQuantityString(R.plurals.items_selected_count, checkedCount, checkedCount);
|
||||
mode.setTitle(title);
|
||||
User currentUser = accountManager.getUser();
|
||||
FileMenuFilter mf = new FileMenuFilter(
|
||||
mAdapter.getFiles().size(),
|
||||
checkedFiles,
|
||||
|
@ -694,10 +689,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
accountManager.getUser()
|
||||
);
|
||||
|
||||
final boolean isMediaStreamingSupported = currentUser.getServer().getVersion().isMediaStreamingSupported();
|
||||
mf.filter(menu,
|
||||
false,
|
||||
isMediaStreamingSupported);
|
||||
mf.filter(menu, false);
|
||||
|
||||
// Determine if we need to finish the action mode because there are no items selected
|
||||
if (checkedCount == 0 && !mIsActionModeNew) {
|
||||
|
@ -1021,8 +1013,7 @@ public class OCFileListFragment extends ExtendedListFragment implements
|
|||
OCCapability capability = mContainerActivity.getStorageManager()
|
||||
.getCapability(account.getAccountName());
|
||||
|
||||
if (PreviewMediaFragment.canBePreviewed(file) && account.getServer().getVersion()
|
||||
.isMediaStreamingSupported() && !file.isEncrypted()) {
|
||||
if (PreviewMediaFragment.canBePreviewed(file) && !file.isEncrypted()) {
|
||||
// stream media preview on >= NC14
|
||||
setFabVisible(false);
|
||||
resetHeaderScrollingState();
|
||||
|
|
|
@ -25,7 +25,6 @@ import android.view.MenuItem;
|
|||
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.resources.shares.OCShare;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
@ -66,14 +65,12 @@ public final class SharingMenuHelper {
|
|||
/**
|
||||
* Sets checked/visibility state on the given {@link MenuItem} based on the given criteria.
|
||||
*
|
||||
* @param menuItem the {@link MenuItem} to be setup
|
||||
* @param capabilities Capabilities of server to check if hide download is supported
|
||||
* @param menuItem the {@link MenuItem} to be setup
|
||||
*/
|
||||
public static void setupHideFileDownload(MenuItem menuItem,
|
||||
boolean hideFileDownload,
|
||||
boolean isFileDrop,
|
||||
OCCapability capabilities) {
|
||||
if (!capabilities.getVersion().isHideFileDownloadSupported() || isFileDrop) {
|
||||
boolean isFileDrop) {
|
||||
if (isFileDrop) {
|
||||
menuItem.setVisible(false);
|
||||
} else {
|
||||
menuItem.setVisible(true);
|
||||
|
|
|
@ -383,9 +383,7 @@ public class PreviewImageFragment extends FileFragment implements Injectable {
|
|||
currentUser
|
||||
);
|
||||
|
||||
mf.filter(menu,
|
||||
true,
|
||||
currentUser.getServer().getVersion().isMediaStreamingSupported());
|
||||
mf.filter(menu, true);
|
||||
}
|
||||
|
||||
// additional restriction for this fragment
|
||||
|
|
|
@ -356,9 +356,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|||
currentUser
|
||||
);
|
||||
|
||||
mf.filter(menu,
|
||||
true,
|
||||
currentUser.getServer().getVersion().isMediaStreamingSupported());
|
||||
mf.filter(menu, true);
|
||||
}
|
||||
|
||||
// additional restriction for this fragment
|
||||
|
|
|
@ -270,9 +270,7 @@ public class PreviewTextFileFragment extends PreviewTextFragment {
|
|||
deviceInfo,
|
||||
user
|
||||
);
|
||||
mf.filter(menu,
|
||||
true,
|
||||
user.getServer().getVersion().isMediaStreamingSupported());
|
||||
mf.filter(menu, true);
|
||||
}
|
||||
|
||||
// additional restriction for this fragment
|
||||
|
|
|
@ -29,9 +29,7 @@ import android.view.Menu;
|
|||
import com.nextcloud.client.account.User;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.lib.resources.status.OCCapability;
|
||||
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -61,9 +59,8 @@ public final class DrawerMenuUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static void filterTrashbinMenuItem(Menu menu, @NonNull User user, @Nullable OCCapability capability) {
|
||||
if (user.getServer().getVersion().compareTo(OwnCloudVersion.nextcloud_14) < 0 ||
|
||||
capability != null && capability.getFilesUndelete().isFalse() ||
|
||||
public static void filterTrashbinMenuItem(Menu menu, @Nullable OCCapability capability) {
|
||||
if (capability != null && capability.getFilesUndelete().isFalse() ||
|
||||
capability != null && capability.getFilesUndelete().isUnknown()) {
|
||||
filterMenuItems(menu, R.id.nav_trashbin);
|
||||
}
|
||||
|
|
|
@ -93,8 +93,8 @@ class ConnectivityServiceTest {
|
|||
lateinit var logger: Logger
|
||||
|
||||
val baseServerUri = URI.create(SERVER_BASE_URL)
|
||||
val newServer = Server(baseServerUri, OwnCloudVersion.nextcloud_14)
|
||||
val legacyServer = Server(baseServerUri, OwnCloudVersion.nextcloud_13)
|
||||
val newServer = Server(baseServerUri, OwnCloudVersion.nextcloud_20)
|
||||
val legacyServer = Server(baseServerUri, OwnCloudVersion.nextcloud_16)
|
||||
|
||||
@Mock
|
||||
lateinit var user: User
|
||||
|
@ -207,12 +207,6 @@ class ConnectivityServiceTest {
|
|||
whenever(getRequest.responseBodyAsString).thenReturn(body)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `false maintenance status flag is used`() {
|
||||
mockResponse(maintenance = false, httpStatus = HttpStatus.SC_OK)
|
||||
assertFalse(connectivityService.isInternetWalled)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `true maintenance status flag is used`() {
|
||||
mockResponse(maintenance = true, httpStatus = HttpStatus.SC_OK)
|
||||
|
@ -231,7 +225,7 @@ class ConnectivityServiceTest {
|
|||
connectivityService.isInternetWalled
|
||||
val urlCaptor = ArgumentCaptor.forClass(String::class.java)
|
||||
verify(requestBuilder).invoke(urlCaptor.capture())
|
||||
assertTrue("Invalid URL used to check status", urlCaptor.value.endsWith("/status.php"))
|
||||
assertTrue("Invalid URL used to check status", urlCaptor.value.endsWith("/204"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,7 +235,7 @@ class ConnectivityServiceTest {
|
|||
fun setUp() {
|
||||
whenever(networkInfo.isConnectedOrConnecting).thenReturn(true)
|
||||
whenever(networkInfo.type).thenReturn(ConnectivityManager.TYPE_WIFI)
|
||||
whenever(accountManager.getServerVersion(any())).thenReturn(OwnCloudVersion.nextcloud_14)
|
||||
whenever(accountManager.getServerVersion(any())).thenReturn(OwnCloudVersion.nextcloud_20)
|
||||
assertTrue(
|
||||
"Precondition failed",
|
||||
connectivityService.connectivity.let {
|
||||
|
@ -255,7 +249,7 @@ class ConnectivityServiceTest {
|
|||
// GIVEN
|
||||
// network connectivity is present
|
||||
// user has no server URI (empty)
|
||||
val serverWithoutUri = Server(URI(""), OwnCloudVersion.nextcloud_14)
|
||||
val serverWithoutUri = Server(URI(""), OwnCloudVersion.nextcloud_20)
|
||||
whenever(user.server).thenReturn(serverWithoutUri)
|
||||
|
||||
// WHEN
|
||||
|
|
Loading…
Reference in a new issue