mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-09-15 08:20:18 +03:00
Add popup menu for boost, quote actions in status
This commit is contained in:
parent
f3e8090c5a
commit
4301c60307
2 changed files with 111 additions and 80 deletions
|
@ -62,6 +62,7 @@ import android.text.SpannableString;
|
|||
import android.text.TextUtils;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -1113,6 +1114,13 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
return true;
|
||||
});
|
||||
holder.binding.actionButtonBoost.setOnClickListener(v -> {
|
||||
PopupMenu popupMenu = new PopupMenu(context, v);
|
||||
popupMenu.getMenuInflater().inflate(R.menu.menu_boost_or_quote, popupMenu.getMenu());
|
||||
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == R.id.action_reblog) {
|
||||
boolean needToWarnForMissingDescription = false;
|
||||
if (warnNoMedia && statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0) {
|
||||
for (Attachment attachment : statusToDeal.media_attachments) {
|
||||
|
@ -1186,6 +1194,23 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (itemId == R.id.action_quote) {
|
||||
Intent intent = new Intent(context, ComposeActivity.class);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_QUOTED_MESSAGE, statusToDeal);
|
||||
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||
intent.putExtras(bundle);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
popupMenu.show();
|
||||
});
|
||||
holder.binding.actionButtonBoost.setChecked(statusToDeal.reblogged);
|
||||
//---> FAVOURITE/UNFAVOURITE
|
||||
|
@ -2350,17 +2375,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
|||
CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REPLY_ACTION, null, statusToDeal);
|
||||
return true;
|
||||
});
|
||||
holder.binding.actionButtonQuote.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(context, ComposeActivity.class);
|
||||
Bundle args = new Bundle();
|
||||
args.putSerializable(Helper.ARG_QUOTED_MESSAGE, statusToDeal);
|
||||
new CachedBundle(context).insertBundle(args, Helper.getCurrentAccount(context), bundleId -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putLong(Helper.ARG_INTENT_ID, bundleId);
|
||||
intent.putExtras(bundle);
|
||||
context.startActivity(intent);
|
||||
});
|
||||
});
|
||||
holder.binding.actionButtonReplyContainer.setOnClickListener(v -> {
|
||||
if (remote) {
|
||||
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();
|
||||
|
|
17
app/src/main/res/menus/mastodon/menu/menu_boost_or_quote.xml
Normal file
17
app/src/main/res/menus/mastodon/menu/menu_boost_or_quote.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/action_reblog"
|
||||
android:icon="@drawable/ic_round_repeat_24"
|
||||
android:title="@string/action_reblog"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
<item
|
||||
android:id="@+id/action_quote"
|
||||
android:icon="@drawable/ic_baseline_format_quote_24"
|
||||
android:title="@string/action_quote"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
Loading…
Reference in a new issue