Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: move icons to profile appbar #321

Merged
merged 5 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ public View onCreateContentView(LayoutInflater inflater, ViewGroup container, Bu
noteEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
}else{
showFab();
savePrivateNote(noteEdit.getText().toString());
}
savePrivateNote(noteEdit.getText().toString());
});

FrameLayout sizeWrapper=new FrameLayout(getActivity()){
Expand Down Expand Up @@ -822,7 +822,7 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
if(isOwnProfile){
UiUtils.enableOptionsMenuIcons(getActivity(), menu, R.id.scheduled, R.id.bookmarks, R.id.favorites);
}else{
UiUtils.enableOptionsMenuIcons(getActivity(), menu, R.id.bookmarks, R.id.followed_hashtags, R.id.favorites, R.id.scheduled);
UiUtils.enableOptionsMenuIcons(getActivity(), menu, R.id.edit_note, R.id.share);
}
boolean hasMultipleAccounts = AccountSessionManager.getInstance().getLoggedInAccounts().size() > 1;
MenuItem openWithAccounts = menu.findItem(R.id.open_with_account);
Expand Down Expand Up @@ -865,6 +865,9 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
}else{
blockDomain.setVisible(false);
}
boolean canAddNote = noteWrap.getVisibility()==View.GONE && (relationship.note==null || relationship.note.isEmpty());
menu.findItem(R.id.edit_note).setTitle(canAddNote ? R.string.sk_add_note : R.string.sk_delete_note);
menu.findItem(R.id.edit_note).setIcon(canAddNote ? R.drawable.ic_fluent_person_note_24_regular : R.drawable.ic_fluent_person_delete_note_24_regular);
}

