From 7dc57d27a4c0bdf1db38e926a335f8ea096946b0 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 26 Nov 2022 11:20:15 +0100 Subject: [PATCH] Set AKKOMA instance as PLEROMA --- app/build.gradle | 7 +++---- .../java/app/fedilab/android/BaseMainActivity.java | 2 +- .../android/activities/EditProfileActivity.java | 2 +- .../android/activities/ProfileActivity.java | 2 +- .../activities/admin/AdminAccountActivity.java | 2 +- .../activities/admin/AdminReportActivity.java | 2 +- .../fedilab/android/client/entities/api/Field.java | 11 +++++++++++ .../android/client/entities/app/Account.java | 1 + .../app/fedilab/android/helper/MastodonHelper.java | 14 +++++++++----- .../fedilab/android/ui/drawer/FieldAdapter.java | 2 +- .../ui/fragment/login/FragmentLoginMain.java | 1 + 11 files changed, 31 insertions(+), 15 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a677471aa..df57002d0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -92,8 +92,8 @@ dependencies { implementation 'com.vanniktech:emoji-one:0.6.0' implementation 'com.github.GrenderG:Toasty:1.5.2' implementation 'org.framagit.tom79:SparkButton:1.0.13' - implementation "com.github.bumptech.glide:glide:4.12.0" - implementation "com.github.bumptech.glide:okhttp3-integration:4.12.0" + implementation "com.github.bumptech.glide:glide:4.14.2" + implementation "com.github.bumptech.glide:okhttp3-integration:4.14.2" implementation "org.jsoup:jsoup:1.15.1" @@ -102,12 +102,11 @@ dependencies { implementation project(path: ':ratethisapp') - implementation 'com.burhanrashid52:photoeditor:1.5.1' implementation project(path: ':cropper') annotationProcessor "com.github.bumptech.glide:compiler:4.12.0" implementation 'jp.wasabeef:glide-transformations:4.3.0' - implementation 'com.github.penfeizhou.android.animation:glide-plugin:2.22.0' + implementation 'com.github.penfeizhou.android.animation:glide-plugin:2.24.0' implementation 'com.google.android.exoplayer:exoplayer:2.18.1' implementation "androidx.viewpager2:viewpager2:1.0.0" implementation 'com.github.piasy:rxandroidaudio:1.7.0' diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index f98860b45..a4ec704c9 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -661,7 +661,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } headerMainBinding.accountName.setText(currentAccount.mastodon_account.display_name); Helper.loadPP(BaseMainActivity.this, headerMainBinding.accountProfilePicture, currentAccount, false); - MastodonHelper.loadProfileMediaMastodon(headerMainBinding.backgroundImage, currentAccount.mastodon_account, MastodonHelper.MediaAccountType.HEADER); + MastodonHelper.loadProfileMediaMastodon(BaseMainActivity.this, headerMainBinding.backgroundImage, currentAccount.mastodon_account, MastodonHelper.MediaAccountType.HEADER); /* * Some general data are loaded when the app starts such; * - Pinned timelines (in app feature) diff --git a/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java b/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java index 008f8197a..8efe171b9 100644 --- a/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java @@ -89,7 +89,7 @@ public class EditProfileActivity extends BaseActivity { @SuppressWarnings("deprecation") private void initializeView() { //Hydrate values - MastodonHelper.loadProfileMediaMastodon(binding.bannerPp, currentAccount.mastodon_account, MastodonHelper.MediaAccountType.HEADER); + MastodonHelper.loadProfileMediaMastodon(EditProfileActivity.this, binding.bannerPp, currentAccount.mastodon_account, MastodonHelper.MediaAccountType.HEADER); MastodonHelper.loadPPMastodon(binding.accountPp, currentAccount.mastodon_account); binding.displayName.setText(currentAccount.mastodon_account.display_name); binding.acct.setText(String.format(Locale.getDefault(), "%s@%s", currentAccount.mastodon_account.acct, BaseMainActivity.currentInstance)); diff --git a/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java b/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java index 38be0df2f..edcd50c18 100644 --- a/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ProfileActivity.java @@ -291,7 +291,7 @@ public class ProfileActivity extends BaseActivity { } ); //Load header - MastodonHelper.loadProfileMediaMastodon(binding.bannerPp, account, MastodonHelper.MediaAccountType.HEADER); + MastodonHelper.loadProfileMediaMastodon(ProfileActivity.this, binding.bannerPp, account, MastodonHelper.MediaAccountType.HEADER); //Redraws icon for locked accounts final float scale = getResources().getDisplayMetrics().density; if (account.locked) { diff --git a/app/src/main/java/app/fedilab/android/activities/admin/AdminAccountActivity.java b/app/src/main/java/app/fedilab/android/activities/admin/AdminAccountActivity.java index c40cace7d..01a18ccdd 100644 --- a/app/src/main/java/app/fedilab/android/activities/admin/AdminAccountActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/admin/AdminAccountActivity.java @@ -272,7 +272,7 @@ public class AdminAccountActivity extends BaseActivity { } ); //Load header - MastodonHelper.loadProfileMediaMastodon(binding.bannerPp, adminAccount.account, MastodonHelper.MediaAccountType.HEADER); + MastodonHelper.loadProfileMediaMastodon(AdminAccountActivity.this, binding.bannerPp, adminAccount.account, MastodonHelper.MediaAccountType.HEADER); //Redraws icon for locked accounts final float scale = getResources().getDisplayMetrics().density; if (adminAccount.account.locked) { diff --git a/app/src/main/java/app/fedilab/android/activities/admin/AdminReportActivity.java b/app/src/main/java/app/fedilab/android/activities/admin/AdminReportActivity.java index c74897c0b..5ff001d04 100644 --- a/app/src/main/java/app/fedilab/android/activities/admin/AdminReportActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/admin/AdminReportActivity.java @@ -291,7 +291,7 @@ public class AdminReportActivity extends BaseActivity { } ); //Load header - MastodonHelper.loadProfileMediaMastodon(binding.bannerPp, account, MastodonHelper.MediaAccountType.HEADER); + MastodonHelper.loadProfileMediaMastodon(AdminReportActivity.this, binding.bannerPp, account, MastodonHelper.MediaAccountType.HEADER); //Redraws icon for locked accounts final float scale = getResources().getDisplayMetrics().density; if (account.locked) { diff --git a/app/src/main/java/app/fedilab/android/client/entities/api/Field.java b/app/src/main/java/app/fedilab/android/client/entities/api/Field.java index e1e2b3cdb..0fdbb3a66 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/api/Field.java +++ b/app/src/main/java/app/fedilab/android/client/entities/api/Field.java @@ -40,6 +40,7 @@ public class Field implements Serializable { //Some extra spannable element - They will be filled automatically when fetching the account private transient ForegroundColorSpan value_span; + private transient ForegroundColorSpan name_span; public synchronized Spannable getValueSpan(Context context, Account account, WeakReference viewWeakReference) { @@ -53,6 +54,16 @@ public class Field implements Serializable { return spannable; } + + public synchronized Spannable getLabelSpan(Context context, Account account, WeakReference viewWeakReference) { + + Spannable spannable = SpannableHelper.convert(context, name, null, account, null, true, viewWeakReference); + if (name_span != null && spannable != null) { + spannable.setSpan(name_span, 0, spannable.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + } + return spannable; + } + public static class FieldParams implements Serializable { @SerializedName("name") public String name; diff --git a/app/src/main/java/app/fedilab/android/client/entities/app/Account.java b/app/src/main/java/app/fedilab/android/client/entities/app/Account.java index 7410dc45f..7564cc362 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/app/Account.java +++ b/app/src/main/java/app/fedilab/android/client/entities/app/Account.java @@ -419,6 +419,7 @@ public class Account extends BaseAccount implements Serializable { case "PIXELFED": api = API.PIXELFED; break; + case "AKKOMA": case "PLEROMA": api = API.PLEROMA; break; diff --git a/app/src/main/java/app/fedilab/android/helper/MastodonHelper.java b/app/src/main/java/app/fedilab/android/helper/MastodonHelper.java index 59f81791a..2a8b75842 100644 --- a/app/src/main/java/app/fedilab/android/helper/MastodonHelper.java +++ b/app/src/main/java/app/fedilab/android/helper/MastodonHelper.java @@ -222,13 +222,17 @@ public class MastodonHelper { } public static void loadProfileMediaMastodon(ImageView view, Account account, MediaAccountType type) { + loadProfileMediaMastodon(null, view, account, type); + } + + public static void loadProfileMediaMastodon(Activity activity, ImageView view, Account account, MediaAccountType type) { Context context = view.getContext(); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(context); boolean disableGif = sharedpreferences.getBoolean(context.getString(R.string.SET_DISABLE_GIF), false); @DrawableRes int placeholder = type == MediaAccountType.AVATAR ? R.drawable.ic_person : R.drawable.default_banner; - if (Helper.isValidContextForGlide(view.getContext())) { + if (Helper.isValidContextForGlide(activity != null ? activity : context)) { if (account == null) { - Glide.with(view.getContext()) + Glide.with(activity != null ? activity : context) .asDrawable() .load(placeholder) .thumbnail(0.1f) @@ -239,14 +243,14 @@ public class MastodonHelper { String targetedUrl = disableGif ? (type == MediaAccountType.AVATAR ? account.avatar_static : account.header_static) : (type == MediaAccountType.AVATAR ? account.avatar : account.header); if (targetedUrl != null) { if (disableGif || (!targetedUrl.endsWith(".gif"))) { - Glide.with(view.getContext()) + Glide.with(activity != null ? activity : context) .asDrawable() .load(targetedUrl) .thumbnail(0.1f) .placeholder(placeholder) .into(view); } else { - Glide.with(view.getContext()) + Glide.with(activity != null ? activity : context) .asGif() .load(targetedUrl) .thumbnail(0.1f) @@ -254,7 +258,7 @@ public class MastodonHelper { .into(view); } } else { - Glide.with(view.getContext()) + Glide.with(activity != null ? activity : context) .asDrawable() .load(placeholder) .thumbnail(0.1f) diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/FieldAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/FieldAdapter.java index 3513525eb..ec3587d6f 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/FieldAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/FieldAdapter.java @@ -77,7 +77,7 @@ public class FieldAdapter extends RecyclerView.Adapter(holder.binding.label)), TextView.BufferType.SPANNABLE); holder.binding.label.setMovementMethod(LinkMovementMethod.getInstance()); diff --git a/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginMain.java b/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginMain.java index 6ec7e0dad..39677e9fe 100644 --- a/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginMain.java +++ b/app/src/main/java/app/fedilab/android/ui/fragment/login/FragmentLoginMain.java @@ -160,6 +160,7 @@ public class FragmentLoginMain extends Fragment { case "PIXELFED": apiLogin = Account.API.PIXELFED; break; + case "AKKOMA": case "PLEROMA": apiLogin = Account.API.PLEROMA; break;