diff --git a/app/build.gradle b/app/build.gradle index 1c308d3f010990db764fb9ab8badd5064146c2a9..786286d7cb7534abee7c053566dee0b71bfd1695 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -60,9 +60,6 @@ dependencies { implementation ('com.github.stefan-niedermann:android-commons:0.2.7') { exclude group: 'com.github.nextcloud', module: 'Android-SingleSignOn' } - implementation ('com.github.stefan-niedermann.nextcloud-commons:sso-glide:1.6.4') { - exclude group: 'com.github.nextcloud', module: 'Android-SingleSignOn' - } implementation ('com.github.stefan-niedermann.nextcloud-commons:exception:1.6.4') { exclude group: 'com.github.nextcloud', module: 'Android-SingleSignOn' } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherDialog.java b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherDialog.java index 7d088afea6f1afbdc6b01b77f66e58b76e65e10e..20c1eed4ff9e3c6da92c586ed4bea7523c4c53b2 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherDialog.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherDialog.java @@ -22,6 +22,7 @@ import it.niedermann.owncloud.notes.databinding.DialogAccountSwitcherBinding; import it.niedermann.owncloud.notes.manageaccounts.ManageAccountsActivity; import it.niedermann.owncloud.notes.persistence.NotesRepository; import it.niedermann.owncloud.notes.persistence.entity.Account; +import it.niedermann.owncloud.notes.shared.util.DisplayUtils; /** * Displays all available {@link Account} entries and provides basic operations for them, like adding or switching @@ -67,7 +68,7 @@ public class AccountSwitcherDialog extends BrandedDialogFragment { binding.accountName.setText(currentLocalAccount.getDisplayName()); binding.accountHost.setText(Uri.parse(currentLocalAccount.getUrl()).getHost()); Glide.with(requireContext()) - .load(currentLocalAccount.getUrl() + "/index.php/avatar/" + Uri.encode(currentLocalAccount.getUserName()) + "/64") + .load(DisplayUtils.getAvatarUrl(currentLocalAccount)) .error(R.drawable.ic_account_circle_grey_24dp) .apply(RequestOptions.circleCropTransform()) .into(binding.currentAccountItemAvatar); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherViewHolder.java index 1f096c96e05e38fe378ba07c04437d71200fe615..512c9a9c25d26c7859b821470ab60d788984734a 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/accountswitcher/AccountSwitcherViewHolder.java @@ -10,10 +10,10 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; -import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding; import it.niedermann.owncloud.notes.persistence.entity.Account; +import it.niedermann.owncloud.notes.shared.util.DisplayUtils; public class AccountSwitcherViewHolder extends RecyclerView.ViewHolder { @@ -28,7 +28,7 @@ public class AccountSwitcherViewHolder extends RecyclerView.ViewHolder { binding.accountName.setText(localAccount.getDisplayName()); binding.accountHost.setText(Uri.parse(localAccount.getUrl()).getHost()); Glide.with(itemView.getContext()) - .load(new SingleSignOnUrl(localAccount.getAccountName(), localAccount.getUrl() + "/index.php/avatar/" + Uri.encode(localAccount.getUserName()) + "/64")) + .load(DisplayUtils.getAvatarUrl(localAccount)) .placeholder(R.drawable.ic_account_circle_grey_24dp) .error(R.drawable.ic_account_circle_grey_24dp) .apply(RequestOptions.circleCropTransform()) 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 9843e4cabc4ad57e5a11711d7b5cb25d9faccdf6..fce42c0ba73f3c1deb4498de6eb5cca5535f12be 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 @@ -92,6 +92,7 @@ import it.niedermann.owncloud.notes.shared.model.IResponseCallback; import it.niedermann.owncloud.notes.shared.model.NavigationCategory; import it.niedermann.owncloud.notes.shared.model.NoteClickListener; import it.niedermann.owncloud.notes.shared.util.CustomAppGlideModule; +import it.niedermann.owncloud.notes.shared.util.DisplayUtils; import it.niedermann.owncloud.notes.shared.util.NoteUtil; import it.niedermann.owncloud.notes.shared.util.ShareUtil; import trikita.log.Log; @@ -307,7 +308,7 @@ public class MainActivity extends LockedActivity implements NoteClickListener, A fabCreate.hide(); Glide .with(this) - .load(nextAccount.getUrl() + "/index.php/avatar/" + Uri.encode(nextAccount.getUserName()) + "/64") + .load(DisplayUtils.getAvatarUrl(nextAccount)) .placeholder(R.drawable.ic_account_circle_grey_24dp) .error(R.drawable.ic_account_circle_grey_24dp) .apply(RequestOptions.circleCropTransform()) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java index 26b1e785cc2b8c5904e2fa4c8cdff96e4bbee3ad..32687e66c10a4c4b932bca8c100b7af43beab4d8 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/manageaccounts/ManageAccountViewHolder.java @@ -16,10 +16,10 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; -import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding; import it.niedermann.owncloud.notes.persistence.entity.Account; +import it.niedermann.owncloud.notes.shared.util.DisplayUtils; public class ManageAccountViewHolder extends RecyclerView.ViewHolder { @@ -38,7 +38,7 @@ public class ManageAccountViewHolder extends RecyclerView.ViewHolder { binding.accountName.setText(localAccount.getUserName()); binding.accountHost.setText(Uri.parse(localAccount.getUrl()).getHost()); Glide.with(itemView.getContext()) - .load(new SingleSignOnUrl(localAccount.getAccountName(), localAccount.getUrl() + "/index.php/avatar/" + Uri.encode(localAccount.getUserName()) + "/64")) + .load(DisplayUtils.getAvatarUrl(localAccount)) .error(R.drawable.ic_account_circle_grey_24dp) .apply(RequestOptions.circleCropTransform()) .into(binding.accountItemAvatar); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/shared/account/AccountChooserViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/account/AccountChooserViewHolder.java index 5d3d296328e37cb02a170ae2c9ae505007bd2092..494f9291753a2e02c1dc8761ce75ec5cf296088e 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/shared/account/AccountChooserViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/account/AccountChooserViewHolder.java @@ -8,10 +8,10 @@ import androidx.recyclerview.widget.RecyclerView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.RequestOptions; -import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding; import it.niedermann.owncloud.notes.persistence.entity.Account; +import it.niedermann.owncloud.notes.shared.util.DisplayUtils; public class AccountChooserViewHolder extends RecyclerView.ViewHolder { private final ItemAccountChooseBinding binding; @@ -24,7 +24,7 @@ public class AccountChooserViewHolder extends RecyclerView.ViewHolder { public void bind(Account localAccount, Consumer targetAccountConsumer) { Glide .with(binding.accountItemAvatar.getContext()) - .load(new SingleSignOnUrl(localAccount.getAccountName(), localAccount.getUrl() + "/index.php/avatar/" + Uri.encode(localAccount.getUserName()) + "/64")) + .load(DisplayUtils.getAvatarUrl(localAccount)) .placeholder(R.drawable.ic_account_circle_grey_24dp) .error(R.drawable.ic_account_circle_grey_24dp) .apply(RequestOptions.circleCropTransform()) 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 abba8e002136302ef169f1aead1a1a4ce4813398..0aeb1bf49fd2ff8f6eb61e519394fa0894e1f7f1 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 @@ -8,6 +8,7 @@ import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Rect; +import android.net.Uri; import android.os.Build; import android.util.TypedValue; import android.view.View; @@ -26,6 +27,7 @@ import java.util.stream.Stream; import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.main.navigation.NavigationAdapter; import it.niedermann.owncloud.notes.main.navigation.NavigationItem; +import it.niedermann.owncloud.notes.persistence.entity.Account; import it.niedermann.owncloud.notes.persistence.entity.CategoryWithNotesCount; public class DisplayUtils { @@ -102,4 +104,9 @@ public class DisplayUtils { final int heightDiff = parentView.getRootView().getHeight() - (rect.bottom - rect.top); return heightDiff >= estimatedKeyboardHeight; } + + @NonNull + public static String getAvatarUrl(@NonNull Account account) { + return account.getUrl() + "/index.php/avatar/" + Uri.encode(account.getUserName()) + "/64"; + } }