Merge branch 'mastodon:master' into feature/display-alt-text

This commit is contained in:
Samuel Kaiser 2022-05-06 00:29:05 +02:00 committed by GitHub
commit f0cef2103f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 10 deletions

View File

@ -9,8 +9,8 @@ android {
applicationId "org.joinmastodon.android" applicationId "org.joinmastodon.android"
minSdk 23 minSdk 23
targetSdk 31 targetSdk 31
versionCode 36 versionCode 37
versionName "1.1.0" versionName "1.1.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@ -26,6 +26,8 @@ public class MastodonErrorResponse extends ErrorResponse{
@Override @Override
public void showToast(Context context){ public void showToast(Context context){
if(context==null)
return;
Toast.makeText(context, error, Toast.LENGTH_SHORT).show(); Toast.makeText(context, error, Toast.LENGTH_SHORT).show();
} }
} }

View File

@ -609,6 +609,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
@Override @Override
public void onSuccess(Status result){ public void onSuccess(Status result){
wm.removeView(sendingOverlay); wm.removeView(sendingOverlay);
sendingOverlay=null;
Nav.finish(ComposeFragment.this); Nav.finish(ComposeFragment.this);
E.post(new StatusCreatedEvent(result)); E.post(new StatusCreatedEvent(result));
if(replyTo!=null){ if(replyTo!=null){
@ -620,6 +621,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
@Override @Override
public void onError(ErrorResponse error){ public void onError(ErrorResponse error){
wm.removeView(sendingOverlay); wm.removeView(sendingOverlay);
sendingOverlay=null;
sendProgress.setVisibility(View.GONE); sendProgress.setVisibility(View.GONE);
sendError.setVisibility(View.VISIBLE); sendError.setVisibility(View.VISIBLE);
publishButton.setEnabled(true); publishButton.setEnabled(true);
@ -647,6 +649,8 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
confirmDiscardDraftAndFinish(); confirmDiscardDraftAndFinish();
return true; return true;
} }
if(sendingOverlay!=null)
return true;
return false; return false;
} }

View File

@ -128,6 +128,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
private View fab; private View fab;
private WindowInsets childInsets; private WindowInsets childInsets;
private PhotoViewer currentPhotoViewer; private PhotoViewer currentPhotoViewer;
private boolean editModeLoading;
public ProfileFragment(){ public ProfileFragment(){
super(R.layout.loader_fragment_overlay_toolbar); super(R.layout.loader_fragment_overlay_toolbar);
@ -664,17 +665,26 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
} }
private void loadAccountInfoAndEnterEditMode(){ private void loadAccountInfoAndEnterEditMode(){
if(editModeLoading)
return;
editModeLoading=true;
setActionProgressVisible(true); setActionProgressVisible(true);
new GetOwnAccount() new GetOwnAccount()
.setCallback(new Callback<>(){ .setCallback(new Callback<>(){
@Override @Override
public void onSuccess(Account result){ public void onSuccess(Account result){
editModeLoading=false;
if(getActivity()==null)
return;
enterEditMode(result); enterEditMode(result);
setActionProgressVisible(false); setActionProgressVisible(false);
} }
@Override @Override
public void onError(ErrorResponse error){ public void onError(ErrorResponse error){
editModeLoading=false;
if(getActivity()==null)
return;
error.showToast(getActivity()); error.showToast(getActivity());
setActionProgressVisible(false); setActionProgressVisible(false);
} }

View File

@ -13,6 +13,8 @@ public interface ScrollableToTop{
* @param list * @param list
*/ */
default void smoothScrollRecyclerViewToTop(RecyclerView 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){ if(list.getChildCount()>0 && list.getChildAdapterPosition(list.getChildAt(0))>10){
list.scrollToPosition(0); list.scrollToPosition(0);
list.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){ list.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener(){

View File

@ -22,6 +22,7 @@ import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.R; import org.joinmastodon.android.R;
import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships; import org.joinmastodon.android.api.requests.accounts.GetAccountRelationships;
import org.joinmastodon.android.api.requests.accounts.SetAccountFollowed; import org.joinmastodon.android.api.requests.accounts.SetAccountFollowed;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.fragments.ProfileFragment; import org.joinmastodon.android.fragments.ProfileFragment;
import org.joinmastodon.android.fragments.report.ReportReasonChoiceFragment; import org.joinmastodon.android.fragments.report.ReportReasonChoiceFragment;
import org.joinmastodon.android.model.Account; import org.joinmastodon.android.model.Account;
@ -234,7 +235,7 @@ public abstract class BaseAccountListFragment extends BaseRecyclerFragment<BaseA
public void bindRelationship(){ public void bindRelationship(){
Relationship rel=relationships.get(item.account.id); Relationship rel=relationships.get(item.account.id);
if(rel==null){ if(rel==null || AccountSessionManager.getInstance().isSelf(accountID, item.account)){
button.setVisibility(View.GONE); button.setVisibility(View.GONE);
}else{ }else{
button.setVisibility(View.VISIBLE); button.setVisibility(View.VISIBLE);

View File

@ -117,6 +117,8 @@ public class SearchFragment extends BaseStatusListFragment<SearchResult>{
protected void doLoadData(int offset, int count){ protected void doLoadData(int offset, int count){
if(isInRecentMode()){ if(isInRecentMode()){
AccountSessionManager.getInstance().getAccount(accountID).getCacheController().getRecentSearches(sr->{ AccountSessionManager.getInstance().getAccount(accountID).getCacheController().getRecentSearches(sr->{
if(getActivity()==null)
return;
unfilteredResults=sr; unfilteredResults=sr;
prevDisplayItems=new ArrayList<>(displayItems); prevDisplayItems=new ArrayList<>(displayItems);
onDataLoaded(sr, false); onDataLoaded(sr, false);

View File

@ -2,6 +2,7 @@ package org.joinmastodon.android.ui.utils;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
@ -29,6 +30,7 @@ import android.webkit.MimeTypeMap;
import android.widget.Button; import android.widget.Button;
import android.widget.PopupMenu; import android.widget.PopupMenu;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import org.joinmastodon.android.E; import org.joinmastodon.android.E;
import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.GlobalUserPreferences;
@ -87,13 +89,17 @@ public class UiUtils{
private UiUtils(){} private UiUtils(){}
public static void launchWebBrowser(Context context, String url){ public static void launchWebBrowser(Context context, String url){
if(GlobalUserPreferences.useCustomTabs){ try{
new CustomTabsIntent.Builder() if(GlobalUserPreferences.useCustomTabs){
.setShowTitle(true) new CustomTabsIntent.Builder()
.build() .setShowTitle(true)
.launchUrl(context, Uri.parse(url)); .build()
}else{ .launchUrl(context, Uri.parse(url));
context.startActivity(new Intent(Intent.ACTION_VIEW, 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();
} }
} }