refactor: fix compilation problems by refactoring old code

This commit is contained in:
LucasGGamerM 2023-06-09 18:52:08 -03:00
parent 7700288dbe
commit bc7f614573
19 changed files with 29 additions and 73 deletions

View File

@ -3,6 +3,7 @@ buildscript {
repositories {
google()
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.0.0'

View File

@ -35,7 +35,7 @@ public class ExternalShareActivity extends FragmentStackActivity{
Optional<String> text = Optional.ofNullable(getIntent().getStringExtra(Intent.EXTRA_TEXT));
Optional<Pair<String, Optional<String>>> 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<AccountSession> sessions=AccountSessionManager.getInstance().getLoggedInAccounts();

View File

@ -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);
}

View File

@ -239,11 +239,6 @@ public class EditTimelinesFragment extends RecyclerFragment<TimelineDefinition>
smoothScrollRecyclerViewToTop(list);
}
@Override
public boolean isScrolledToTop() {
return list.getChildAt(0).getTop() == 0;
}
@Override
public void onDestroy() {
super.onDestroy();

View File

@ -145,11 +145,6 @@ public class FollowRequestsListFragment extends RecyclerFragment<FollowRequestsL
}
}
@Override
public boolean isScrolledToTop() {
return list.getChildAt(0).getTop() == 0;
}
@Override
public void scrollToTop(){
smoothScrollRecyclerViewToTop(list);

View File

@ -72,10 +72,6 @@ public class FollowedHashtagsFragment extends RecyclerFragment<Hashtag> implemen
return new HashtagsAdapter();
}
@Override
public boolean isScrolledToTop() {
return list.getChildAt(0).getTop() == 0;
}
@Override
public void scrollToTop() {

View File

@ -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;

View File

@ -196,11 +196,6 @@ public class ListsFragment extends RecyclerFragment<ListTimeline> implements Scr
return adapter = new ListsAdapter();
}
@Override
public boolean isScrolledToTop() {
return list.getChildAt(0).getTop() == 0;
}
@Override
public void scrollToTop() {
smoothScrollRecyclerViewToTop(list);

View File

@ -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)

View File

@ -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) {

View File

@ -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;
}

View File

@ -33,9 +33,4 @@ public class StatusFavoritesListFragment extends StatusRelatedAccountListFragmen
? statusUri
: statusUri.buildUpon().appendPath("favourites").build();
}
@Override
public HeaderPaginationRequest<Account> onCreateRemoteRequest(String id, String maxID, int count) {
return null;
}
}

View File

@ -33,9 +33,4 @@ public class StatusReblogsListFragment extends StatusRelatedAccountListFragment{
? statusUri
: statusUri.buildUpon().appendPath("reblogs").build();
}
@Override
public HeaderPaginationRequest<Account> onCreateRemoteRequest(String id, String maxID, int count) {
return null;
}
}

View File

@ -143,11 +143,6 @@ public class DiscoverAccountsFragment extends RecyclerFragment<DiscoverAccountsF
smoothScrollRecyclerViewToTop(list);
}
@Override
public boolean isScrolledToTop() {
return list.getChildAt(0).getTop() == 0;
}
@Override
public boolean isOnTop() {
return isRecyclerViewOnTop(list);

View File

@ -224,15 +224,6 @@ public class DiscoverFragment extends AppKitFragment implements ScrollableToTop,
return view;
}
@Override
public boolean isScrolledToTop() {
if(!searchActive){
return ((ScrollableToTop)getFragmentForPage(pager.getCurrentItem())).isScrolledToTop();
}else{
return searchFragment.isScrolledToTop();
}
}
@Override
public void scrollToTop(){
if(!searchActive){

View File

@ -68,11 +68,6 @@ public class DiscoverHashtagsFragment extends RecyclerFragment<Hashtag> implemen
bannerHelper.maybeAddBanner(contentWrap);
}
@Override
public boolean isScrolledToTop() {
return list.getChildAt(0).getTop() == 0;
}
@Override
public void scrollToTop(){
smoothScrollRecyclerViewToTop(list);

View File

@ -80,11 +80,6 @@ public class DiscoverNewsFragment extends RecyclerFragment<Card> implements Scro
bannerHelper.maybeAddBanner(contentWrap);
}
@Override
public boolean isScrolledToTop() {
return list.getChildAt(0).getTop() == 0;
}
@Override
public void scrollToTop(){
smoothScrollRecyclerViewToTop(list);

View File

@ -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);
});
}

View File

@ -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