From 85d4c1fc244d666d0c73fe2539a91f4f0f3b46aa Mon Sep 17 00:00:00 2001 From: Grishka Date: Sun, 2 Jul 2023 12:03:21 +0300 Subject: [PATCH] A bunch of crash fixes --- mastodon/build.gradle | 2 +- .../org/joinmastodon/android/fragments/ComposeFragment.java | 5 ++++- .../android/fragments/NotificationsListFragment.java | 2 +- .../org/joinmastodon/android/fragments/ProfileFragment.java | 6 ++++++ .../android/fragments/discover/SearchQueryFragment.java | 2 +- .../fragments/onboarding/AccountActivationFragment.java | 5 +++++ .../fragments/onboarding/InstanceCatalogFragment.java | 2 +- .../org/joinmastodon/android/ui/AccountSwitcherSheet.java | 3 ++- .../java/org/joinmastodon/android/ui/SearchViewHelper.java | 4 ++++ .../android/ui/displayitems/HeaderStatusDisplayItem.java | 2 ++ 10 files changed, 27 insertions(+), 6 deletions(-) diff --git a/mastodon/build.gradle b/mastodon/build.gradle index 68b677b6a..a0996dca2 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -76,7 +76,7 @@ dependencies { implementation 'me.grishka.litex:viewpager:1.0.0' implementation 'me.grishka.litex:viewpager2:1.0.0' implementation 'me.grishka.litex:palette:1.0.0' - implementation 'me.grishka.appkit:appkit:1.2.8' + implementation 'me.grishka.appkit:appkit:1.2.9' implementation 'com.google.code.gson:gson:2.8.9' implementation 'org.jsoup:jsoup:1.14.3' implementation 'com.squareup:otto:1.3.8' 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 de5412d5d..7fb4c5175 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -252,7 +252,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr selfAvatar=view.findViewById(R.id.avatar); HtmlParser.setTextWithCustomEmoji(selfName, self.displayName, self.emojis); selfUsername.setText('@'+self.username+'@'+instanceDomain); - ViewImageLoader.load(selfAvatar, null, new UrlImageLoaderRequest(self.avatar)); + if(self.avatar!=null) + ViewImageLoader.load(selfAvatar, null, new UrlImageLoaderRequest(self.avatar)); ViewOutlineProvider roundCornersOutline=new ViewOutlineProvider(){ @Override public void getOutline(View view, Outline outline){ @@ -960,6 +961,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr } private void updateVisibilityIcon(){ + if(getActivity()==null) + return; if(statusVisibility==null){ // TODO find out why this happens statusVisibility=StatusPrivacy.PUBLIC; } diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java index 8d4209ea1..12b05a9be 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java @@ -349,7 +349,7 @@ public class NotificationsListFragment extends BaseStatusListFragment(){ @Override public void onSuccess(Account result){ + savingEdits=false; account=result; AccountSessionManager.getInstance().updateAccountInfo(accountID, account); exitEditMode(); @@ -878,6 +881,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList @Override public void onError(ErrorResponse error){ + savingEdits=false; error.showToast(getActivity()); setActionProgressVisible(false); } @@ -901,6 +905,8 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList @Override public boolean onBackPressed(){ if(isInEditMode){ + if(savingEdits) + return true; if(editDirty || aboutFragment.isEditDirty()){ new M3AlertDialogBuilder(getActivity()) .setTitle(R.string.discard_changes) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchQueryFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchQueryFragment.java index 4b183cfea..d455ee470 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchQueryFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/discover/SearchQueryFragment.java @@ -279,7 +279,7 @@ public class SearchQueryFragment extends MastodonRecyclerFragment0 && filteredData.get(0)==fakeInstance){ if(list.findViewHolderForAdapterPosition(1) instanceof BindableViewHolder ivh){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/AccountSwitcherSheet.java b/mastodon/src/main/java/org/joinmastodon/android/ui/AccountSwitcherSheet.java index 3d3bc1471..23e938230 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/AccountSwitcherSheet.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/AccountSwitcherSheet.java @@ -255,7 +255,8 @@ public class AccountSwitcherSheet extends BottomSheet{ } return; } - AccountSessionManager.getInstance().setLastActiveAccountID(item.getID()); + if(AccountSessionManager.getInstance().tryGetAccount(item.getID())!=null) + AccountSessionManager.getInstance().setLastActiveAccountID(item.getID()); activity.finish(); activity.startActivity(new Intent(activity, MainActivity.class)); } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/SearchViewHelper.java b/mastodon/src/main/java/org/joinmastodon/android/ui/SearchViewHelper.java index 3a6a85c42..d816b7151 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/SearchViewHelper.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/SearchViewHelper.java @@ -126,4 +126,8 @@ public class SearchViewHelper{ public View getDivider(){ return divider; } + + public EditText getSearchEdit(){ + return searchEdit; + } } diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java index 86bdac1cc..f8055c226 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/HeaderStatusDisplayItem.java @@ -280,6 +280,8 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{ } private void updateOptionsMenu(){ + if(item.parentFragment.getActivity()==null) + return; Account account=item.user; Menu menu=optionsMenu.getMenu(); boolean isOwnPost=AccountSessionManager.getInstance().isSelf(item.parentFragment.getAccountID(), account);