-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
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 23fb0ef
lambda: use method reference
AndyScherzinger 6831678
butterknife for the sharing tabs of file details
AndyScherzinger c9328dc
add new lines
AndyScherzinger cd200b2
empty menu implementation per sharee
AndyScherzinger c86f007
add listener interface + organized imports
AndyScherzinger 5200dd0
WiP permission handling (Don't use for productive shares yet!)
AndyScherzinger 5054df0
updating of permissions for file/folder (folder not reachable yet)
AndyScherzinger 72681e9
add proper permission editing for folders
AndyScherzinger 2c30e38
Wip user/group search (not fully working yet)
AndyScherzinger 27d04c8
organize imports
AndyScherzinger a2c0b18
lint: Inefficient layout weight
AndyScherzinger a29d731
fix theming issue
AndyScherzinger 5589b8c
add avatar icons on sharee list
tobiasKaminsky 90529c5
fix not needed try/catch blocks
tobiasKaminsky 11edb45
use own, distinct menu definition, fix strings, use relative date
AndyScherzinger 4a22b93
fix send menu action + send/share dialog extension
AndyScherzinger a0b7406
replace anonymous classes with lambdas
AndyScherzinger 1a99f65
add content description to preview image
AndyScherzinger d7e8f61
WiP share link functionality
AndyScherzinger 362061b
fixed 2 NPEs
AndyScherzinger 3913689
add sharee works
tobiasKaminsky 607bc12
add unset of password for share link
AndyScherzinger 072e646
reformatted code for line length 120
AndyScherzinger f5d9af7
WiP expiration Date, permission text calculation
AndyScherzinger 236924c
add hide file listing
AndyScherzinger b7b7237
fix flag detection
AndyScherzinger 8397a48
hide file listing option if share is not editable
AndyScherzinger 7800d33
move stuff to helper class
AndyScherzinger 1a32758
implement changes sharing data / fixed unsetting of exp. date
AndyScherzinger 7f85bff
fix codacy + revert to handling name-to-color exceptions
AndyScherzinger 5f64479
add the ability to set expiration date on shares not just links
AndyScherzinger 5ea0528
cleanup + fix lint issues
AndyScherzinger fe234cd
open file details with sharing tab active for folders
AndyScherzinger 431549e
slice filter menu method
AndyScherzinger de51ba1
remove legacy code after refactoring to a helper class
AndyScherzinger 0a545dd
fix NPEs in calling UI thread and within UI threads
AndyScherzinger d0dbc9e
remove unused import
AndyScherzinger b3f980c
show proper error view if activities failed to load
AndyScherzinger dba1042
remove unused string
AndyScherzinger cc8914e
type, code formatting
tobiasKaminsky 0e41ed7
Use AppCompat checkbox
AndyScherzinger 1709348
sort menu items according to webUI
AndyScherzinger d0b9d58
account switch on drawer without "singleTop" works again
tobiasKaminsky cab6555
app restarts now after account switching
tobiasKaminsky f2dd5ea
proper error snackbars for sharing errors, move feed back results to …
AndyScherzinger d08a944
hide sync for folders
AndyScherzinger bb7c090
remove unused legacy method
AndyScherzinger 2d55824
fix name and javaDoc of updateMethod
AndyScherzinger 42a0e28
add ability to set expiration date for user shares
AndyScherzinger a00b89f
add javaDoc comment
AndyScherzinger 9e0e838
update license headers
AndyScherzinger 20d0307
use general fallback theming for popup menu (checkable menu items)
AndyScherzinger ab97357
remove method call of formerly dropped method
AndyScherzinger cb6c56e
save accent color
AndyScherzinger 4899226
minor size optimizations
AndyScherzinger c738d9e
optimize layout/design
AndyScherzinger e7a0f49
rewrite sharee list to recycler view, show can edit in list items
AndyScherzinger 90a129d
use nicer UI element names
AndyScherzinger f2edf5a
shorten edit label
AndyScherzinger abc2be7
further shortened the label
AndyScherzinger 5c4a450
use file details sharing tab for files also via the share bottom shee…
AndyScherzinger 5154280
fix refreshing OC file list after sharing info changes
AndyScherzinger 952db5a
added javaDoc for public methods
AndyScherzinger d8c4be0
fix lint for item divider, plus code formatting
AndyScherzinger f201a2d
first changes due to designers review
AndyScherzinger 1f58926
Drone: update Lint results to reflect reduced error/warning count [sk…
a3daf06
fix lint again
AndyScherzinger d72eb2a
fix codacy
AndyScherzinger 892db9f
raise font size on file name
AndyScherzinger cf1b8f8
Fix theming issue with date picker dialog
AndyScherzinger f731e4d
java imports, unused java been removed...
AndyScherzinger 84401e7
fix menu filter
AndyScherzinger c3209d8
fix further review comments
AndyScherzinger ba0aff4
Fix comment again
AndyScherzinger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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; | ||
|
@@ -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) { | ||
|
@@ -787,6 +788,9 @@ public AvatarGenerationTask(AvatarGenerationListener avatarGenerationListener, O | |
mAccount = account; | ||
mResources = resources; | ||
mAvatarRadius = avatarRadius; | ||
mUserId = userId; | ||
mServerName = serverName; | ||
mContext = context; | ||
} | ||
|
||
@SuppressFBWarnings("Dm") | ||
|
@@ -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; | ||
|
@@ -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); | ||
} | ||
} | ||
|
@@ -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)); | ||
|
@@ -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; | ||
|
||
String eTag = arbitraryDataProvider.getValue(mAccount, AVATAR); | ||
final String imageKey = "a_" + username + "_" + eTag; | ||
int px = getAvatarDimension(); | ||
|
||
// Download avatar from server | ||
|
@@ -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); | ||
} | ||
|
||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
@@ -897,7 +895,7 @@ Drawable doAvatarInBackground() { | |
|
||
case HttpStatus.SC_NOT_MODIFIED: | ||
// old avatar | ||
avatar = getBitmapFromDiskCache(imageKey); | ||
avatar = getBitmapFromDiskCache(avatarKey); | ||
mClient.exhaustResponse(get.getResponseBodyAsStream()); | ||
break; | ||
|
||
|
@@ -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 | ||
|
@@ -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 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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…
There was a problem hiding this comment.
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?