@Override
Expand Down Expand Up @@ -946,6 +949,26 @@ public void onError(ErrorResponse error){
}else if(id==R.id.save){
if(isInEditMode)
saveAndExitEditMode();
}else if(id==R.id.edit_note){
if(noteWrap.getVisibility()==View.GONE){
showPrivateNote();
UiUtils.beginLayoutTransition(scrollableContent);
noteEdit.requestFocus();
noteEdit.postDelayed(()->{
InputMethodManager imm=getActivity().getSystemService(InputMethodManager.class);
imm.showSoftInput(noteEdit, 0);
}, 100);
}else if(relationship.note.isEmpty()){
hidePrivateNote();
UiUtils.beginLayoutTransition(scrollableContent);
}else{
new M3AlertDialogBuilder(getActivity())
.setMessage(getContext().getString(R.string.sk_private_note_confirm_delete, account.getDisplayUsername()))
.setPositiveButton(R.string.delete, (dlg, btn)->savePrivateNote(null))
.setNegativeButton(R.string.cancel, null)
.show();
}
invalidateOptionsMenu();
}
return true;
}
Expand All @@ -971,7 +994,8 @@ public void onError(ErrorResponse error){

private void updateRelationship(){
if(getActivity()==null) return;
showPrivateNote();
if(relationship.note!=null && !relationship.note.isEmpty()) showPrivateNote();
else hidePrivateNote();
invalidateOptionsMenu();
actionButton.setVisibility(View.VISIBLE);
notifyButton.setVisibility(relationship.following ? View.VISIBLE : View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public boolean onLongClick(float x, float y){
Menu menu=contextMenu.getMenu();
Account account=item.account;

menu.findItem(R.id.edit_note).setVisible(false);
menu.findItem(R.id.manage_user_lists).setTitle(fragment.getString(R.string.sk_lists_with_user, account.getShortUsername()));
MenuItem mute=menu.findItem(R.id.mute);
mute.setTitle(fragment.getString(relationship.muting ? R.string.unmute_user : R.string.mute_user, account.getShortUsername()));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group>
<clip-path
android:pathData="M-2.996,-2.995L28,-2.995L28,28L-2.996,28ZM12.371,11.8c-0.449,-0.466 -1.157,0.217 -0.675,0.651l1.912,1.846c7.457,7.199 9.861,9.522 7.457,7.199l2.404,2.323c0.45,0.435 1.125,-0.217 0.675,-0.652z"/>
<path
android:pathData="m11,15c0,-0.351 0.06,-0.687 0.171,-1L4.253,14c-1.242,0 -2.249,1.007 -2.249,2.249v0.578c0,0.893 0.319,1.756 0.898,2.435 1.566,1.834 3.952,2.739 7.098,2.739 0.398,0 0.783,-0.014 1.156,-0.043 -0.101,-0.301 -0.156,-0.623 -0.156,-0.958v-0.535c-0.321,0.024 -0.655,0.036 -1,0.036 -2.738,0 -4.704,-0.746 -5.958,-2.214C3.695,17.881 3.504,17.362 3.504,16.827v-0.578c0,-0.414 0.335,-0.749 0.749,-0.749L11,15.5ZM10,2.005c2.761,0 5,2.239 5,5 0,2.761 -2.239,5 -5,5 -2.761,0 -5,-2.239 -5,-5 0,-2.761 2.239,-5 5,-5zM10,3.505c-1.933,0 -3.5,1.567 -3.5,3.5 0,1.933 1.567,3.5 3.5,3.5 1.933,0 3.5,-1.567 3.5,-3.5 0,-1.933 -1.567,-3.5 -3.5,-3.5zM12,15c0,-1.105 0.895,-2 2,-2h7c1.105,0 2,0.896 2,2v6c0,1.105 -0.895,2 -2,2h-7c-1.105,0 -2,-0.895 -2,-2zM14.5,16c-0.276,0 -0.5,0.224 -0.5,0.5 0,0.276 0.224,0.5 0.5,0.5h6c0.276,0 0.5,-0.224 0.5,-0.5 0,-0.276 -0.224,-0.5 -0.5,-0.5zM14.5,19c-0.276,0 -0.5,0.224 -0.5,0.5 0,0.276 0.224,0.5 0.5,0.5h6c0.276,0 0.5,-0.224 0.5,-0.5 0,-0.276 -0.224,-0.5 -0.5,-0.5z"
android:fillColor="@color/fluent_default_icon_tint"/>
</group>
<path
android:pathData="m11.568,12.296c-0.449,-0.466 -1.157,0.217 -0.675,0.651l1.912,1.846c7.457,7.199 9.861,9.522 7.457,7.199l2.404,2.323c0.45,0.435 1.125,-0.217 0.675,-0.652z"
android:strokeWidth="0.625337"
android:fillColor="@color/fluent_default_icon_tint"/>
</vector>
3 changes: 2 additions & 1 deletion mastodon/src/main/res/layout/fragment_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,13 @@
<EditText
android:id="@+id/note_edit"
android:layout_width="match_parent"
android:minHeight="52dp"
android:maxHeight="200dp"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:padding="16dp"
android:background="@null"
android:inputType="text|textMultiLine|textCapSentences"
android:maxHeight="200dp"
android:hint="@string/mo_personal_note"
tools:ignore="RtlSymmetry" />
</org.joinmastodon.android.ui.views.FloatingHintEditTextLayout>
Expand Down
7 changes: 5 additions & 2 deletions mastodon/src/main/res/menu/profile.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<group android:id="@+id/menu_group1">
<item android:id="@+id/edit_note" android:title="@string/sk_add_note" android:icon="@drawable/ic_fluent_person_note_24_regular" android:showAsAction="ifRoom" />
</group>
<group android:id="@+id/menu_group2">
<item android:id="@+id/manage_user_lists" android:title="@string/sk_lists_with_user" android:icon="@drawable/ic_fluent_people_24_regular"/>
<item android:id="@+id/mute" android:title="@string/mute_user" android:icon="@drawable/ic_fluent_speaker_off_24_regular"/>
<item android:id="@+id/hide_boosts" android:title="@string/hide_boosts_from_user" android:icon="@drawable/ic_fluent_arrow_repeat_all_off_24_regular"/>
Expand All @@ -9,9 +12,9 @@
<item android:id="@+id/report" android:title="@string/report_user" android:icon="@drawable/ic_fluent_warning_24_regular"/>
<item android:id="@+id/block_domain" android:title="@string/block_domain" android:icon="@drawable/ic_fluent_shield_prohibited_24_regular"/>
</group>
<group android:id="@+id/menu_group2">
<group android:id="@+id/menu_group3">
<item android:id="@+id/open_in_browser" android:title="@string/open_in_browser" android:icon="@drawable/ic_fluent_globe_24_regular"/>
<item android:id="@+id/share" android:title="@string/share_user" android:icon="@drawable/ic_fluent_share_24_regular"/>
<item android:id="@+id/share" android:title="@string/share_user" android:icon="@drawable/ic_fluent_share_24_regular" android:showAsAction="ifRoom"/>
<item android:id="@+id/open_with_account" android:title="@string/sk_open_with_account" android:visible="false" android:icon="@drawable/ic_fluent_person_swap_24_regular">
<menu android:id="@+id/accounts" />
</item>
Expand Down
2 changes: 1 addition & 1 deletion mastodon/src/main/res/menu/profile_own.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<item android:id="@+id/followed_hashtags" android:title="@string/sk_hashtags_you_follow" android:icon="@drawable/ic_fluent_number_symbol_24_regular"/>
<item android:id="@+id/bookmarks" android:title="@string/bookmarks" android:icon="@drawable/ic_fluent_bookmark_multiple_24_regular" android:showAsAction="always"/>
<item android:id="@+id/manage_user_lists" android:title="@string/sk_your_lists" android:icon="@drawable/ic_fluent_people_24_regular"/>
<item android:id="@+id/favorites" android:title="@string/your_favorites" android:icon="@drawable/ic_fluent_star_24_regular" android:showAsAction="always"/>
<item android:id="@+id/favorites" android:title="@string/your_favorites" android:icon="@drawable/ic_fluent_star_24_regular"/>
<item android:id="@+id/muted_accounts" android:title="@string/sk_muted_accounts" android:icon="@drawable/ic_fluent_speaker_off_24_regular"/>
<item android:id="@+id/blocked_accounts" android:title="@string/sk_blocked_accounts" android:icon="@drawable/ic_fluent_shield_24_regular"/>
<item android:id="@+id/scheduled" android:title="@string/sk_unsent_posts" android:icon="@drawable/ic_fluent_folder_open_24_regular" android:showAsAction="always"/>
Expand Down