diff --git a/mastodon/build.gradle b/mastodon/build.gradle index d031144b..21af4311 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -9,8 +9,8 @@ android { applicationId "org.joinmastodon.android" minSdk 23 targetSdk 31 - versionCode 36 - versionName "1.1.0" + versionCode 37 + versionName "1.1.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java b/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java index 74f6ccdd..4e24629e 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/MastodonErrorResponse.java @@ -26,6 +26,8 @@ public class MastodonErrorResponse extends ErrorResponse{ @Override public void showToast(Context context){ + if(context==null) + return; Toast.makeText(context, error, Toast.LENGTH_SHORT).show(); } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index f7d53fbc..b2105f6b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -609,6 +609,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr @Override public void onSuccess(Status result){ wm.removeView(sendingOverlay); + sendingOverlay=null; Nav.finish(ComposeFragment.this); E.post(new StatusCreatedEvent(result)); if(replyTo!=null){ @@ -620,6 +621,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr @Override public void onError(ErrorResponse error){ wm.removeView(sendingOverlay); + sendingOverlay=null; sendProgress.setVisibility(View.GONE); sendError.setVisibility(View.VISIBLE); publishButton.setEnabled(true); @@ -647,6 +649,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr confirmDiscardDraftAndFinish(); return true; } + if(sendingOverlay!=null) + return true; return false; } 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 eb602005..4f0907e3 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ProfileFragment.java @@ -128,6 +128,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList private View fab; private WindowInsets childInsets; private PhotoViewer currentPhotoViewer; + private boolean editModeLoading; public ProfileFragment(){ super(R.layout.loader_fragment_overlay_toolbar); @@ -664,17 +665,26 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList } private void loadAccountInfoAndEnterEditMode(){ + if(editModeLoading) + return; + editModeLoading=true; setActionProgressVisible(true); new GetOwnAccount() .setCallback(new Callback<>(){ @Override public void onSuccess(Account result){ + editModeLoading=false; + if(getActivity()==null) + return; enterEditMode(result); setActionProgressVisible(false); } @Override public void onError(ErrorResponse error){ + editModeLoading=false; + if(getActivity()==null) + return; error.showToast(getActivity()); setActionProgressVisible(false); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ScrollableToTop.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ScrollableToTop.java index 705c5d9f..d6a28ae6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ScrollableToTop.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ScrollableToTop.java @@ -13,6 +13,8 @@ public interface ScrollableToTop{ * @param list */ default void smoothScrollRecyclerViewToTop(RecyclerView list){ + if(list==null) // TODO find out why this happens because it should not be possible + return; if(list.getChildCount()>0 && list.getChildAdapterPosition(list.getChildAt(0))>10){ list.scrollToPosition(0); list.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchFragment.java index c7a1f0ab..a2c9a604 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchFragment.java @@ -117,6 +117,8 @@ public class SearchFragment extends BaseStatusListFragment{ protected void doLoadData(int offset, int count){ if(isInRecentMode()){ AccountSessionManager.getInstance().getAccount(accountID).getCacheController().getRecentSearches(sr->{ + if(getActivity()==null) + return; unfilteredResults=sr; prevDisplayItems=new ArrayList<>(displayItems); onDataLoaded(sr, false); 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 ab2f828b..a689ae93 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 @@ -2,6 +2,7 @@ package org.joinmastodon.android.ui.utils; import android.annotation.SuppressLint; import android.app.Activity; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.res.ColorStateList; @@ -29,6 +30,7 @@ import android.webkit.MimeTypeMap; import android.widget.Button; import android.widget.PopupMenu; import android.widget.TextView; +import android.widget.Toast; import org.joinmastodon.android.E; import org.joinmastodon.android.GlobalUserPreferences; @@ -87,13 +89,17 @@ public class UiUtils{ private UiUtils(){} public static void launchWebBrowser(Context context, String url){ - if(GlobalUserPreferences.useCustomTabs){ - new CustomTabsIntent.Builder() - .setShowTitle(true) - .build() - .launchUrl(context, Uri.parse(url)); - }else{ - context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + try{ + if(GlobalUserPreferences.useCustomTabs){ + new CustomTabsIntent.Builder() + .setShowTitle(true) + .build() + .launchUrl(context, Uri.parse(url)); + }else{ + context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + } + }catch(ActivityNotFoundException x){ + Toast.makeText(context, R.string.no_app_to_handle_action, Toast.LENGTH_SHORT).show(); } }