This commit is contained in:
LucasGGamerM 2023-01-02 11:46:15 -03:00
parent 2969a3e4fd
commit ac3875fe08
4 changed files with 27 additions and 28 deletions

View File

@ -61,7 +61,7 @@ import me.grishka.appkit.api.ErrorResponse;
public class AccountSessionManager{ public class AccountSessionManager{
private static final String TAG="AccountSessionManager"; private static final String TAG="AccountSessionManager";
public static final String SCOPE="read write follow push"; public static final String SCOPE="read write follow push";
public static final String REDIRECT_URI="moshidon-android-auth://callback"; public static final String REDIRECT_URI="megalodon-android-auth://callback";
private static final AccountSessionManager instance=new AccountSessionManager(); private static final AccountSessionManager instance=new AccountSessionManager();
@ -211,7 +211,7 @@ public class AccountSessionManager{
.path("/oauth/authorize") .path("/oauth/authorize")
.appendQueryParameter("response_type", "code") .appendQueryParameter("response_type", "code")
.appendQueryParameter("client_id", result.clientId) .appendQueryParameter("client_id", result.clientId)
.appendQueryParameter("redirect_uri", "moshidon-android-auth://callback") .appendQueryParameter("redirect_uri", "megalodon-android-auth://callback")
.appendQueryParameter("scope", SCOPE) .appendQueryParameter("scope", SCOPE)
.build(); .build();

View File

@ -1,11 +1,16 @@
package org.joinmastodon.android.fragments; package org.joinmastodon.android.fragments;
import static android.content.Context.CLIPBOARD_SERVICE;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet; import android.animation.AnimatorSet;
import android.animation.ObjectAnimator; import android.animation.ObjectAnimator;
import android.app.Activity; import android.app.Activity;
import android.app.Fragment; import android.app.Fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.Outline; import android.graphics.Outline;
@ -14,10 +19,11 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.style.ImageSpan; import android.text.style.ImageSpan;
import android.util.Log;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -32,6 +38,7 @@ import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
@ -97,7 +104,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
private static final int COVER_RESULT=343; private static final int COVER_RESULT=343;
private ImageView avatar; private ImageView avatar;
private Button botIcon;
private CoverImageView cover; private CoverImageView cover;
private View avatarBorder; private View avatarBorder;
private TextView name, username, bio, followersCount, followersLabel, followingCount, followingLabel, postsCount, postsLabel; private TextView name, username, bio, followersCount, followersLabel, followingCount, followingLabel, postsCount, postsLabel;
@ -132,7 +138,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
private WindowInsets childInsets; private WindowInsets childInsets;
private PhotoViewer currentPhotoViewer; private PhotoViewer currentPhotoViewer;
private boolean editModeLoading; private boolean editModeLoading;
private String prefilledText;
public ProfileFragment(){ public ProfileFragment(){
super(R.layout.loader_fragment_overlay_toolbar); super(R.layout.loader_fragment_overlay_toolbar);
@ -157,8 +162,11 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
if(!getArguments().getBoolean("noAutoLoad", false)) if(!getArguments().getBoolean("noAutoLoad", false))
loadData(); loadData();
} }
}
prefilledText = AccountSessionManager.getInstance().isSelf(accountID, account) ? null : '@'+account.acct+' '; private String getPrefilledText() {
return account == null || AccountSessionManager.getInstance().isSelf(accountID, account)
? null : '@'+account.acct+' ';
} }
@Override @Override
@ -174,11 +182,6 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
avatar=content.findViewById(R.id.avatar); avatar=content.findViewById(R.id.avatar);
cover=content.findViewById(R.id.cover); cover=content.findViewById(R.id.cover);
avatarBorder=content.findViewById(R.id.avatar_border); avatarBorder=content.findViewById(R.id.avatar_border);
botIcon=content.findViewById(R.id.bot_icon);
botIcon.setOnClickListener(v ->{
Toast.makeText(getActivity(), R.string.sk_bot_account,
Toast.LENGTH_LONG).show();
});
name=content.findViewById(R.id.name); name=content.findViewById(R.id.name);
username=content.findViewById(R.id.username); username=content.findViewById(R.id.username);
bio=content.findViewById(R.id.bio); bio=content.findViewById(R.id.bio);
@ -271,15 +274,13 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
} }
}); });
botIcon.setVisibility(account.bot ? View.VISIBLE : View.GONE);
actionButton.setOnClickListener(this::onActionButtonClick); actionButton.setOnClickListener(this::onActionButtonClick);
notifyButton.setOnClickListener(this::onNotifyButtonClick); notifyButton.setOnClickListener(this::onNotifyButtonClick);
avatar.setOnClickListener(this::onAvatarClick); avatar.setOnClickListener(this::onAvatarClick);
cover.setOnClickListener(this::onCoverClick); cover.setOnClickListener(this::onCoverClick);
refreshLayout.setOnRefreshListener(this); refreshLayout.setOnRefreshListener(this);
fab.setOnClickListener(this::onFabClick); fab.setOnClickListener(this::onFabClick);
fab.setOnLongClickListener(v->UiUtils.pickAccountForCompose(getActivity(), accountID, prefilledText)); fab.setOnLongClickListener(v->UiUtils.pickAccountForCompose(getActivity(), accountID, getPrefilledText()));
if(loaded){ if(loaded){
bindHeaderView(); bindHeaderView();
@ -554,25 +555,25 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
if(relationship==null && !isOwnProfile) if(relationship==null && !isOwnProfile)
return; return;
inflater.inflate(isOwnProfile ? R.menu.profile_own : R.menu.profile, menu); inflater.inflate(isOwnProfile ? R.menu.profile_own : R.menu.profile, menu);
// UiUtils.enableOptionsMenuIcons(getActivity(), menu, R.id.bookmarks, R.id.followed_hashtags); UiUtils.enableOptionsMenuIcons(getActivity(), menu, R.id.bookmarks, R.id.followed_hashtags);
menu.findItem(R.id.share).setTitle(getString(R.string.share_user, account.getDisplayUsername())); menu.findItem(R.id.share).setTitle(getString(R.string.share_user, account.getShortUsername()));
if(isOwnProfile) if(isOwnProfile)
return; return;
MenuItem mute = menu.findItem(R.id.mute); MenuItem mute = menu.findItem(R.id.mute);
mute.setTitle(getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getDisplayUsername())); mute.setTitle(getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getShortUsername()));
mute.setIcon(relationship.muting ? R.drawable.ic_fluent_speaker_2_24_regular : R.drawable.ic_fluent_speaker_mute_24_regular); mute.setIcon(relationship.muting ? R.drawable.ic_fluent_speaker_0_24_regular : R.drawable.ic_fluent_speaker_off_24_regular);
UiUtils.insetPopupMenuIcon(getContext(), mute); UiUtils.insetPopupMenuIcon(getContext(), mute);
menu.findItem(R.id.block).setTitle(getString(relationship.blocking ? R.string.unblock_user : R.string.block_user, account.getDisplayUsername())); menu.findItem(R.id.block).setTitle(getString(relationship.blocking ? R.string.unblock_user : R.string.block_user, account.getShortUsername()));
menu.findItem(R.id.report).setTitle(getString(R.string.report_user, account.getDisplayUsername())); menu.findItem(R.id.report).setTitle(getString(R.string.report_user, account.getShortUsername()));
MenuItem manageUserLists=menu.findItem(R.id.manage_user_lists); MenuItem manageUserLists=menu.findItem(R.id.manage_user_lists);
if(relationship.following) { if(relationship.following) {
MenuItem hideBoosts = menu.findItem(R.id.hide_boosts); MenuItem hideBoosts = menu.findItem(R.id.hide_boosts);
hideBoosts.setTitle(getString(relationship.showingReblogs ? R.string.hide_boosts_from_user : R.string.show_boosts_from_user, account.getDisplayUsername())); hideBoosts.setTitle(getString(relationship.showingReblogs ? R.string.hide_boosts_from_user : R.string.show_boosts_from_user, account.getShortUsername()));
hideBoosts.setIcon(relationship.showingReblogs ? R.drawable.ic_fluent_arrow_repeat_all_off_24_regular : R.drawable.ic_fluent_arrow_repeat_all_24_regular); hideBoosts.setIcon(relationship.showingReblogs ? R.drawable.ic_fluent_arrow_repeat_all_off_24_regular : R.drawable.ic_fluent_arrow_repeat_all_24_regular);
UiUtils.insetPopupMenuIcon(getContext(), hideBoosts); UiUtils.insetPopupMenuIcon(getContext(), hideBoosts);
manageUserLists.setTitle(getString(R.string.sk_lists_with_user, account.getDisplayUsername())); manageUserLists.setTitle(getString(R.string.sk_lists_with_user, account.getShortUsername()));
manageUserLists.setVisible(true); manageUserLists.setVisible(true);
}else { }else {
menu.findItem(R.id.hide_boosts).setVisible(false); menu.findItem(R.id.hide_boosts).setVisible(false);
@ -956,7 +957,7 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
private void onFabClick(View v){ private void onFabClick(View v){
Bundle args=new Bundle(); Bundle args=new Bundle();
args.putString("account", accountID); args.putString("account", accountID);
if(prefilledText != null) args.putString("prefilledText", prefilledText); if(getPrefilledText() != null) args.putString("prefilledText", getPrefilledText());
Nav.go(getActivity(), ComposeFragment.class, args); Nav.go(getActivity(), ComposeFragment.class, args);
} }

View File

@ -45,7 +45,6 @@ public class LinkSpan extends CharacterStyle {
UiUtils.copyText(view, getType() == Type.URL ? link : text); UiUtils.copyText(view, getType() == Type.URL ? link : text);
} }
public String getLink(){ public String getLink(){
return link; return link;
} }

View File

@ -233,7 +233,7 @@
<LinearLayout <LinearLayout
android:id="@id/name_wrap" android:id="@id/name_wrap"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/avatar_border" android:layout_below="@id/avatar_border"
android:layout_alignParentStart="true" android:layout_alignParentStart="true"
@ -242,7 +242,7 @@
<TextView <TextView
android:id="@+id/name" android:id="@+id/name"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="17dp" android:layout_marginTop="17dp"
@ -251,7 +251,6 @@
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textAppearance="@style/m3_headline_small" android:textAppearance="@style/m3_headline_small"
tools:text="Eugen" /> tools:text="Eugen" />
<Button <Button
android:id="@+id/bot_icon" android:id="@+id/bot_icon"
android:layout_width="wrap_content" android:layout_width="wrap_content"