From bc7f614573ec5195abde465118c4747ca97a4674 Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Fri, 9 Jun 2023 18:52:08 -0300 Subject: [PATCH] refactor: fix compilation problems by refactoring old code --- build.gradle | 1 + .../android/ExternalShareActivity.java | 2 +- .../android/GlobalUserPreferences.java | 3 +-- .../fragments/EditTimelinesFragment.java | 5 ----- .../fragments/FollowRequestsListFragment.java | 5 ----- .../fragments/FollowedHashtagsFragment.java | 4 ---- .../android/fragments/HomeTabFragment.java | 7 +------ .../android/fragments/ListsFragment.java | 5 ----- .../fragments/NotificationsFragment.java | 7 +------ .../android/fragments/ProfileFragment.java | 19 +++++++++++++++++++ .../android/fragments/ThreadFragment.java | 2 +- .../StatusFavoritesListFragment.java | 5 ----- .../StatusReblogsListFragment.java | 5 ----- .../discover/DiscoverAccountsFragment.java | 5 ----- .../fragments/discover/DiscoverFragment.java | 9 --------- .../discover/DiscoverHashtagsFragment.java | 5 ----- .../discover/DiscoverNewsFragment.java | 5 ----- .../displayitems/FooterStatusDisplayItem.java | 4 ++-- .../android/ui/utils/UiUtils.java | 4 ++-- 19 files changed, 29 insertions(+), 73 deletions(-) diff --git a/build.gradle b/build.gradle index 8357ab502..a3d106727 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ buildscript { repositories { google() mavenCentral() + mavenLocal() } dependencies { classpath 'com.android.tools.build:gradle:8.0.0' diff --git a/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java b/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java index ce56efb54..2b655db19 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ExternalShareActivity.java @@ -35,7 +35,7 @@ public class ExternalShareActivity extends FragmentStackActivity{ Optional text = Optional.ofNullable(getIntent().getStringExtra(Intent.EXTRA_TEXT)); Optional>> fediHandle = text.flatMap(UiUtils::parseFediverseHandle); - boolean isFediUrl = text.map(UiUtils::looksLikeFediverseUrl).orElse(false); + boolean isFediUrl = text.map(UiUtils::looksLikeMastodonUrl).orElse(false); boolean isOpenable = isFediUrl || fediHandle.isPresent(); List sessions=AccountSessionManager.getInstance().getLoggedInAccounts(); diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 66501a16c..e946c2846 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -36,7 +36,6 @@ public class GlobalUserPreferences{ public static boolean enableDeleteNotifications; public static boolean translateButtonOpenedOnly; public static boolean uniformNotificationIcon; - public static boolean enableDeleteNotifications; public static boolean relocatePublishButton; public static boolean reduceMotion; public static boolean keepOnlyLatestNotification; @@ -81,7 +80,7 @@ public class GlobalUserPreferences{ */ public static String replyVisibility; - private static SharedPreferences getPrefs(){ + public static SharedPreferences getPrefs(){ return MastodonApp.context.getSharedPreferences("global", Context.MODE_PRIVATE); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/EditTimelinesFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/EditTimelinesFragment.java index ee751c3ce..3d5037051 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/EditTimelinesFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/EditTimelinesFragment.java @@ -239,11 +239,6 @@ public class EditTimelinesFragment extends RecyclerFragment smoothScrollRecyclerViewToTop(list); } - @Override - public boolean isScrolledToTop() { - return list.getChildAt(0).getTop() == 0; - } - @Override public void onDestroy() { super.onDestroy(); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java index d23531be1..9f144634d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/FollowRequestsListFragment.java @@ -145,11 +145,6 @@ public class FollowRequestsListFragment extends RecyclerFragment implemen return new HashtagsAdapter(); } - @Override - public boolean isScrolledToTop() { - return list.getChildAt(0).getTop() == 0; - } @Override public void scrollToTop() { diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java index 59d7f3263..4867a86d6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTabFragment.java @@ -510,7 +510,7 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab @Override public void scrollToTop(){ - if (((ScrollableToTop) fragments[pager.getCurrentItem()]).isScrolledToTop() && + if (((IsOnTop) fragments[pager.getCurrentItem()]).isOnTop() && GlobalUserPreferences.doubleTapToSwipe && !newPostsBtnShown) { int nextPage = (pager.getCurrentItem() + 1) % count; navigateTo(nextPage); @@ -519,11 +519,6 @@ public class HomeTabFragment extends MastodonToolbarFragment implements Scrollab ((ScrollableToTop) fragments[pager.getCurrentItem()]).scrollToTop(); } - @Override - public boolean isScrolledToTop() { - return ((ScrollableToTop) fragments[pager.getCurrentItem()]).isScrolledToTop(); - } - public void hideNewPostsButton(){ if(!newPostsBtnShown) return; diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ListsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ListsFragment.java index 42e9c53ed..243a104c6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ListsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ListsFragment.java @@ -196,11 +196,6 @@ public class ListsFragment extends RecyclerFragment implements Scr return adapter = new ListsAdapter(); } - @Override - public boolean isScrolledToTop() { - return list.getChildAt(0).getTop() == 0; - } - @Override public void scrollToTop() { smoothScrollRecyclerViewToTop(list); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java index a80c9d192..6a3ce20d1 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsFragment.java @@ -212,7 +212,7 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc @Override public void scrollToTop(){ - if (getFragmentForPage(pager.getCurrentItem()).isScrolledToTop() && GlobalUserPreferences.doubleTapToSwipe) { + if (getFragmentForPage(pager.getCurrentItem()).isOnTop() && GlobalUserPreferences.doubleTapToSwipe) { int nextPage = (pager.getCurrentItem() + 1) % tabViews.length; pager.setCurrentItem(nextPage, true); return; @@ -220,11 +220,6 @@ public class NotificationsFragment extends MastodonToolbarFragment implements Sc getFragmentForPage(pager.getCurrentItem()).scrollToTop(); } - @Override - public boolean isScrolledToTop() { - return getFragmentForPage(pager.getCurrentItem()).isScrolledToTop(); - } - public void loadData(){ refreshFollowRequestsBadge(); if(allNotificationsFragment!=null && !allNotificationsFragment.loaded && !allNotificationsFragment.dataLoading) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java index 7a61ba8c7..684078214 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -448,6 +448,25 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList V.setVisibilityAnimated(fab, View.VISIBLE); } + public void setNote(String note){ + this.note=note; + noteWrap.setVisibility(View.VISIBLE); + noteEdit.setVisibility(View.VISIBLE); + noteEdit.setText(note); + } + + private void savePrivateNote(){ + new SetPrivateNote(profileAccountID, noteEdit.getText().toString()).setCallback(new Callback<>() { + @Override + public void onSuccess(Relationship result) {} + + @Override + public void onError(ErrorResponse error) { + error.showToast(getActivity()); + } + }).exec(accountID); + } + @Override protected void doLoadData(){ if (remoteAccount != null) { diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java index 6ff24b7b7..a4fd08152 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java @@ -107,7 +107,7 @@ public class ThreadFragment extends StatusListFragment implements ProvidesAssist } for (int deleteThisItem : deleteTheseItems) itemsToModify.remove(deleteThisItem); if(s.id.equals(mainStatus.id)) { - items.add(new ExtendedFooterStatusDisplayItem(s.id, this, s.getContentStatus())); + items.add(new ExtendedFooterStatusDisplayItem(s.id, this, getAccountID(), s.getContentStatus())); } return items; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/StatusFavoritesListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/StatusFavoritesListFragment.java index 627bd4ad8..20d0c2acf 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/StatusFavoritesListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/StatusFavoritesListFragment.java @@ -33,9 +33,4 @@ public class StatusFavoritesListFragment extends StatusRelatedAccountListFragmen ? statusUri : statusUri.buildUpon().appendPath("favourites").build(); } - - @Override - public HeaderPaginationRequest onCreateRemoteRequest(String id, String maxID, int count) { - return null; - } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/StatusReblogsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/StatusReblogsListFragment.java index 608e34d08..3c5a5e228 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/StatusReblogsListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/account_list/StatusReblogsListFragment.java @@ -33,9 +33,4 @@ public class StatusReblogsListFragment extends StatusRelatedAccountListFragment{ ? statusUri : statusUri.buildUpon().appendPath("reblogs").build(); } - - @Override - public HeaderPaginationRequest onCreateRemoteRequest(String id, String maxID, int count) { - return null; - } } 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 0a68f22c8..d5fb1dd5d 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 @@ -143,11 +143,6 @@ public class DiscoverAccountsFragment extends RecyclerFragment implemen bannerHelper.maybeAddBanner(contentWrap); } - @Override - public boolean isScrolledToTop() { - return list.getChildAt(0).getTop() == 0; - } - @Override public void scrollToTop(){ smoothScrollRecyclerViewToTop(list); 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 4d490c7db..67e030514 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 @@ -80,11 +80,6 @@ public class DiscoverNewsFragment extends RecyclerFragment implements Scro bannerHelper.maybeAddBanner(contentWrap); } - @Override - public boolean isScrolledToTop() { - return list.getChildAt(0).getTop() == 0; - } - @Override public void scrollToTop(){ smoothScrollRecyclerViewToTop(list); diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java index 7f3ccad22..a88493c7a 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java @@ -370,7 +370,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ } else { v.startAnimation(opacityIn); } - bindButton(favorite, r.favouritesCount); + bindText(favorites, r.favouritesCount); }); } ); @@ -383,7 +383,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ } else { v.startAnimation(opacityIn); } - bindButton(favorite, r.favouritesCount); + bindText(favorites, r.favouritesCount); }); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java index cce7b9427..b4a81d770 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/utils/UiUtils.java @@ -108,6 +108,7 @@ import java.lang.reflect.Method; import java.net.IDN; import java.net.URI; import java.net.URISyntaxException; +import java.time.Duration; import java.time.Instant; import java.time.ZoneId; import java.time.ZonedDateTime; @@ -809,7 +810,6 @@ public class UiUtils { } }) .exec(accountID); - } } @@ -1282,7 +1282,7 @@ public class UiUtils { } }) .exec(accountID)); - } else if (looksLikeFediverseUrl(url)) { + } else if (looksLikeMastodonUrl(url)) { return Optional.of(new GetSearchResults(url, null, true) .setCallback(new Callback<>() { @Override