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 2 for file detail & new sharing #2573

Merged
merged 75 commits into from
May 29, 2018
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
6bb7dc8
butterknife for details fragment + proper empty content handling
AndyScherzinger May 11, 2018
23fb0ef
lambda: use method reference
AndyScherzinger May 11, 2018
6831678
butterknife for the sharing tabs of file details
AndyScherzinger May 11, 2018
c9328dc
add new lines
AndyScherzinger May 11, 2018
cd200b2
empty menu implementation per sharee
AndyScherzinger May 11, 2018
c86f007
add listener interface + organized imports
AndyScherzinger May 13, 2018
5200dd0
WiP permission handling (Don't use for productive shares yet!)
AndyScherzinger May 13, 2018
5054df0
updating of permissions for file/folder (folder not reachable yet)
AndyScherzinger May 13, 2018
72681e9
add proper permission editing for folders
AndyScherzinger May 13, 2018
2c30e38
Wip user/group search (not fully working yet)
AndyScherzinger May 13, 2018
27d04c8
organize imports
AndyScherzinger May 13, 2018
a2c0b18
lint: Inefficient layout weight
AndyScherzinger May 14, 2018
a29d731
fix theming issue
AndyScherzinger May 14, 2018
5589b8c
add avatar icons on sharee list
tobiasKaminsky May 14, 2018
90529c5
fix not needed try/catch blocks
tobiasKaminsky May 15, 2018
11edb45
use own, distinct menu definition, fix strings, use relative date
AndyScherzinger May 15, 2018
4a22b93
fix send menu action + send/share dialog extension
AndyScherzinger May 15, 2018
a0b7406
replace anonymous classes with lambdas
AndyScherzinger May 15, 2018
1a99f65
add content description to preview image
AndyScherzinger May 15, 2018
d7e8f61
WiP share link functionality
AndyScherzinger May 16, 2018
362061b
fixed 2 NPEs
AndyScherzinger May 16, 2018
3913689
add sharee works
tobiasKaminsky May 17, 2018
607bc12
add unset of password for share link
AndyScherzinger May 18, 2018
072e646
reformatted code for line length 120
AndyScherzinger May 18, 2018
f5d9af7
WiP expiration Date, permission text calculation
AndyScherzinger May 18, 2018
236924c
add hide file listing
AndyScherzinger May 20, 2018
b7b7237
fix flag detection
AndyScherzinger May 20, 2018
8397a48
hide file listing option if share is not editable
AndyScherzinger May 20, 2018
7800d33
move stuff to helper class
AndyScherzinger May 20, 2018
1a32758
implement changes sharing data / fixed unsetting of exp. date
AndyScherzinger May 20, 2018
7f85bff
fix codacy + revert to handling name-to-color exceptions
AndyScherzinger May 20, 2018
5f64479
add the ability to set expiration date on shares not just links
AndyScherzinger May 20, 2018
5ea0528
cleanup + fix lint issues
AndyScherzinger May 20, 2018
fe234cd
open file details with sharing tab active for folders
AndyScherzinger May 20, 2018
431549e
slice filter menu method
AndyScherzinger May 21, 2018
de51ba1
remove legacy code after refactoring to a helper class
AndyScherzinger May 21, 2018
0a545dd
fix NPEs in calling UI thread and within UI threads
AndyScherzinger May 22, 2018
d0dbc9e
remove unused import
AndyScherzinger May 22, 2018
b3f980c
show proper error view if activities failed to load
AndyScherzinger May 22, 2018
dba1042
remove unused string
AndyScherzinger May 22, 2018
cc8914e
type, code formatting
tobiasKaminsky May 23, 2018
0e41ed7
Use AppCompat checkbox
AndyScherzinger May 23, 2018
1709348
sort menu items according to webUI
AndyScherzinger May 24, 2018
d0b9d58
account switch on drawer without "singleTop" works again
tobiasKaminsky May 24, 2018
cab6555
app restarts now after account switching
tobiasKaminsky May 24, 2018
f2dd5ea
proper error snackbars for sharing errors, move feed back results to …
AndyScherzinger May 25, 2018
d08a944
hide sync for folders
AndyScherzinger May 25, 2018
bb7c090
remove unused legacy method
AndyScherzinger May 25, 2018
2d55824
fix name and javaDoc of updateMethod
AndyScherzinger May 25, 2018
42a0e28
add ability to set expiration date for user shares
AndyScherzinger May 25, 2018
a00b89f
add javaDoc comment
AndyScherzinger May 25, 2018
9e0e838
update license headers
AndyScherzinger May 25, 2018
20d0307
use general fallback theming for popup menu (checkable menu items)
AndyScherzinger May 25, 2018
ab97357
remove method call of formerly dropped method
AndyScherzinger May 25, 2018
cb6c56e
save accent color
AndyScherzinger May 25, 2018
4899226
minor size optimizations
AndyScherzinger May 25, 2018
c738d9e
optimize layout/design
AndyScherzinger May 25, 2018
e7a0f49
rewrite sharee list to recycler view, show can edit in list items
AndyScherzinger May 27, 2018
90a129d
use nicer UI element names
AndyScherzinger May 27, 2018
f2edf5a
shorten edit label
AndyScherzinger May 27, 2018
abc2be7
further shortened the label
AndyScherzinger May 27, 2018
5c4a450
use file details sharing tab for files also via the share bottom shee…
AndyScherzinger May 28, 2018
5154280
fix refreshing OC file list after sharing info changes
AndyScherzinger May 28, 2018
952db5a
added javaDoc for public methods
AndyScherzinger May 28, 2018
d8c4be0
fix lint for item divider, plus code formatting
AndyScherzinger May 28, 2018
f201a2d
first changes due to designers review
AndyScherzinger May 28, 2018
1f58926
Drone: update Lint results to reflect reduced error/warning count [sk…
May 28, 2018
a3daf06
fix lint again
AndyScherzinger May 28, 2018
d72eb2a
fix codacy
AndyScherzinger May 28, 2018
892db9f
raise font size on file name
AndyScherzinger May 29, 2018
cf1b8f8
Fix theming issue with date picker dialog
AndyScherzinger May 29, 2018
f731e4d
java imports, unused java been removed...
AndyScherzinger May 29, 2018
84401e7
fix menu filter
AndyScherzinger May 29, 2018
c3209d8
fix further review comments
AndyScherzinger May 29, 2018
ba0aff4
Fix comment again
AndyScherzinger May 29, 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
1 change: 1 addition & 0 deletions drawable_resources/alert-octagon.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: 104 warnings</span>
<span class="mdl-layout-title">Lint Report: 103 warnings</span>
6 changes: 6 additions & 0 deletions src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
tools:ignore="UnusedAttribute">
<activity
android:name=".ui.activity.FileDisplayActivity"
android:launchMode="singleTop"
android:label="@string/app_name"
android:configChanges="orientation|screenSize"
android:theme="@style/Theme.ownCloud.Launcher">
Expand All @@ -88,6 +89,11 @@

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/users_and_groups_searchable"/>
</activity>
<activity android:name=".ui.activity.ManageAccountsActivity" />
<activity android:name=".ui.activity.UserInfoActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
package com.owncloud.android.datamodel;

import android.accounts.Account;
import android.accounts.AccountManager;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
Expand Down Expand Up @@ -773,12 +772,14 @@ public static class AvatarGenerationTask extends AsyncTask<String, Void, Drawabl
private final Resources mResources;
private final float mAvatarRadius;
private Account mAccount;
private String mUsername;
private String mUserId;
private String mServerName;
private Context mContext;


public AvatarGenerationTask(AvatarGenerationListener avatarGenerationListener, Object callContext,
FileDataStorageManager storageManager, Account account, Resources resources,
float avatarRadius) {
float avatarRadius, String userId, String serverName, Context context) {
mAvatarGenerationListener = new WeakReference<>(avatarGenerationListener);
mCallContext = callContext;
if (storageManager == null) {
Expand All @@ -787,6 +788,9 @@ public AvatarGenerationTask(AvatarGenerationListener avatarGenerationListener, O
mAccount = account;
mResources = resources;
mAvatarRadius = avatarRadius;
mUserId = userId;
mServerName = serverName;
mContext = context;
}

@SuppressFBWarnings("Dm")
Expand All @@ -796,20 +800,17 @@ protected Drawable doInBackground(String... params) {

try {
if (mAccount != null) {
OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount,
MainApp.getAppContext());
mClient = OwnCloudClientManagerFactory.getDefaultSingleton().
getClientFor(ocAccount, MainApp.getAppContext());
OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, mContext);
mClient = OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, mContext);
}

mUsername = params[0];
thumbnail = doAvatarInBackground();

} catch(OutOfMemoryError oome) {
Log_OC.e(TAG, "Out of memory");
} catch(Throwable t){
// the app should never break due to a problem with avatars
Log_OC.e(TAG, "Generation of avatar for " + mUsername + " failed", t);
Log_OC.e(TAG, "Generation of avatar for " + mUserId + " failed", t);
}

return thumbnail;
Expand All @@ -820,7 +821,7 @@ protected void onPostExecute(Drawable drawable) {
AvatarGenerationListener listener = mAvatarGenerationListener.get();
AvatarGenerationTask avatarWorkerTask = getAvatarWorkerTask(mCallContext);

if (this == avatarWorkerTask && listener.shouldCallGeneratedCallback(mUsername, mCallContext)) {
if (this == avatarWorkerTask && listener.shouldCallGeneratedCallback(mUserId, mCallContext)) {
listener.avatarGenerated(drawable, mCallContext);
}
}
Expand All @@ -830,7 +831,7 @@ protected void onPostExecute(Drawable drawable) {
* Converts size of file icon from dp to pixel
* @return int
*/
private int getAvatarDimension(){
private int getAvatarDimension() {
// Converts dp to pixel
Resources r = MainApp.getAppContext().getResources();
return Math.round(r.getDimension(R.dimen.file_avatar_size));
Expand All @@ -839,13 +840,14 @@ private int getAvatarDimension(){
private @Nullable
Drawable doAvatarInBackground() {
Bitmap avatar = null;
String username = mUsername;

ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(
MainApp.getAppContext().getContentResolver());
String accountName = mUserId + "@" + mServerName;

ArbitraryDataProvider arbitraryDataProvider = new ArbitraryDataProvider(mContext.getContentResolver());

String eTag = arbitraryDataProvider.getValue(accountName, ThumbnailsCacheManager.AVATAR);
String avatarKey = "a_" + mUserId + "_" + mServerName + "_" + eTag;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I don't and don't wanna know what "a" is, please change to "avatar".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the key for our cache:
a_: avatar
t_: thumbnail
r_: resizedImage

As the key is changing for avatar, we can rename it, but then it is not consistent to the other.
Hopefully we/I find the time to change to glide, then this all will change again…

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so leave it as-is then for now?


String eTag = arbitraryDataProvider.getValue(mAccount, AVATAR);
final String imageKey = "a_" + username + "_" + eTag;
int px = getAvatarDimension();

// Download avatar from server
Expand All @@ -854,18 +856,13 @@ Drawable doAvatarInBackground() {
if (serverOCVersion.supportsRemoteThumbnails()) {
GetMethod get = null;
try {
String userId = AccountManager.get(MainApp.getAppContext()).getUserData(mAccount,
com.owncloud.android.lib.common.accounts.AccountUtils.Constants.KEY_USER_ID);

if (TextUtils.isEmpty(userId)) {
userId = AccountUtils.getAccountUsername(username);
}

String uri = mClient.getBaseUri() + "/index.php/avatar/" + Uri.encode(userId) + "/" + px;
String uri = mClient.getBaseUri() + "/index.php/avatar/" + Uri.encode(mUserId) + "/" + px;
Log_OC.d("Avatar", "URI: " + uri);
get = new GetMethod(uri);

if (!eTag.isEmpty()) {
// only use eTag if available and corresponding avatar is still there
// (might be deleted from cache)
if (!eTag.isEmpty() && getBitmapFromDiskCache(avatarKey) != null) {
get.setRequestHeader("If-None-Match", eTag);
}

Expand All @@ -877,18 +874,19 @@ Drawable doAvatarInBackground() {
// new avatar
InputStream inputStream = get.getResponseBodyAsStream();

String newETag = null;
if (get.getResponseHeader(ETAG) != null) {
eTag = get.getResponseHeader(ETAG).getValue().replace("\"", "");
arbitraryDataProvider.storeOrUpdateKeyValue(mAccount.name, AVATAR, eTag);
newETag = get.getResponseHeader(ETAG).getValue().replace("\"", "");
arbitraryDataProvider.storeOrUpdateKeyValue(accountName, AVATAR, newETag);
}

Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
avatar = ThumbnailUtils.extractThumbnail(bitmap, px, px);

// Add avatar to cache
if (avatar != null) {
if (avatar != null && !TextUtils.isEmpty(newETag)) {
avatar = handlePNG(avatar, px, px);
String newImageKey = "a_" + username + "_" + eTag;
String newImageKey = "a_" + mUserId + "_" + mServerName + "_" + newETag;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avatar_ instead of a_.

addBitmapToCache(newImageKey, avatar);
} else {
return TextDrawable.createAvatar(mAccount.name, mAvatarRadius);
Expand All @@ -897,7 +895,7 @@ Drawable doAvatarInBackground() {

case HttpStatus.SC_NOT_MODIFIED:
// old avatar
avatar = getBitmapFromDiskCache(imageKey);
avatar = getBitmapFromDiskCache(avatarKey);
mClient.exhaustResponse(get.getResponseBodyAsStream());
break;

Expand Down Expand Up @@ -965,7 +963,7 @@ public static boolean cancelPotentialAvatarWork(Object file, ImageView imageView
final AvatarGenerationTask avatarWorkerTask = getAvatarWorkerTask(imageView);

if (avatarWorkerTask != null) {
final Object usernameData = avatarWorkerTask.mUsername;
final Object usernameData = avatarWorkerTask.mUserId;
// If usernameData is not yet set or it differs from the new data
if (usernameData == null || !usernameData.equals(file)) {
// Cancel previous task
Expand All @@ -984,7 +982,7 @@ public static boolean cancelPotentialAvatarWork(Object file, MenuItem menuItem)
final AvatarGenerationTask avatarWorkerTask = getAvatarWorkerTask(menuItem);

if (avatarWorkerTask != null) {
final Object usernameData = avatarWorkerTask.mUsername;
final Object usernameData = avatarWorkerTask.mUserId;
// If usernameData is not yet set or it differs from the new data
if (usernameData == null || !usernameData.equals(file)) {
// Cancel previous task
Expand Down
Loading