android-library icon indicating copy to clipboard operation
android-library copied to clipboard

Remote Operation to load given user's avatar

Open AndyScherzinger opened this issue 9 years ago • 30 comments

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)

AndyScherzinger avatar Feb 08 '16 15:02 AndyScherzinger

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

AndyScherzinger avatar Feb 08 '16 16:02 AndyScherzinger

@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).

AndyScherzinger avatar Feb 09 '16 08:02 AndyScherzinger

@davivel @masensio @rperezb would this feature be something you would like to be added/contributed to the app/lib?

AndyScherzinger avatar Feb 09 '16 08:02 AndyScherzinger

I will ave a look on thursday afternoon (german timezone)

tobiasKaminsky avatar Feb 09 '16 19:02 tobiasKaminsky

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.

AndyScherzinger avatar Feb 10 '16 19:02 AndyScherzinger

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.

tobiasKaminsky avatar Feb 10 '16 20:02 tobiasKaminsky

@DeepDiver1975 can you give us some more details if and when this would be available on the server side? :)

AndyScherzinger avatar Feb 12 '16 08:02 AndyScherzinger

Why dont you just use an existing OwnCloudClient and executeMethod to get the avatar? The whole thumbnail processing is made that way...

ddijak avatar Feb 12 '16 09:02 ddijak

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 :)

tobiasKaminsky avatar Feb 12 '16 09:02 tobiasKaminsky

@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.

ddijak avatar Feb 12 '16 11:02 ddijak

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 avatar Feb 12 '16 16:02 tobiasKaminsky

@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.

AndyScherzinger avatar Feb 12 '16 17:02 AndyScherzinger

At least it is working with demo.owncloud.com ;) But you are right, let's wait for the final ok from @DeepDiver1975

tobiasKaminsky avatar Feb 13 '16 07:02 tobiasKaminsky

@AndyScherzinger Is there a reason why you put this in library? This could also be a normal function like the thumbnails...

tobiasKaminsky avatar Feb 13 '16 11:02 tobiasKaminsky

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 avatar Feb 13 '16 20:02 przybylski

@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.

tobiasKaminsky avatar Feb 15 '16 08:02 tobiasKaminsky

@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?)

tobiasKaminsky avatar Feb 15 '16 08:02 tobiasKaminsky

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? :)

AndyScherzinger avatar Feb 15 '16 08:02 AndyScherzinger

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?

tobiasKaminsky avatar Feb 15 '16 20:02 tobiasKaminsky

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.

LukasReschke avatar Feb 15 '16 20:02 LukasReschke

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.

AndyScherzinger avatar Feb 16 '16 08:02 AndyScherzinger

@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 avatar Mar 03 '16 21:03 AndyScherzinger

@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 avatar Mar 04 '16 07:03 rperezb

@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 :)

AndyScherzinger avatar Mar 04 '16 09:03 AndyScherzinger

cc'ing @PVince81 so we can get this into 9.1 :)

jancborchardt avatar Mar 08 '16 14:03 jancborchardt

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.

davivel avatar Jul 14 '16 08:07 davivel

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?

daorte avatar Aug 29 '16 12:08 daorte

Well, that's probably a question better suited for owncloud/core#14564. The API is decided in the server side.

davivel avatar Aug 30 '16 07:08 davivel

@davigonz Is this still required? If yes then can I work on this?

shashvat-kedia avatar May 15 '19 12:05 shashvat-kedia

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

davigonz avatar May 16 '19 06:05 davigonz