diff --git a/app/build.gradle b/app/build.gradle index e4b884d734a4d603f3e3a0840c1026b0a2a38260..0affabc4d2e013ebe2a1a21ad28cfd3c1c9f83eb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -67,10 +67,13 @@ dependencies { exclude group: 'org.jetbrains', module: 'annotations-java5' exclude group: 'com.github.nextcloud', module: 'Android-SingleSignOn' } + implementation ('com.github.stefan-niedermann.nextcloud-commons:sso-glide:2.1.0') { + exclude group: 'com.github.nextcloud', module: 'Android-SingleSignOn' + } // Glide - implementation 'com.github.bumptech.glide:glide:4.14.2' - annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2' + implementation 'com.github.bumptech.glide:glide:4.16.0' + annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0' // Android X implementation 'androidx.appcompat:appcompat:1.5.1' diff --git a/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java index 6f7e7c392e9704a6d66a8541db227af739fc1e41..36b377152bcfbffe919b827da6d2397a079ced0c 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java @@ -15,7 +15,6 @@ import android.accounts.NetworkErrorException; import android.animation.AnimatorInflater; import android.app.SearchManager; import android.content.Intent; -import android.net.Uri; import android.os.Bundle; import android.text.TextUtils; import android.view.View; diff --git a/app/src/main/java/it/niedermann/owncloud/notes/shared/util/DisplayUtils.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/DisplayUtils.java index 0d1388d9c1df124169ed975346653bd0179244ad..6bf6f2ba4a1c23f26188e6a385dd3502d7a4b4d1 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/shared/util/DisplayUtils.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/DisplayUtils.java @@ -24,6 +24,7 @@ import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; +import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.main.navigation.NavigationAdapter; import it.niedermann.owncloud.notes.main.navigation.NavigationItem; @@ -32,6 +33,14 @@ import it.niedermann.owncloud.notes.persistence.entity.CategoryWithNotesCount; public class DisplayUtils { + private static final String AVATAR_URL_MID_PART = "/index.php/avatar/"; + + // added dummy query `dummy`, to resolve https://gitlab.e.foundation/e/backlog/-/issues/6839. + // NC glide lib pass kotlin.collection.emptyList which fails to convert to java.collection + // * + // 64 means that we want the 64px X 64px image. + private static final String AVATAR_URL_END_PART = "/64?dummy=1"; + private static final Map> SPECIAL_CATEGORY_REPLACEMENTS = Map.of( R.drawable.ic_library_music_grey600_24dp, singletonList(R.string.category_music), R.drawable.ic_local_movies_grey600_24dp, asList(R.string.category_movies, R.string.category_movie), @@ -106,7 +115,8 @@ public class DisplayUtils { } @NonNull - public static String getAvatarUrl(@NonNull Account account) { - return account.getUrl() + "/index.php/avatar/" + Uri.encode(SSOUtil.sanitizeUserId(account.getUserName())) + "/64"; + public static SingleSignOnUrl getAvatarUrl(@NonNull Account account) { + return new SingleSignOnUrl(account.getAccountName(), account.getUrl() + AVATAR_URL_MID_PART + + Uri.encode(SSOUtil.sanitizeUserId(account.getUserName())) + AVATAR_URL_END_PART); } }