This commit is contained in:
Grishka 2024-02-23 20:00:35 +03:00
parent 51f87848f4
commit eacfd2fa4f
4 changed files with 44 additions and 16 deletions

View File

@ -18,8 +18,11 @@ import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.SpannedString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.ImageSpan;
import android.transition.ChangeBounds;
import android.transition.Fade;
@ -596,6 +599,13 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
}
}
private CharSequence makeRedString(CharSequence s){
int color=UiUtils.getThemeColor(getActivity(), R.attr.colorM3Error);
SpannableString ss=new SpannableString(s);
ss.setSpan(new ForegroundColorSpan(color), 0, ss.length(), 0);
return ss;
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
if(isOwnProfile && isInEditMode){
@ -612,18 +622,22 @@ public class ProfileFragment extends LoaderFragment implements OnBackPressedList
if(isOwnProfile)
return;
menu.findItem(R.id.mute).setTitle(getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.displayName));
menu.findItem(R.id.block).setTitle(getString(relationship.blocking ? R.string.unblock_user : R.string.block_user, account.displayName));
menu.findItem(R.id.report).setTitle(getString(R.string.report_user, account.displayName));
menu.findItem(R.id.mute).setTitle(getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getDisplayUsername()));
menu.findItem(R.id.block).setTitle(makeRedString(getString(relationship.blocking ? R.string.unblock_user : R.string.block_user, account.getDisplayUsername())));
menu.findItem(R.id.report).setTitle(makeRedString(getString(R.string.report_user, account.getDisplayUsername())));
if(relationship.following)
menu.findItem(R.id.hide_boosts).setTitle(getString(relationship.showingReblogs ? R.string.hide_boosts_from_user : R.string.show_boosts_from_user, account.displayName));
menu.findItem(R.id.hide_boosts).setTitle(getString(relationship.showingReblogs ? R.string.hide_boosts_from_user : R.string.show_boosts_from_user));
else
menu.findItem(R.id.hide_boosts).setVisible(false);
if(!account.isLocal())
menu.findItem(R.id.block_domain).setTitle(getString(relationship.domainBlocking ? R.string.unblock_domain : R.string.block_domain, account.getDomain()));
menu.findItem(R.id.block_domain).setTitle(makeRedString(getString(relationship.domainBlocking ? R.string.unblock_domain : R.string.block_domain, account.getDomain())));
else
menu.findItem(R.id.block_domain).setVisible(false);
menu.findItem(R.id.add_to_list).setVisible(relationship.following);
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.P){
menu.setGroupDividerEnabled(true);
}
}
@Override

View File

@ -1,13 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:orderInCategory="1">
<group android:orderInCategory="1" android:id="@+id/menu_group1">
<item android:id="@+id/share" android:title="@string/share_user"/>
<item android:id="@+id/add_to_list" android:title="@string/add_user_to_list"/>
<item android:id="@+id/mute" android:title="@string/mute_user"/>
<item android:id="@+id/block" android:title="@string/block_user"/>
<item android:id="@+id/report" android:title="@string/report_user"/>
<item android:id="@+id/block_domain" android:title="@string/block_domain"/>
<item android:id="@+id/hide_boosts" android:title="@string/hide_boosts_from_user"/>
<item android:id="@+id/copy_link" android:title="@string/copy_profile_link"/>
<item android:id="@+id/open_in_browser" android:title="@string/open_in_browser"/>
</group>
<group android:orderInCategory="2" android:id="@+id/menu_group2">
<item android:id="@+id/add_to_list" android:title="@string/add_user_to_list"/>
</group>
<group android:orderInCategory="3" android:id="@+id/menu_group3">
<item android:id="@+id/hide_boosts" android:title="@string/hide_boosts_from_user"/>
<item android:id="@+id/mute" android:title="@string/mute_user"/>
</group>
<group android:orderInCategory="4" android:id="@+id/menu_group4">
<item android:id="@+id/block" android:title="@string/block_user"/>
<item android:id="@+id/block_domain" android:title="@string/block_domain"/>
<item android:id="@+id/report" android:title="@string/report_user"/>
</group>
</menu>

View File

@ -42,7 +42,7 @@
<string name="button_follow">Follow</string>
<string name="button_following">Following</string>
<string name="edit_profile">Edit profile</string>
<string name="share_user">Share profile</string>
<string name="share_user">Share profile via…</string>
<string name="mute_user">Mute %s</string>
<string name="unmute_user">Unmute %s</string>
<string name="block_user">Block %s</string>
@ -223,8 +223,8 @@
<string name="followed_user">Youre now following %s</string>
<string name="following_user_requested">Requested to follow %s</string>
<string name="open_in_browser">Open in browser</string>
<string name="hide_boosts_from_user">Hide boosts from %s</string>
<string name="show_boosts_from_user">Show boosts from %s</string>
<string name="hide_boosts_from_user">Hide boosts</string>
<string name="show_boosts_from_user">Show boosts</string>
<string name="signup_reason">Why do you want to join?</string>
<string name="signup_reason_note">This will help us review your application.</string>
<string name="clear">Clear</string>
@ -604,7 +604,7 @@
<string name="remove">Remove</string>
<string name="add_list_member">Add member</string>
<string name="search_among_people_you_follow">Search among people you follow</string>
<string name="add_user_to_list">Add to list</string>
<string name="add_user_to_list">Add/remove from lists</string>
<string name="add_user_to_list_title">Add to list</string>
<!-- %s is a username -->
<string name="manage_user_lists">Manage the lists %s appears on</string>
@ -709,4 +709,5 @@
<string name="view_file">View</string>
<string name="share_sheet_preview_profile">%s on Mastodon</string>
<string name="share_sheet_preview_post">%1$s on Mastodon: “%2$s”</string>
<string name="copy_profile_link">Copy link to profile</string>
</resources>

View File

@ -68,6 +68,7 @@
<item name="colorSensitiveOverlay">#a6ffffff</item>
<item name="android:textColorPrimary">?colorM3OnSurface</item>
<item name="android:textColorSecondary">?colorM3OnSurfaceVariant</item>
<item name="android:textAppearanceLargePopupMenu">@style/popup_menu_item_text</item>
</style>
<style name="Theme.Mastodon.Dark" parent="Theme.AppKit">
@ -137,6 +138,7 @@
<item name="colorSensitiveOverlay">#80000000</item>
<item name="android:textColorPrimary">?colorM3OnSurface</item>
<item name="android:textColorSecondary">?colorM3OnSurfaceVariant</item>
<item name="android:textAppearanceLargePopupMenu">@style/popup_menu_item_text</item>
</style>
<style name="Theme.Mastodon.Dark.SplashFragment">
@ -446,4 +448,8 @@
<style name="empty_text" parent="m3_body_large">
<item name="android:textColor">?colorM3OnSurfaceVariant</item>
</style>
<style name="popup_menu_item_text" parent="m3_body_large">
<item name="android:textColor">?colorM3OnSurface</item>
</style>
</resources>