Browse Source

PM overflow menu

pms
Thodoris1999 6 years ago
parent
commit
7549fe348c
  1. 56
      app/src/main/java/gr/thmmy/mthmmy/activities/inbox/InboxAdapter.java
  2. 49
      app/src/main/res/layout/activity_inbox_overflow_menu.xml
  3. 2
      app/src/main/res/values/strings.xml

56
app/src/main/java/gr/thmmy/mthmmy/activities/inbox/InboxAdapter.java

@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
@ -18,10 +19,14 @@ import android.webkit.WebViewClient;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.content.res.ResourcesCompat; import androidx.core.content.res.ResourcesCompat;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProviders;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
@ -34,11 +39,11 @@ import java.util.Objects;
import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.activities.board.BoardActivity; import gr.thmmy.mthmmy.activities.board.BoardActivity;
import gr.thmmy.mthmmy.activities.profile.ProfileActivity; import gr.thmmy.mthmmy.activities.profile.ProfileActivity;
import gr.thmmy.mthmmy.utils.MessageAnimations;
import gr.thmmy.mthmmy.activities.topic.TopicActivity; import gr.thmmy.mthmmy.activities.topic.TopicActivity;
import gr.thmmy.mthmmy.model.PM; import gr.thmmy.mthmmy.model.PM;
import gr.thmmy.mthmmy.model.ThmmyPage; import gr.thmmy.mthmmy.model.ThmmyPage;
import gr.thmmy.mthmmy.utils.CircleTransform; import gr.thmmy.mthmmy.utils.CircleTransform;
import gr.thmmy.mthmmy.utils.MessageAnimations;
import gr.thmmy.mthmmy.utils.parsing.ParseHelpers; import gr.thmmy.mthmmy.utils.parsing.ParseHelpers;
import gr.thmmy.mthmmy.viewmodel.InboxViewModel; import gr.thmmy.mthmmy.viewmodel.InboxViewModel;
@ -205,6 +210,55 @@ public class InboxAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
holder.subject, Color.parseColor("#FFFFFF"), holder.subject, Color.parseColor("#FFFFFF"),
Color.parseColor("#757575"), (LinearLayout) v); Color.parseColor("#757575"), (LinearLayout) v);
}); });
holder.overflowButton.setOnClickListener(view -> {
LayoutInflater layoutInflater = LayoutInflater.from(context);
View popupContent = layoutInflater.inflate(R.layout.activity_inbox_overflow_menu, null);
//Creates the PopupWindow
final PopupWindow popUp = new PopupWindow(holder.overflowButton.getContext());
popUp.setContentView(popupContent);
popUp.setWidth(LinearLayout.LayoutParams.WRAP_CONTENT);
popUp.setHeight(LinearLayout.LayoutParams.WRAP_CONTENT);
popUp.setFocusable(true);
TextView quoteButton = popupContent.findViewById(R.id.pm_quote_button);
Drawable quoteDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_format_quote);
quoteButton.setCompoundDrawablesRelativeWithIntrinsicBounds(quoteDrawable, null, null, null);
quoteButton.setOnClickListener(v -> {
Toast.makeText(context, "TODO", Toast.LENGTH_SHORT).show();
// TODO: Create quote PM task
});
final TextView replyButton = popupContent.findViewById(R.id.pm_reply_button);
Drawable replyDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_reply);
replyButton.setCompoundDrawablesRelativeWithIntrinsicBounds(replyDrawable, null, null, null);
replyButton.setOnClickListener(v -> {
Toast.makeText(context, "TODO", Toast.LENGTH_SHORT).show();
// TODO: Create reply PM task
});
TextView deletePostButton = popupContent.findViewById(R.id.delete_post);
Drawable deleteStartDrawable = AppCompatResources.getDrawable(context, R.drawable.ic_delete_white_24dp);
deletePostButton.setCompoundDrawablesRelativeWithIntrinsicBounds(deleteStartDrawable, null, null, null);
popupContent.findViewById(R.id.delete_post).setOnClickListener(v -> {
new AlertDialog.Builder(holder.overflowButton.getContext())
.setTitle("Delete personal message")
.setMessage("Do you really want to delete this personal message?")
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
Toast.makeText(context, "TODO", Toast.LENGTH_SHORT).show();
// TODO: Create delete PM task
})
.setNegativeButton(android.R.string.no, null).show();
popUp.dismiss();
});
//Displays the popup
popUp.showAsDropDown(holder.overflowButton);
});
} }
@Override @Override

49
app/src/main/res/layout/activity_inbox_overflow_menu.xml

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/pm_quote_button"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:background="?android:attr/selectableItemBackground"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:paddingBottom="6dp"
android:paddingEnd="12dp"
android:paddingStart="12dp"
android:paddingTop="6dp"
android:text="@string/quote_menu_button_text"
android:textColor="@color/primary_text" />
<TextView
android:id="@+id/pm_reply_button"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:background="?android:attr/selectableItemBackground"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:paddingBottom="6dp"
android:paddingEnd="12dp"
android:paddingStart="12dp"
android:paddingTop="6dp"
android:text="@string/reply_menu_button_text"
android:textColor="@color/primary_text" />
<TextView
android:id="@+id/delete_post"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:background="?android:attr/selectableItemBackground"
android:drawablePadding="5dp"
android:gravity="center_vertical"
android:paddingBottom="6dp"
android:paddingEnd="12dp"
android:paddingStart="12dp"
android:paddingTop="6dp"
android:text="@string/post_delete_button"
android:textColor="@color/primary_text" />
</LinearLayout>

2
app/src/main/res/values/strings.xml

@ -215,4 +215,6 @@
<string name="pm_author">PM author</string> <string name="pm_author">PM author</string>
<string name="pm_subject">PM subject</string> <string name="pm_subject">PM subject</string>
<string name="pm_content">PM content</string> <string name="pm_content">PM content</string>
<string name="quote_menu_button_text">Quote</string>
<string name="reply_menu_button_text">Reply</string>
</resources> </resources>

Loading…
Cancel
Save