From e8abc0bbd2c541f3c1f597bec2e594ed4930d1b5 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Tue, 21 Mar 2023 20:40:55 -0300 Subject: [PATCH] feat: make it compile again I am tired as hell someone donates plz --- .../android/GlobalUserPreferences.java | 7 ++++ .../fragments/BaseStatusListFragment.java | 1 + .../android/fragments/HomeFragment.java | 42 ------------------- .../android/fragments/SettingsFragment.java | 4 -- .../discover/DiscoverAccountsFragment.java | 1 + .../discover/DiscoverNewsFragment.java | 1 + .../discover/TrendingHashtagsFragment.java | 1 + .../displayitems/TextStatusDisplayItem.java | 15 +------ 8 files changed, 13 insertions(+), 59 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 9265794b0..3b71d7f81 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -49,6 +49,8 @@ public class GlobalUserPreferences{ public static boolean autoHideFab; public static boolean defaultToUnlistedReplies; public static boolean disableDoubleTapToSwipe; + public static boolean compactReblogReplyLine; + public static boolean replyLineAboveHeader; public static String publishButtonText; public static ThemePreference theme; public static ColorPreference color; @@ -68,6 +70,7 @@ public class GlobalUserPreferences{ */ public static String replyVisibility; + private static SharedPreferences getPrefs(){ return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE); } @@ -108,8 +111,10 @@ public class GlobalUserPreferences{ collapseLongPosts=prefs.getBoolean("collapseLongPosts", true); spectatorMode=prefs.getBoolean("spectatorMode", false); autoHideFab=prefs.getBoolean("autoHideFab", true); + compactReblogReplyLine=prefs.getBoolean("compactReblogReplyLine", true); defaultToUnlistedReplies=prefs.getBoolean("defaultToUnlistedReplies", false); disableDoubleTapToSwipe=prefs.getBoolean("disableDoubleTapToSwipe", false); + replyLineAboveHeader=prefs.getBoolean("replyLineAboveHeader", true); publishButtonText=prefs.getString("publishButtonText", ""); theme=ThemePreference.values()[prefs.getInt("theme", 0)]; recentLanguages=fromJson(prefs.getString("recentLanguages", "{}"), recentLanguagesType, new HashMap<>()); @@ -164,6 +169,8 @@ public class GlobalUserPreferences{ .putBoolean("bottomEncoding", bottomEncoding) .putBoolean("defaultToUnlistedReplies", defaultToUnlistedReplies) .putBoolean("disableDoubleTapToSwipe", disableDoubleTapToSwipe) + .putBoolean("compactReblogReplyLine", compactReblogReplyLine) + .putBoolean("replyLineAboveHeader", replyLineAboveHeader) .putInt("theme", theme.ordinal()) .putString("color", color.name()) .putString("recentLanguages", gson.toJson(recentLanguages)) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index b65a61c30..4ab6e5c67 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -66,6 +66,7 @@ import androidx.recyclerview.widget.RecyclerView; import me.grishka.appkit.Nav; import me.grishka.appkit.api.Callback; import me.grishka.appkit.api.ErrorResponse; +import me.grishka.appkit.fragments.BaseRecyclerFragment; import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java index 060909ea7..36740dcf3 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java @@ -408,46 +408,4 @@ public class HomeFragment extends AppKitFragment implements OnBackPressedListene public void onAllNotificationsSeen(AllNotificationsSeenEvent allNotificationsSeenEvent) { setNotificationBadge(false); } - - public void updateNotificationBadge() { - AccountSession session = AccountSessionManager.getInstance().getAccount(accountID); - Instance instance = AccountSessionManager.getInstance().getInstanceInfo(session.domain); - - new GetNotifications(null, 1, EnumSet.allOf(Notification.Type.class), instance.pleroma != null) - .setCallback(new Callback<>() { - @Override - public void onSuccess(List notifications) { - if (notifications.size() > 0) { - try { - long newestId = Long.parseLong(notifications.get(0).id); - long lastSeenId = Long.parseLong(session.markers.notifications.lastReadId); - setNotificationBadge(newestId > lastSeenId); - } catch (Exception ignored) { - setNotificationBadge(false); - } - } - } - - @Override - public void onError(ErrorResponse error) { - setNotificationBadge(false); - } - }).exec(accountID); - } - - public void setNotificationBadge(boolean badge) { - notificationTabIcon.setImageResource(badge - ? R.drawable.ic_fluent_alert_28_selector_badged - : R.drawable.ic_fluent_alert_28_selector); - } - - @Subscribe - public void onNotificationReceived(NotificationReceivedEvent notificationReceivedEvent) { - if (notificationReceivedEvent.account.equals(accountID)) setNotificationBadge(true); - } - - @Subscribe - public void onAllNotificationsSeen(AllNotificationsSeenEvent allNotificationsSeenEvent) { - setNotificationBadge(false); - } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index 1dd57fea4..9c474a0be 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -321,10 +321,6 @@ public class SettingsFragment extends MastodonToolbarFragment{ // GlobalUserPreferences.save(); // needAppRestart=true; // })); - boolean translationAvailable = instance.v2 != null && instance.v2.configuration.translation != null && instance.v2.configuration.translation.enabled; - items.add(new SmallTextItem(getString(translationAvailable ? - R.string.sk_settings_translation_availability_note_available : - R.string.sk_settings_translation_availability_note_unavailable, instanceName))); items.add(new HeaderItem(R.string.settings_notifications)); items.add(notificationPolicyItem=new NotificationPolicyItem()); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverAccountsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverAccountsFragment.java index 047fd0634..906ae4673 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverAccountsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverAccountsFragment.java @@ -42,6 +42,7 @@ import me.grishka.appkit.Nav; import me.grishka.appkit.api.Callback; import me.grishka.appkit.api.ErrorResponse; import me.grishka.appkit.api.SimpleCallback; +import me.grishka.appkit.fragments.BaseRecyclerFragment; import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverNewsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverNewsFragment.java index 82c17b4fa..be4c5931f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverNewsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/DiscoverNewsFragment.java @@ -28,6 +28,7 @@ import java.util.stream.Collectors; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import me.grishka.appkit.api.SimpleCallback; +import me.grishka.appkit.fragments.BaseRecyclerFragment; import me.grishka.appkit.imageloader.ImageLoaderRecyclerAdapter; import me.grishka.appkit.imageloader.ImageLoaderViewHolder; import me.grishka.appkit.imageloader.requests.ImageLoaderRequest; diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java index f4d62657e..e5f5a784f 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/TrendingHashtagsFragment.java @@ -22,6 +22,7 @@ import java.util.List; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; import me.grishka.appkit.api.SimpleCallback; +import me.grishka.appkit.fragments.BaseRecyclerFragment; import me.grishka.appkit.utils.BindableViewHolder; import me.grishka.appkit.views.UsableRecyclerView; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java index a5d18676c..50a222c89 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/TextStatusDisplayItem.java @@ -184,8 +184,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ !item.status.visibility.isLessVisibleThan(StatusPrivacy.UNLISTED) && item.status.language != null && // todo: compare to mastodon locale instead (how do i query that?!) - !item.status.language.equalsIgnoreCase(Locale.getDefault().getLanguage()))) - && (!GlobalUserPreferences.translateButtonOpenedOnly || item.textSelectable); + !item.status.language.equalsIgnoreCase(Locale.getDefault().getLanguage()))); translateWrap.setVisibility(translateVisible ? View.VISIBLE : View.GONE); translateButton.setText(item.translationShown ? R.string.sk_translate_show_original : R.string.sk_translate_post); translateInfo.setText(item.translationShown ? itemView.getResources().getString(R.string.sk_translated_using, bottomText != null ? "bottom-java" : item.status.translation.provider) : ""); @@ -207,17 +206,7 @@ public class TextStatusDisplayItem extends StatusDisplayItem{ translateProgress.setVisibility(View.VISIBLE); translateButton.setClickable(false); translateButton.animate().alpha(0.5f).setInterpolator(CubicBezierInterpolator.DEFAULT).setDuration(150).start(); - new TranslateStatus(item.status.id).setCallback(new Callback<>() { - @Override - public void onSuccess(TranslatedStatus translatedStatus) { - item.status.translation = translatedStatus; - item.setTranslationShown(true); - if (item.parentFragment.getActivity() == null) return; - translateProgress.setVisibility(View.GONE); - translateButton.setClickable(true); - translateButton.animate().alpha(1).setInterpolator(CubicBezierInterpolator.DEFAULT).setDuration(50).start(); - rebind(); - } + if(item.status.reloadWhenClicked){ UiUtils.lookupStatus(item.parentFragment.getContext(), item.status, item.parentFragment.getAccountID(), null, status1 -> { new TranslateStatus(item.status.id).setCallback(new Callback<>() {