Commit 7d7311f9 authored by Thomas's avatar Thomas
Browse files

manage extra features

parent 6dc01975
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -128,6 +128,8 @@ public class Status implements Serializable, Cloneable {
    public String translationContent;
    public boolean translationShown;
    public boolean mathsShown = false;
    public boolean markdownShown = false;
    public boolean extraFeaturesShown = false;
    public boolean canLoadMedia = false;
    public transient boolean isFocused = false;
    public transient boolean setCursorToEnd = false;
+56 −27
Original line number Diff line number Diff line
@@ -745,25 +745,24 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
                holder.binding.statusAddCustomEmoji.setVisibility(View.GONE);
                holder.binding.statusEmoji.setVisibility(View.GONE);
            }


        }

        if (status.isMaths == null) {
            if (status.content != null && Helper.mathsPattern.matcher(status.content).find()) {
                holder.binding.actionButtonMaths.setVisibility(View.VISIBLE);
                status.isMaths = true;
            } else {
                holder.binding.actionButtonMaths.setVisibility(View.GONE);
        if (statusToDeal.markdownShown) {
            if (statusToDeal.contentMarkdownSpan != null) {
                holder.binding.statusContent.setText(statusToDeal.contentMarkdownSpan, TextView.BufferType.SPANNABLE);
            }
        } else {
            if (status.isMaths) {
                holder.binding.actionButtonMaths.setVisibility(View.VISIBLE);
            } else {
                holder.binding.actionButtonMaths.setVisibility(View.GONE);
            if (statusToDeal.contentSpan != null) {
                holder.binding.statusContent.setText(statusToDeal.contentSpan, TextView.BufferType.SPANNABLE);
            }
        }
        if (statusToDeal.extraFeaturesShown) {
            holder.binding.extraFeaturesPanel.setVisibility(View.VISIBLE);
            holder.binding.extraFeaturesPanel.requestFocus();
        } else {
            holder.binding.extraFeaturesPanel.setVisibility(View.GONE);
        }
        if (status.mathsShown) {
        if (statusToDeal.mathsShown) {
            holder.binding.statusContentMaths.setVisibility(View.VISIBLE);
            holder.binding.statusContent.setVisibility(View.GONE);
            holder.binding.statusContentMaths.removeAllViews();
@@ -799,10 +798,13 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            holder.binding.statusContent.setVisibility(View.VISIBLE);
        }
        holder.binding.actionButtonMaths.setOnClickListener(v -> {

            status.mathsShown = !status.mathsShown;
            adapter.notifyItemChanged(holder.getBindingAdapterPosition());
        });
        holder.binding.actionButtonMarkdown.setOnClickListener(v -> {
            status.markdownShown = !status.markdownShown;
            adapter.notifyItemChanged(holder.getBindingAdapterPosition());
        });
        holder.binding.actionButtonFavorite.setActiveImage(R.drawable.ic_round_star_24);
        holder.binding.actionButtonFavorite.setInactiveImage(R.drawable.ic_round_star_border_24);
        holder.binding.actionButtonBookmark.setActiveImage(R.drawable.ic_round_bookmark_24);
@@ -909,15 +911,6 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            } else {
                holder.binding.actionButtonBookmark.setVisibility(View.GONE);
            }
            if (displayTranslate) {
                if (statusToDeal.language != null && statusToDeal.language.trim().length() > 0 && statusToDeal.language.equalsIgnoreCase(MyTransL.getLocale())) {
                    holder.binding.actionButtonTranslate.setVisibility(View.GONE);
                } else {
                    holder.binding.actionButtonTranslate.setVisibility(View.VISIBLE);
                }
            } else {
                holder.binding.actionButtonTranslate.setVisibility(View.GONE);
            }
            //--- ACTIONS ---
            holder.binding.actionButtonBookmark.setChecked(statusToDeal.bookmarked);
            //---> BOOKMARK/UNBOOKMARK
@@ -1042,11 +1035,42 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
            holder.binding.actionButtonExtra.setAnimation(null);

            holder.binding.actionButtonExtra.setOnClickListener(v -> {
                if (displayTranslate) {
                    if (statusToDeal.language != null && statusToDeal.language.trim().length() > 0 && statusToDeal.language.equalsIgnoreCase(MyTransL.getLocale())) {
                        holder.binding.actionButtonTranslate.setVisibility(View.GONE);
                    } else {
                        holder.binding.actionButtonTranslate.setVisibility(View.VISIBLE);
                    }
                } else {
                    holder.binding.actionButtonTranslate.setVisibility(View.GONE);
                }
                if (statusToDeal.isMaths == null) {
                    if (statusToDeal.content != null && Helper.mathsPattern.matcher(statusToDeal.content).find()) {
                        holder.binding.actionButtonMaths.setVisibility(View.VISIBLE);
                        statusToDeal.isMaths = true;
                    } else {
                        holder.binding.actionButtonMaths.setVisibility(View.GONE);
                    }
                } else {
                    if (statusToDeal.isMaths) {
                        holder.binding.actionButtonMaths.setVisibility(View.VISIBLE);
                    } else {
                        holder.binding.actionButtonMaths.setVisibility(View.GONE);
                    }
                }
                if (statusToDeal.contentMarkdownSpan != null) {
                    holder.binding.actionButtonMarkdown.setVisibility(View.VISIBLE);
                } else {
                    holder.binding.actionButtonMarkdown.setVisibility(View.GONE);
                }
                holder.binding.extraFeaturesPanel.setVisibility(View.VISIBLE);
                holder.binding.actionButtonExtra.setChecked(false);
            });

            holder.binding.buttonCloseExtraFeaturesPanel.setOnClickListener(v -> holder.binding.extraFeaturesPanel.setVisibility(View.GONE));
            holder.binding.buttonCloseExtraFeaturesPanel.setOnClickListener(v -> {
                statusToDeal.extraFeaturesShown = !statusToDeal.extraFeaturesShown;
                adapter.notifyItemChanged(holder.getBindingAdapterPosition());
            });

            holder.binding.actionButtonBoost.setOnClickListener(v -> {
                boolean needToWarnForMissingDescription = false;
@@ -2065,12 +2089,17 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
                                position++;
                            }
                        }
                    } else {
                        if (statusToDeal.extraFeaturesShown) {
                            statusToDeal.extraFeaturesShown = false;
                            adapter.notifyItemChanged(holder.getBindingAdapterPosition());
                        } else {
                            Intent intent = new Intent(context, ContextActivity.class);
                            intent.putExtra(Helper.ARG_STATUS, statusToDeal);
                            context.startActivity(intent);
                        }
                    }
                }
            });
        } else if (!canBeFederated) {
            holder.binding.mainContainer.setOnClickListener(v -> Helper.openBrowser(context, status.url));
+10 −0
Original line number Diff line number Diff line
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:tint="#FFFFFF"
    android:viewportWidth="24"
    android:viewportHeight="24">
    <path
        android:fillColor="@android:color/white"
        android:pathData="M9.4,16.6L4.8,12l4.6,-4.6L8,6l-6,6 6,6 1.4,-1.4zM14.6,16.6l4.6,-4.6 -4.6,-4.6L16,6l6,6 -6,6 -1.4,-1.4z" />
</vector>
+11 −2
Original line number Diff line number Diff line
@@ -763,8 +763,10 @@
                android:background="@drawable/bg_compose_panels"
                android:padding="6dp"
                android:visibility="gone"
                app:constraint_referenced_ids="button_close_extra_features_panel, action_button_quote, action_button_translate, action_button_maths, status_add_custom_emoji, status_emoji"
                app:flow_maxElementsWrap="3"
                app:constraint_referenced_ids="button_close_extra_features_panel, action_button_quote, action_button_translate, action_button_maths, status_add_custom_emoji, status_emoji, action_button_markdown"
                app:flow_horizontalGap="10dp"
                app:flow_horizontalStyle="spread_inside"
                app:flow_maxElementsWrap="10"
                app:flow_wrapMode="aligned"
                app:layout_constraintBottom_toBottomOf="@id/action_buttons"
                app:layout_constraintEnd_toEndOf="@id/action_button_extra" />
@@ -799,6 +801,13 @@
                android:layout_height="wrap_content"
                app:icon="@drawable/ic_baseline_functions_24" />

            <com.google.android.material.button.MaterialButton
                android:id="@+id/action_button_markdown"
                style="@style/Widget.Material3.Button.IconButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:icon="@drawable/baseline_code_24" />


            <com.google.android.material.button.MaterialButton
                android:id="@+id/status_add_custom_emoji"