Commit 4301c603 authored by 0xd9a's avatar 0xd9a
Browse files

Add popup menu for boost, quote actions in status

parent f3e8090c
Loading
Loading
Loading
Loading
+90 −76
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
<?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>