android-library
android-library copied to clipboard
Remote Operation to load given user's avatar
Like the title says it would be nice to have an Operation to load a user's avatar.
This can imho be supported for oC v8.2 while being logged in requesting the image via
<ocBaseURI>/index.php/avatar/
The Android client issue for this is: https://github.com/owncloud/android/issues/778 The server issue is: https://github.com/owncloud/core/pull/14856 (already merged/released)
I started (trying) to implement this on the following branch https://github.com/owncloud/android-library/tree/avatar (dry coding atm).
https://github.com/owncloud/android-library/blob/avatar/src/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java
@tobiasKaminsky @przybylski fancy some collaboration? :smiley: I started working on this but hit a roadblock when trying to make use of the (untested) implementation since the AccountManager gets involved and would need to put the loading of the avatars into some asynchronous processing.
@DeepDiver1975 can the avatar be loaded via the url? --> /index.php/avatar/username/pixelsize or is this kind of a hack since the changes made in https://github.com/owncloud/core/pull/14856 have been reverted but I think it would be a nice feature to have the avatars in the mobile app(s).
@davivel @masensio @rperezb would this feature be something you would like to be added/contributed to the app/lib?
I will ave a look on thursday afternoon (german timezone)
Awesome! I would really like to add this feature to the app and can take care of embedding it in the UI with circle shape and stuff like that.
I read the /core issue you have mentioned. As far as I can see the PR has been reverted. So, I can add this to my local cloud for testing, but we will have to wait for official integration. (And hope that it will be implemented the same way) So I am not sure if we should do it now.
@DeepDiver1975 can you give us some more details if and when this would be available on the server side? :)
Why dont you just use an existing OwnCloudClient and executeMethod to get the avatar? The whole thumbnail processing is made that way...
There is as far as I know currently no implementation to get the avatar on server side. If so, please post an example url and we can use it right away :)
@AndyScherzinger had a right idea.
private String getAvatarURL(OwnCloudAccount oca) { int lastAtPos = oca.getName().lastIndexOf("@"); String username = oca.getName().substring(0, lastAtPos); return String.valueOf(oca.getBaseUri() + "/index.php/avatar/" + username + "/128"); }
That 128 is a size of the returned avatar, it can be adjusted accordingly.
Then you just executeMethod on that URL on already implemeted OwnCloudClient (so you don't need to implement your own authentication and its already handled for you) in the android application.
If no image is returned, meaning no avatar has been set for the user, you can just show the default person icon (the one that is currently used in the app).
Thats how I implemented avatars.
Great, this is working. But I thought this could not work as the PR in /core was reverted. Strange...
@AndyScherzinger I will have a look soon.
@tobiasKaminsky Thanks! I still wou,d like to get some comment from @DeepDiver1975 since I don't now if the URL pattern I mentioned (and also @skymania) is actually an official API and working on purpose.
At least it is working with demo.owncloud.com ;) But you are right, let's wait for the final ok from @DeepDiver1975
@AndyScherzinger Is there a reason why you put this in library? This could also be a normal function like the thumbnails...
Isn't /index.php/avatar/$username$/$size$ url only for internal use? I tried that and it said that session is invalid, it works on demo.owncloud.org because this instance is altered to always authenticate as test user
@przybylski This seems to work for me with OC 8.2. @AndyScherzinger I have moved the avatar loading from lib to normal app to use the thumbnail cache system. I will provide it in the next few days.
@AndyScherzinger Maybe you can change the rectangular avatar to round like in the web? (And also add them to the account list in the settings screen?)
Yes! That is what I had in mind, even though with the api in place I would rather like to start implementing the account switch in the drawer which you already did in the past.
As for the reason why I would like to have the avatar loading in the library instead of in the app is simply to offer this to third party apps so they can also show avatars helping consistency throughout apps. While the image handling making them rectangular would be part of the application since it has nothing to do with the server's API :) - In case this isn't an official API (yet) then of course we should not put it here but I would like to see this API being supported by the backend. Still no answer from @DeepDiver1975 - any comment? :)
For the thumbnail generation it is easy to determine if the thumbnail needs to be updated as the fileID changes. But for the avatar there is not such an id. So how can we figure out if the avatar was updated and refresh the internal cache?
In case this isn't an official API (yet) then of course we should not put it here but I would like to see this API being supported by the backend.
Not an official public API from what I can tell. I'd rather not rely on it at the moment.
I agree with @LukasReschke - we shouldn't use an unofficial API. Is anyone able to contact @DeepDiver1975 about the server side issue? In my opinion it would be nice to have this for consistency and I also think it adds to the user experience.
@jancborchardt any chance to get this with oC9 ? Would be nice to have this via a public API :tada:
EDIT: it has been postponed to 9.1 --> https://github.com/owncloud/core/issues/14564
@AndyScherzinger i'm afraid that the development for oc9 is locked down; just sev1 and sev2 bug fixed. The release is around the corner, Tuesday 8 The issue that you are pointing out is labeled for oc9.1 so next version
@rperezb thanks for the update, yeah I realized that, so I asked if it can be committed for 9.1 knowing it is sheduled but probably not a priority which is fine with me, but I am more a guy who is motivated to work on UI rather then functional features, so I try to push stuff forward that adds value to the user interface :)
cc'ing @PVince81 so we can get this into 9.1 :)
As for the reason why I would like to have the avatar loading in the library instead of in the app is simply to offer this to third party apps so they can also show avatars helping consistency throughout apps.
I totally support that view. Joining in :)
Server part is now scheduled for 9.2. Will have to wait a little bit more.
Hi,
In #132 i suggest to unify the OCS controllers in one place, just like ocs/v1.php/cloud/capabilities, ocs/v1.php/apps/files_sharing and ocs/v1.php/cloud/user
This request to retrieve the user's avatar could be part of the User Provisioning API? because with version 2.1.0 there is a new call pointing to cloud/index.php/ocs/cloud/user?format=json to get the user's display name, and now there is a new call to index.php/avatar to process an OCS request.
If both requests are for user's information, should not be both calls in the same place? ocs/v1.php/cloud/user maybe?
Well, that's probably a question better suited for owncloud/core#14564. The API is decided in the server side.
@davigonz Is this still required? If yes then can I work on this?
Is this still required? If yes then can I work on this?
It seems this needs https://github.com/owncloud/core/issues/14564 before, so let's wait a bit