Loading app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +22 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import static android.content.Context.DOWNLOAD_SERVICE; import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.mastodon.activities.BaseActivity.currentThemeId; import static app.fedilab.android.mastodon.helper.LogoHelper.getNotificationIcon; import static app.fedilab.android.mastodon.helper.ThemeHelper.fetchAccentColor; import android.annotation.SuppressLint; import android.app.Activity; Loading @@ -42,6 +43,7 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.media.RingtoneManager; import android.net.ConnectivityManager; Loading Loading @@ -89,6 +91,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import com.avatarfirst.avatargenlib.AvatarGenerator; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.load.resource.bitmap.CenterCrop; Loading Loading @@ -1062,10 +1065,26 @@ public class Helper { if (account.mastodon_account != null) { targetedUrl = disableGif ? account.mastodon_account.avatar_static : account.mastodon_account.avatar; } else if (account.peertube_account != null) { if (account.peertube_account.getAvatar() != null) { targetedUrl = account.peertube_account.getAvatar().getPath(); if (targetedUrl != null && targetedUrl.startsWith("/")) { targetedUrl = "https://" + account.instance + account.peertube_account.getAvatar().getPath(); } } else { BitmapDrawable avatar = new AvatarGenerator.AvatarBuilder(activity) .setLabel(account.peertube_account.getAcct()) .setAvatarSize(120) .setTextSize(30) .toSquare() .setBackgroundColor(fetchAccentColor(activity)) .build(); Glide.with(activity) .asDrawable() .load(avatar) .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))) .into(view); return; } } if (targetedUrl != null && Helper.isValidContextForGlide(activity)) { Loading app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java +14 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.webkit.URLUtil; import androidx.documentfile.provider.DocumentFile; import androidx.preference.PreferenceManager; import com.google.android.material.button.MaterialButton; import com.google.gson.JsonSyntaxException; import org.jetbrains.annotations.NotNull; Loading Loading @@ -94,6 +95,7 @@ import app.fedilab.android.peertube.viewmodel.CommentVM; import app.fedilab.android.peertube.viewmodel.PlaylistsVM; import app.fedilab.android.peertube.viewmodel.TimelineVM; import app.fedilab.android.sqlite.Sqlite; import es.dmoral.toasty.Toasty; import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.OkHttpClient; Loading Loading @@ -158,7 +160,18 @@ public class RetrofitPeertubeAPI { String instance = host; try { UserMe userMe = new RetrofitPeertubeAPI(activity, instance, token).verifyCredentials(); if (userMe == null) { Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { MaterialButton login = activity.findViewById(R.id.login_button); if (login != null) { login.setEnabled(true); } Toasty.error(activity, activity.getString(R.string.toast_error_peertube_not_supported), Toasty.LENGTH_SHORT).show(); }; mainHandler.post(myRunnable); return; } peertubeAccount = userMe.getAccount(); } catch (Error error) { Error.displayError(activity, error); Loading app/src/main/java/app/fedilab/android/peertube/client/entities/UserMe.java +4 −4 Original line number Diff line number Diff line Loading @@ -55,8 +55,8 @@ public class UserMe { private NotificationSettings notificationSettings; @SerializedName("nsfwPolicy") private String nsfwPolicy; @SerializedName("role") private Role role; /* @SerializedName("role") private Role role;*/ @SerializedName("roleLabel") private String roleLabel; @SerializedName("username") Loading @@ -74,13 +74,13 @@ public class UserMe { @SerializedName("webTorrentEnabled") private boolean webTorrentEnabled; public Role getRole() { /* public Role getRole() { return role; } public void setRole(Role role) { this.role = role; } }*/ public PeertubeAccount getAccount() { return account; Loading Loading
app/src/main/java/app/fedilab/android/mastodon/helper/Helper.java +22 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import static android.content.Context.DOWNLOAD_SERVICE; import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.mastodon.activities.BaseActivity.currentThemeId; import static app.fedilab.android.mastodon.helper.LogoHelper.getNotificationIcon; import static app.fedilab.android.mastodon.helper.ThemeHelper.fetchAccentColor; import android.annotation.SuppressLint; import android.app.Activity; Loading @@ -42,6 +43,7 @@ import android.graphics.Color; import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.media.RingtoneManager; import android.net.ConnectivityManager; Loading Loading @@ -89,6 +91,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; import com.avatarfirst.avatargenlib.AvatarGenerator; import com.bumptech.glide.Glide; import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.load.resource.bitmap.CenterCrop; Loading Loading @@ -1062,10 +1065,26 @@ public class Helper { if (account.mastodon_account != null) { targetedUrl = disableGif ? account.mastodon_account.avatar_static : account.mastodon_account.avatar; } else if (account.peertube_account != null) { if (account.peertube_account.getAvatar() != null) { targetedUrl = account.peertube_account.getAvatar().getPath(); if (targetedUrl != null && targetedUrl.startsWith("/")) { targetedUrl = "https://" + account.instance + account.peertube_account.getAvatar().getPath(); } } else { BitmapDrawable avatar = new AvatarGenerator.AvatarBuilder(activity) .setLabel(account.peertube_account.getAcct()) .setAvatarSize(120) .setTextSize(30) .toSquare() .setBackgroundColor(fetchAccentColor(activity)) .build(); Glide.with(activity) .asDrawable() .load(avatar) .apply(new RequestOptions().transform(new CenterCrop(), new RoundedCorners(10))) .into(view); return; } } if (targetedUrl != null && Helper.isValidContextForGlide(activity)) { Loading
app/src/main/java/app/fedilab/android/peertube/client/RetrofitPeertubeAPI.java +14 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.webkit.URLUtil; import androidx.documentfile.provider.DocumentFile; import androidx.preference.PreferenceManager; import com.google.android.material.button.MaterialButton; import com.google.gson.JsonSyntaxException; import org.jetbrains.annotations.NotNull; Loading Loading @@ -94,6 +95,7 @@ import app.fedilab.android.peertube.viewmodel.CommentVM; import app.fedilab.android.peertube.viewmodel.PlaylistsVM; import app.fedilab.android.peertube.viewmodel.TimelineVM; import app.fedilab.android.sqlite.Sqlite; import es.dmoral.toasty.Toasty; import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.OkHttpClient; Loading Loading @@ -158,7 +160,18 @@ public class RetrofitPeertubeAPI { String instance = host; try { UserMe userMe = new RetrofitPeertubeAPI(activity, instance, token).verifyCredentials(); if (userMe == null) { Handler mainHandler = new Handler(Looper.getMainLooper()); Runnable myRunnable = () -> { MaterialButton login = activity.findViewById(R.id.login_button); if (login != null) { login.setEnabled(true); } Toasty.error(activity, activity.getString(R.string.toast_error_peertube_not_supported), Toasty.LENGTH_SHORT).show(); }; mainHandler.post(myRunnable); return; } peertubeAccount = userMe.getAccount(); } catch (Error error) { Error.displayError(activity, error); Loading
app/src/main/java/app/fedilab/android/peertube/client/entities/UserMe.java +4 −4 Original line number Diff line number Diff line Loading @@ -55,8 +55,8 @@ public class UserMe { private NotificationSettings notificationSettings; @SerializedName("nsfwPolicy") private String nsfwPolicy; @SerializedName("role") private Role role; /* @SerializedName("role") private Role role;*/ @SerializedName("roleLabel") private String roleLabel; @SerializedName("username") Loading @@ -74,13 +74,13 @@ public class UserMe { @SerializedName("webTorrentEnabled") private boolean webTorrentEnabled; public Role getRole() { /* public Role getRole() { return role; } public void setRole(Role role) { this.role = role; } }*/ public PeertubeAccount getAccount() { return account; Loading