Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iteration 1 for file detail & new sharing #2533

Merged
merged 27 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
254ac96
WiP for #2485
AndyScherzinger Apr 30, 2018
dd050b0
new lines and license headers
AndyScherzinger Apr 30, 2018
7ff4f4e
add initial loading of (all, not file specific) activities
AndyScherzinger Apr 30, 2018
6013956
organize imports
AndyScherzinger Apr 30, 2018
d1ba80e
cleanup
AndyScherzinger Apr 30, 2018
19edfb1
filter activity by file Id
tobiasKaminsky May 2, 2018
46f226b
move menu to file name, hide tags (to be implemented later)
AndyScherzinger May 3, 2018
ce66e12
simplify menu item filtering code
AndyScherzinger May 4, 2018
e42ff25
move menu filtering to menu filter helper
AndyScherzinger May 4, 2018
6952e64
further optimize menu item filtering code
AndyScherzinger May 4, 2018
af4918d
WiP preview image in toolbar
AndyScherzinger May 4, 2018
ca7e60b
codacy: combined nested if statements
AndyScherzinger May 4, 2018
0a8822a
load resized image in header
tobiasKaminsky May 4, 2018
60a497a
load center cropped preview image, hide type icon
AndyScherzinger May 4, 2018
941f621
implement set available offline via menu
AndyScherzinger May 4, 2018
57e061e
uncomment unused method/calls for use whenever we switch to glide
AndyScherzinger May 4, 2018
adb9ab2
cleanup details fragment, use standard character avatars for sharees …
AndyScherzinger May 4, 2018
5934bbf
also use standard character avatars for sharees instead of grey icons…
AndyScherzinger May 4, 2018
27a2041
codacy cleanup + fixed javaDoc
AndyScherzinger May 4, 2018
c7d8171
fix use of asyncDrawable
AndyScherzinger May 4, 2018
7c21f46
fix empty activities icon
AndyScherzinger May 4, 2018
dc771a8
implemented pull-to-refresh for activities
AndyScherzinger May 4, 2018
70a9c95
add theming/tinting for sharing headers
AndyScherzinger May 4, 2018
e047df0
fix theming/tinting for tab indicator
AndyScherzinger May 4, 2018
1349c26
fix lint issues
AndyScherzinger May 4, 2018
1049a8a
Drone: update Lint results to reflect reduced error/warning count [sk…
May 4, 2018
200e5aa
center tabs
AndyScherzinger May 9, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ dependencies {
// dependencies for app building
implementation 'com.android.support:multidex:1.0.3'
// implementation project('nextcloud-android-library')
genericImplementation "com.github.nextcloud:android-library:${androidLibraryVersion}"
gplayImplementation "com.github.nextcloud:android-library:${androidLibraryVersion}"
versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
genericImplementation "com.github.nextcloud:android-library:filterActivities-SNAPSHOT"
gplayImplementation "com.github.nextcloud:android-library:filterActivities-SNAPSHOT"
versionDevImplementation 'com.github.nextcloud:android-library:filterActivities-SNAPSHOT' // use always latest master
implementation "com.android.support:support-v4:${supportLibraryVersion}"
implementation "com.android.support:design:${supportLibraryVersion}"
implementation 'com.jakewharton:disklrucache:2.0.2'
Expand Down
1 change: 1 addition & 0 deletions drawable_resources/ic_star.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions drawable_resources/ic_star_outline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions drawable_resources/ic_tag.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion scripts/lint/lint-results.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 114 warnings</span>
<span class="mdl-layout-title">Lint Report: 113 warnings</span>
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import com.owncloud.android.lib.resources.status.OwnCloudVersion;
import com.owncloud.android.ui.TextDrawable;
import com.owncloud.android.ui.adapter.DiskLruImageCache;
import com.owncloud.android.ui.fragment.FileFragment;
import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.utils.BitmapUtils;
import com.owncloud.android.utils.ConnectivityUtils;
Expand Down Expand Up @@ -208,17 +209,17 @@ public static Bitmap getBitmapFromDiskCache(String key) {
}

public static class ResizedImageGenerationTask extends AsyncTask<Object, Void, Bitmap> {
private PreviewImageFragment previewImageFragment;
private FileFragment fileFragment;
private FileDataStorageManager storageManager;
private Account account;
private WeakReference<ImageView> imageViewReference;
private OCFile file;


public ResizedImageGenerationTask(PreviewImageFragment previewImageFragment, ImageView imageView,
public ResizedImageGenerationTask(FileFragment fileFragment, ImageView imageView,
FileDataStorageManager storageManager, Account account)
throws IllegalArgumentException {
this.previewImageFragment = previewImageFragment;
this.fileFragment = fileFragment;
imageViewReference = new WeakReference<>(imageView);
this.storageManager = storageManager;
this.account = account;
Expand Down Expand Up @@ -350,9 +351,13 @@ protected void onPostExecute(Bitmap bitmap) {
} else {
new Thread(() -> {
if (ConnectivityUtils.isInternetWalled(MainApp.getAppContext())) {
previewImageFragment.setNoConnectionErrorMessage();
if (fileFragment instanceof PreviewImageFragment) {
((PreviewImageFragment) fileFragment).setNoConnectionErrorMessage();
}
} else {
previewImageFragment.setErrorPreviewMessage();
if (fileFragment instanceof PreviewImageFragment) {
((PreviewImageFragment) fileFragment).setErrorPreviewMessage();
}
}
}).start();

Expand Down
42 changes: 27 additions & 15 deletions src/main/java/com/owncloud/android/files/FileMenuFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,34 +105,46 @@ public void filter(Menu menu, boolean inSingleFileFragment) {

filter(toShow, toHide, inSingleFileFragment);

MenuItem item;
for (int i : toShow) {
item = menu.findItem(i);
if (item != null) {
item.setVisible(true);
item.setEnabled(true);
}
showMenuItem(menu.findItem(i));
}

for (int i : toHide) {
item = menu.findItem(i);
if (item != null) {
item.setVisible(false);
item.setEnabled(false);
}
hideMenuItem(menu.findItem(i));
}
}
}

private void hideAll(Menu menu) {
MenuItem item;
for (int i = 0; i < menu.size(); i++) {
item = menu.getItem(i);
public static void hideAll(Menu menu) {
if (menu != null) {
for (int i = 0; i < menu.size(); i++) {
hideMenuItem(menu.getItem(i));
}
}
}

private static void hideMenuItem(MenuItem item) {
if (item != null) {
item.setVisible(false);
item.setEnabled(false);
}
}

private static void showMenuItem(MenuItem item) {
if (item != null) {
item.setVisible(true);
item.setEnabled(true);
}
}

public static void hideMenuItems(MenuItem... items) {
if (items != null) {
for (MenuItem item : items) {
hideMenuItem(item);
}
}
}

/**
* Performs the real filtering, to be applied in the {@link Menu} by the caller methods.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Nextcloud Android client application
*
* @author Andy Scherzinger
* Copyright (C) 2018 Andy Scherzinger
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or 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 AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.owncloud.android.ui.adapter;

import android.accounts.Account;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.ui.fragment.FileDetailActivitiesFragment;
import com.owncloud.android.ui.fragment.FileDetailSharingFragment;

/**
* File details pager adapter.
*/
public class FileDetailTabAdapter extends FragmentStatePagerAdapter {
private OCFile file;
private Account account;

public FileDetailTabAdapter(FragmentManager fm, OCFile file, Account account) {
super(fm);

this.file = file;
this.account = account;
}

@Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return FileDetailActivitiesFragment.newInstance(file, account);
case 1:
return FileDetailSharingFragment.newInstance(file, account);
default:
return null;
}
}

@Override
public int getCount() {
return 2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -32,7 +33,10 @@
import com.owncloud.android.R;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.ui.TextDrawable;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;

/**
Expand All @@ -43,13 +47,16 @@ public class ShareUserListAdapter extends ArrayAdapter {
private Context mContext;
private ArrayList<OCShare> mShares;
private ShareUserAdapterListener mListener;
private float mAvatarRadiusDimension;

public ShareUserListAdapter(Context context, int resource, ArrayList<OCShare>shares,
ShareUserAdapterListener listener) {
super(context, resource);
mContext= context;
mShares = shares;
mListener = listener;

mAvatarRadiusDimension = context.getResources().getDimension(R.dimen.standard_padding);
}

@Override
Expand All @@ -67,32 +74,46 @@ public long getItemId(int position) {
return 0;
}

@NonNull
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
LayoutInflater inflator = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflator.inflate(R.layout.share_user_item, parent, false);
public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
View view = convertView;
if (view == null) {
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.share_user_item, parent, false);
}

if (mShares != null && mShares.size() > position) {
OCShare share = mShares.get(position);

TextView userName = (TextView) view.findViewById(R.id.userOrGroupName);
ImageView iconView = (ImageView) view.findViewById(R.id.icon);
final ImageView editShareButton = (ImageView) view.findViewById(R.id.editShareButton);
final ImageView unshareButton = (ImageView) view.findViewById(R.id.unshareButton);
TextView userName = view.findViewById(R.id.userOrGroupName);
ImageView icon = view.findViewById(R.id.icon);
final ImageView editShareButton = view.findViewById(R.id.editShareButton);
final ImageView unshareButton = view.findViewById(R.id.unshareButton);

String name = share.getSharedWithDisplayName();
Drawable icon = getContext().getResources().getDrawable(R.drawable.ic_user);
if (share.getShareType() == ShareType.GROUP) {
name = getContext().getString(R.string.share_group_clarification, name);
icon = getContext().getResources().getDrawable(R.drawable.ic_group);
try {
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
icon.setImageResource(R.drawable.ic_group);
}
} else if (share.getShareType() == ShareType.EMAIL) {
name = getContext().getString(R.string.share_email_clarification, name);
icon = getContext().getResources().getDrawable(R.drawable.ic_email);
editShareButton.setVisibility(View.INVISIBLE);
try {
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
icon.setImageResource(R.drawable.ic_email);
}
} else {
try {
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
icon.setImageResource(R.drawable.ic_user);
}
}
userName.setText(name);
iconView.setImageDrawable(icon);

/// bind listener to edit privileges
editShareButton.setOnClickListener(new View.OnClickListener() {
Expand Down
28 changes: 24 additions & 4 deletions src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
import com.owncloud.android.R;
import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;
import com.owncloud.android.ui.TextDrawable;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;

/**
Expand All @@ -42,11 +45,14 @@ public class UserListAdapter extends ArrayAdapter {

private Context mContext;
private ArrayList<OCShare> mShares;
private float mAvatarRadiusDimension;

public UserListAdapter(Context context, int resource, ArrayList<OCShare> shares) {
super(context, resource);
mContext = context;
mShares = shares;

mAvatarRadiusDimension = context.getResources().getDimension(R.dimen.standard_padding);
}

@Override
Expand Down Expand Up @@ -75,15 +81,29 @@ public long getItemId(int position) {
if (mShares != null && mShares.size() > position) {
OCShare share = mShares.get(position);

TextView userName = (TextView) view.findViewById(R.id.userOrGroupName);
ImageView icon = (ImageView) view.findViewById(R.id.userIcon);
TextView userName = view.findViewById(R.id.userOrGroupName);
ImageView icon = view.findViewById(R.id.userIcon);
String name = share.getSharedWithDisplayName();
if (share.getShareType() == ShareType.GROUP) {
name = getContext().getString(R.string.share_group_clarification, name);
icon.setImageResource(R.drawable.ic_group);
try {
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
icon.setImageResource(R.drawable.ic_group);
}
} else if (share.getShareType() == ShareType.EMAIL) {
name = getContext().getString(R.string.share_email_clarification, name);
icon.setImageResource(R.drawable.ic_email);
try {
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
icon.setImageResource(R.drawable.ic_email);
}
} else {
try {
icon.setImageDrawable(TextDrawable.createNamedAvatar(name, mAvatarRadiusDimension));
} catch (UnsupportedEncodingException | NoSuchAlgorithmException e) {
icon.setImageResource(R.drawable.ic_user);
}
}
userName.setText(name);

Expand Down
Loading