Add popup menu for boost, quote actions in status

This commit is contained in:
0xd9a 2025-08-24 01:27:58 +05:30
parent f3e8090c5a
commit 4301c60307
2 changed files with 111 additions and 80 deletions

View file

@ -62,6 +62,7 @@ import android.text.SpannableString;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -1113,6 +1114,13 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
return true; return true;
}); });
holder.binding.actionButtonBoost.setOnClickListener(v -> { 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; boolean needToWarnForMissingDescription = false;
if (warnNoMedia && statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0) { if (warnNoMedia && statusToDeal.media_attachments != null && statusToDeal.media_attachments.size() > 0) {
for (Attachment attachment : statusToDeal.media_attachments) { 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); holder.binding.actionButtonBoost.setChecked(statusToDeal.reblogged);
//---> FAVOURITE/UNFAVOURITE //---> FAVOURITE/UNFAVOURITE
@ -2350,17 +2375,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REPLY_ACTION, null, statusToDeal); CrossActionHelper.doCrossAction(context, CrossActionHelper.TypeOfCrossAction.REPLY_ACTION, null, statusToDeal);
return true; 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 -> { holder.binding.actionButtonReplyContainer.setOnClickListener(v -> {
if (remote) { if (remote) {
Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show(); Toasty.info(context, context.getString(R.string.retrieve_remote_status), Toasty.LENGTH_SHORT).show();

View 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>