Browse Source

Fixes for settings, Add delete post

pull/27/head
Apostolos Fanakis 7 years ago
parent
commit
67ffb59c67
  1. 1
      app/src/main/AndroidManifest.xml
  2. 1
      app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java
  3. 5
      app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java
  4. 44
      app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java
  5. 54
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  6. 62
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  7. 24
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
  8. 8
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
  9. 20
      app/src/main/java/gr/thmmy/mthmmy/model/Post.java
  10. BIN
      app/src/main/res/drawable-hdpi/ic_more_vert.png
  11. BIN
      app/src/main/res/drawable-mdpi/ic_more_vert.png
  12. BIN
      app/src/main/res/drawable-xhdpi/ic_more_vert.png
  13. BIN
      app/src/main/res/drawable-xxhdpi/ic_more_vert.png
  14. BIN
      app/src/main/res/drawable-xxxhdpi/ic_more_vert.png
  15. 15
      app/src/main/res/layout-v21/activity_topic_post_row.xml
  16. 15
      app/src/main/res/layout/activity_topic_post_row.xml
  17. 19
      app/src/main/res/menu/post_menu.xml
  18. 1
      app/src/main/res/values-v21/styles.xml
  19. 7
      app/src/main/res/values/strings.xml
  20. 8
      app/src/main/res/values/styles.xml
  21. 5
      app/src/main/res/xml/app_preferences.xml

1
app/src/main/AndroidManifest.xml

@ -108,7 +108,6 @@
<activity <activity
android:name=".activities.settings.SettingsActivity" android:name=".activities.settings.SettingsActivity"
android:parentActivityName=".activities.main.MainActivity" android:parentActivityName=".activities.main.MainActivity"
android:launchMode="singleInstance"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"

1
app/src/main/java/gr/thmmy/mthmmy/activities/bookmarks/BookmarkActivity.java

@ -1,7 +1,6 @@
package gr.thmmy.mthmmy.activities.bookmarks; package gr.thmmy.mthmmy.activities.bookmarks;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.TabLayout; import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;

5
app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsActivity.java

@ -11,6 +11,8 @@ public class SettingsActivity extends BaseActivity {
public static final String NOTIFICATION_VIBRATION_KEY = "pref_notification_vibration_enable_key"; public static final String NOTIFICATION_VIBRATION_KEY = "pref_notification_vibration_enable_key";
public static final String APP_SIGNATURE_ENABLE_KEY = "pref_posting_app_signature_enable_key"; public static final String APP_SIGNATURE_ENABLE_KEY = "pref_posting_app_signature_enable_key";
private Fragment preferenceFragment;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -29,7 +31,7 @@ public class SettingsActivity extends BaseActivity {
drawer.setSelection(SETTINGS_ID); drawer.setSelection(SETTINGS_ID);
if (savedInstanceState == null) { if (savedInstanceState == null) {
Fragment preferenceFragment = new SettingsFragment(); preferenceFragment = SettingsFragment.newInstance(sessionManager.isLoggedIn());
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.pref_container, preferenceFragment); fragmentTransaction.add(R.id.pref_container, preferenceFragment);
fragmentTransaction.commit(); fragmentTransaction.commit();
@ -40,5 +42,6 @@ public class SettingsActivity extends BaseActivity {
protected void onResume() { protected void onResume() {
drawer.setSelection(SETTINGS_ID); drawer.setSelection(SETTINGS_ID);
super.onResume(); super.onResume();
((SettingsFragment) preferenceFragment).updateUserLoginState(sessionManager.isLoggedIn());
} }
} }

44
app/src/main/java/gr/thmmy/mthmmy/activities/settings/SettingsFragment.java

@ -8,27 +8,59 @@ import android.media.RingtoneManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.provider.Settings; import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.v7.preference.Preference; import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceFragmentCompat; import android.support.v7.preference.PreferenceFragmentCompat;
import android.util.Log; import android.view.View;
import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.R;
public class SettingsFragment extends PreferenceFragmentCompat { public class SettingsFragment extends PreferenceFragmentCompat {
public static final String ARG_IS_LOGGED_IN = "selectedRingtoneKey";
//Preferences xml keys
private static final String POSTING_CATEGORY = "pref_category_posting_key";
private static final String SELECTED_NOTIFICATIONS_SOUND = "pref_notifications_select_sound_key";
//SharedPreferences keys
private static final int REQUEST_CODE_ALERT_RINGTONE = 2; private static final int REQUEST_CODE_ALERT_RINGTONE = 2;
public static final String SETTINGS_SHARED_PREFS = "settingsSharedPrefs"; public static final String SETTINGS_SHARED_PREFS = "settingsSharedPrefs";
public static final String SELECTED_RINGTONE = "selectedRingtoneKey"; public static final String SELECTED_RINGTONE = "selectedRingtoneKey";
private static final String SELECTED_NOTIFICATIONS_SOUND = "pref_notifications_select_sound_key";
private static final String SILENT_SELECTED = "STFU"; private static final String SILENT_SELECTED = "STFU";
private SharedPreferences settingsFile; private SharedPreferences settingsFile;
private boolean isLoggedIn = false;
public static SettingsFragment newInstance(boolean isLoggedIn) {
SettingsFragment fragment = new SettingsFragment();
Bundle args = new Bundle();
args.putBoolean(ARG_IS_LOGGED_IN, isLoggedIn);
fragment.setArguments(args);
return fragment;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle args = getArguments();
if (args != null){
isLoggedIn = args.getBoolean(ARG_IS_LOGGED_IN,false);
}
}
@Override @Override
public void onCreatePreferences(Bundle bundle, String s) { public void onCreatePreferences(Bundle bundle, String rootKey) {
// Load the Preferences from the XML file // Load the Preferences from the XML file
addPreferencesFromResource(R.xml.app_preferences); addPreferencesFromResource(R.xml.app_preferences);
} }
@Override
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
findPreference(POSTING_CATEGORY).setVisible(isLoggedIn);
}
@Override @Override
public boolean onPreferenceTreeClick(Preference preference) { public boolean onPreferenceTreeClick(Preference preference) {
if (preference.getKey().equals(SELECTED_NOTIFICATIONS_SOUND)) { if (preference.getKey().equals(SELECTED_NOTIFICATIONS_SOUND)) {
@ -72,11 +104,15 @@ public class SettingsFragment extends PreferenceFragmentCompat {
if (ringtone != null) { if (ringtone != null) {
editor.putString(SELECTED_RINGTONE, ringtone.toString()).apply(); editor.putString(SELECTED_RINGTONE, ringtone.toString()).apply();
} else { } else {
// "Silent" was selected //"Silent" was selected
editor.putString(SELECTED_RINGTONE, SILENT_SELECTED).apply(); editor.putString(SELECTED_RINGTONE, SILENT_SELECTED).apply();
} }
} else { } else {
super.onActivityResult(requestCode, resultCode, data); super.onActivityResult(requestCode, resultCode, data);
} }
} }
public void updateUserLoginState(boolean isLoggedIn) {
this.isLoggedIn = isLoggedIn;
}
} }

54
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -675,6 +675,7 @@ public class TopicActivity extends BaseActivity {
} }
postsList.addAll(localPostsList); postsList.addAll(localPostsList);
topicAdapter.notifyItemRangeInserted(0, postsList.size()); topicAdapter.notifyItemRangeInserted(0, postsList.size());
topicAdapter.prepareForDelete(new DeleteTask());
progressBar.setVisibility(ProgressBar.INVISIBLE); progressBar.setVisibility(ProgressBar.INVISIBLE);
if (replyPageUrl == null) { if (replyPageUrl == null) {
@ -981,4 +982,57 @@ public class TopicActivity extends BaseActivity {
} }
} }
} }
class DeleteTask extends AsyncTask<String, Void, Boolean> {
@Override
protected void onPreExecute() {
progressBar.setVisibility(ProgressBar.VISIBLE);
paginationEnabled(false);
replyFAB.setEnabled(false);
}
@Override
protected Boolean doInBackground(String... args) {
Request delete = new Request.Builder()
.url(args[0])
.header("User-Agent",
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")
.build();
try {
client.newCall(delete).execute();
Response response = client.newCall(delete).execute();
//Response response = client.newCall(delete).execute();
switch (replyStatus(response)) {
case SUCCESSFUL:
return true;
default:
Timber.e("Something went wrong. Request string: %s", delete.toString());
return true;
}
} catch (IOException e) {
Timber.e(e, "Delete failed.");
return false;
}
}
@Override
protected void onPostExecute(Boolean result) {
progressBar.setVisibility(ProgressBar.GONE);
replyFAB.setVisibility(View.VISIBLE);
bottomNavBar.setVisibility(View.VISIBLE);
if (!result)
Toast.makeText(TopicActivity.this, "Post deleted!", Toast.LENGTH_SHORT).show();
paginationEnabled(true);
replyFAB.setEnabled(true);
if (result) {
topicTask = new TopicTask();
reloadingPage = true;
topicTask.execute(loadedPageUrl);
}
}
}
} }

62
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -11,12 +11,19 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.res.ResourcesCompat; import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.view.menu.MenuBuilder;
import android.support.v7.view.menu.MenuPopupHelper;
import android.support.v7.widget.AppCompatImageButton; import android.support.v7.widget.AppCompatImageButton;
import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
@ -87,6 +94,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int isQuoteButtonChecked = 1; private static final int isQuoteButtonChecked = 1;
private TopicActivity.TopicTask topicTask; private TopicActivity.TopicTask topicTask;
private TopicActivity.ReplyTask replyTask; private TopicActivity.ReplyTask replyTask;
private TopicActivity.DeleteTask deleteTask;
private final int VIEW_TYPE_POST = 0; private final int VIEW_TYPE_POST = 0;
private final int VIEW_TYPE_QUICK_REPLY = 1; private final int VIEW_TYPE_QUICK_REPLY = 1;
@ -113,7 +121,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
this.topicTask = topicTask; this.topicTask = topicTask;
} }
ArrayList<Integer> getToQuoteList(){ ArrayList<Integer> getToQuoteList() {
return toQuoteList; return toQuoteList;
} }
@ -128,6 +136,10 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
this.buildedQuotes = buildedQuotes; this.buildedQuotes = buildedQuotes;
} }
void prepareForDelete(TopicActivity.DeleteTask deleteTask) {
this.deleteTask = deleteTask;
}
@Override @Override
public int getItemViewType(int position) { public int getItemViewType(int position) {
return postsList.get(position) == null ? VIEW_TYPE_QUICK_REPLY : VIEW_TYPE_POST; return postsList.get(position) == null ? VIEW_TYPE_QUICK_REPLY : VIEW_TYPE_POST;
@ -409,13 +421,44 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.userExtraInfo.setOnClickListener(null); holder.userExtraInfo.setOnClickListener(null);
} }
holder.sharePostButton.setOnClickListener(new View.OnClickListener() { holder.overflowButton.setOnClickListener(new View.OnClickListener() {
@SuppressLint("RestrictedApi")
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); //Inflates menu
sendIntent.setType("text/plain"); PopupMenu popup = new PopupMenu(holder.overflowButton.getContext(), holder.overflowButton, Gravity.END);
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, currentPost.getPostURL()); MenuInflater inflater = popup.getMenuInflater();
context.startActivity(Intent.createChooser(sendIntent, "Share via")); inflater.inflate(R.menu.post_menu, popup.getMenu());
Menu popupMenu = popup.getMenu();
if(currentPost.getPostDeleteURL() == null || currentPost.getPostDeleteURL().equals("")){
popupMenu.findItem(R.id.delete_post).setEnabled(false);
popupMenu.findItem(R.id.delete_post).setVisible(false);
}
MenuPopupHelper optionsMenu = new MenuPopupHelper(holder.overflowButton.getContext()
, new MenuBuilder(holder.overflowButton.getContext()), holder.overflowButton);
optionsMenu.setForceShowIcon(true);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.post_share_button:
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(android.content.Intent.EXTRA_TEXT, currentPost.getPostURL());
context.startActivity(Intent.createChooser(sendIntent, "Share via"));
return true;
case R.id.delete_post:
deleteTask.execute(currentPost.getPostDeleteURL());
return true;
default:
}
return false;
}
});
popup.show();
} }
}); });
@ -482,8 +525,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.submitButton.setEnabled(true); holder.submitButton.setEnabled(true);
} }
}); });
if(backPressHidden) if (backPressHidden) {
{
holder.quickReply.requestFocus(); holder.quickReply.requestFocus();
backPressHidden = false; backPressHidden = false;
} }
@ -514,7 +556,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
final TextView postDate, postNum, username, subject; final TextView postDate, postNum, username, subject;
final ImageView thumbnail; final ImageView thumbnail;
final public WebView post; final public WebView post;
final ImageButton quoteToggle, sharePostButton; final ImageButton quoteToggle, overflowButton;
final RelativeLayout header; final RelativeLayout header;
final LinearLayout userExtraInfo; final LinearLayout userExtraInfo;
final View bodyFooterDivider; final View bodyFooterDivider;
@ -535,7 +577,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
post = view.findViewById(R.id.post); post = view.findViewById(R.id.post);
post.setBackgroundColor(Color.argb(1, 255, 255, 255)); post.setBackgroundColor(Color.argb(1, 255, 255, 255));
quoteToggle = view.findViewById(R.id.toggle_quote_button); quoteToggle = view.findViewById(R.id.toggle_quote_button);
sharePostButton = view.findViewById(R.id.post_share_button); overflowButton = view.findViewById(R.id.post_overflow_menu);
bodyFooterDivider = view.findViewById(R.id.body_footer_divider); bodyFooterDivider = view.findViewById(R.id.body_footer_divider);
postFooter = view.findViewById(R.id.post_footer); postFooter = view.findViewById(R.id.post_footer);

24
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java

@ -156,7 +156,8 @@ class TopicParser {
for (Element thisRow : postRows) { for (Element thisRow : postRows) {
//Variables for Post constructor //Variables for Post constructor
String p_userName, p_thumbnailURL, p_subject, p_post, p_postDate, p_profileURL, p_rank, String p_userName, p_thumbnailURL, p_subject, p_post, p_postDate, p_profileURL, p_rank,
p_specialRank, p_gender, p_personalText, p_numberOfPosts, p_postLastEditDate, p_postURL; p_specialRank, p_gender, p_personalText, p_numberOfPosts, p_postLastEditDate,
p_postURL, p_deletePostURL;
int p_postNum, p_postIndex, p_numberOfStars, p_userColor; int p_postNum, p_postIndex, p_numberOfStars, p_userColor;
boolean p_isDeleted = false; boolean p_isDeleted = false;
ArrayList<ThmmyFile> p_attachedFiles; ArrayList<ThmmyFile> p_attachedFiles;
@ -172,6 +173,7 @@ class TopicParser {
p_userColor = USER_COLOR_YELLOW; p_userColor = USER_COLOR_YELLOW;
p_attachedFiles = new ArrayList<>(); p_attachedFiles = new ArrayList<>();
p_postLastEditDate = null; p_postLastEditDate = null;
p_deletePostURL = null;
//Language independent parsing //Language independent parsing
//Finds thumbnail url //Finds thumbnail url
@ -232,6 +234,12 @@ class TopicParser {
p_profileURL = userName.attr("href"); p_profileURL = userName.attr("href");
} }
//Finds post delete url
Element postDelete = thisRow.select("a:has(img[alt='Διαγραφή'])").first();
if (postDelete!=null){
p_deletePostURL = postDelete.attr("href");
}
//Finds post's submit date //Finds post's submit date
Element postDate = thisRow.select("div.smalltext:matches(στις:)").first(); Element postDate = thisRow.select("div.smalltext:matches(στις:)").first();
p_postDate = postDate.text(); p_postDate = postDate.text();
@ -292,6 +300,12 @@ class TopicParser {
p_profileURL = userName.attr("href"); p_profileURL = userName.attr("href");
} }
//Finds post delete url
Element postDelete = thisRow.select("a:has(img[alt='Remove message'])").first();
if (postDelete!=null){
p_deletePostURL = postDelete.attr("href");
}
//Finds post's submit date //Finds post's submit date
Element postDate = thisRow.select("div.smalltext:matches(on:)").first(); Element postDate = thisRow.select("div.smalltext:matches(on:)").first();
p_postDate = postDate.text(); p_postDate = postDate.text();
@ -412,16 +426,18 @@ class TopicParser {
p_personalText = p_personalText.replace("\n", "").replace("\r", "").trim(); p_personalText = p_personalText.replace("\n", "").replace("\r", "").trim();
} }
} }
//Add new post in postsList, extended information needed //Add new post in postsList, extended information needed
parsedPostsList.add(new Post(p_thumbnailURL, p_userName, p_subject, p_post, p_postIndex parsedPostsList.add(new Post(p_thumbnailURL, p_userName, p_subject, p_post, p_postIndex
, p_postNum, p_postDate, p_profileURL, p_rank, p_specialRank, p_gender , p_postNum, p_postDate, p_profileURL, p_rank, p_specialRank, p_gender
, p_numberOfPosts, p_personalText, p_numberOfStars, p_userColor , p_numberOfPosts, p_personalText, p_numberOfStars, p_userColor
, p_attachedFiles, p_postLastEditDate, p_postURL)); , p_attachedFiles, p_postLastEditDate, p_postURL, p_deletePostURL));
} else { //Deleted user } else { //Deleted user
//Add new post in postsList, only standard information needed //Add new post in postsList, only standard information needed
parsedPostsList.add(new Post(p_thumbnailURL, p_userName, p_subject, p_post, p_postIndex parsedPostsList.add(new Post(p_thumbnailURL, p_userName, p_subject, p_post
, p_postNum, p_postDate, p_userColor, p_attachedFiles, p_postLastEditDate, p_postURL)); , p_postIndex , p_postNum, p_postDate, p_userColor, p_attachedFiles
, p_postLastEditDate, p_postURL, p_deletePostURL));
} }
} }
return parsedPostsList; return parsedPostsList;

8
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -42,8 +42,8 @@ import java.util.ArrayList;
import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.activities.AboutActivity; import gr.thmmy.mthmmy.activities.AboutActivity;
import gr.thmmy.mthmmy.activities.bookmarks.BookmarkActivity;
import gr.thmmy.mthmmy.activities.LoginActivity; import gr.thmmy.mthmmy.activities.LoginActivity;
import gr.thmmy.mthmmy.activities.bookmarks.BookmarkActivity;
import gr.thmmy.mthmmy.activities.downloads.DownloadsActivity; import gr.thmmy.mthmmy.activities.downloads.DownloadsActivity;
import gr.thmmy.mthmmy.activities.main.MainActivity; import gr.thmmy.mthmmy.activities.main.MainActivity;
import gr.thmmy.mthmmy.activities.profile.ProfileActivity; import gr.thmmy.mthmmy.activities.profile.ProfileActivity;
@ -370,7 +370,7 @@ public abstract class BaseActivity extends AppCompatActivity {
if (sessionManager.isLoggedIn()) if (sessionManager.isLoggedIn())
drawerBuilder.addDrawerItems(homeItem, bookmarksItem, downloadsItem, settingsItem, loginLogoutItem, aboutItem); drawerBuilder.addDrawerItems(homeItem, bookmarksItem, downloadsItem, settingsItem, loginLogoutItem, aboutItem);
else else
drawerBuilder.addDrawerItems(homeItem, bookmarksItem, loginLogoutItem, aboutItem); drawerBuilder.addDrawerItems(homeItem, bookmarksItem, settingsItem, loginLogoutItem, aboutItem);
drawer = drawerBuilder.build(); drawer = drawerBuilder.build();
@ -391,7 +391,6 @@ public abstract class BaseActivity extends AppCompatActivity {
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
{ {
drawer.removeItem(DOWNLOADS_ID); drawer.removeItem(DOWNLOADS_ID);
drawer.removeItem(SETTINGS_ID);
loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login loginLogoutItem.withName(R.string.login).withIcon(loginIcon); //Swap logout with login
profileDrawerItem.withName(sessionManager.getUsername()); profileDrawerItem.withName(sessionManager.getUsername());
setDefaultAvatar(); setDefaultAvatar();
@ -399,9 +398,6 @@ public abstract class BaseActivity extends AppCompatActivity {
if (!drawer.getDrawerItems().contains(downloadsItem)){ if (!drawer.getDrawerItems().contains(downloadsItem)){
drawer.addItemAtPosition(settingsItem, 2); drawer.addItemAtPosition(settingsItem, 2);
} }
if (!drawer.getDrawerItems().contains(settingsItem)){
drawer.addItemAtPosition(settingsItem, 3);
}
loginLogoutItem.withName(R.string.logout).withIcon(logoutIcon); //Swap login with logout loginLogoutItem.withName(R.string.logout).withIcon(logoutIcon); //Swap login with logout
profileDrawerItem.withName(sessionManager.getUsername()); profileDrawerItem.withName(sessionManager.getUsername());
if (sessionManager.hasAvatar()) if (sessionManager.hasAvatar())

20
app/src/main/java/gr/thmmy/mthmmy/model/Post.java

@ -29,6 +29,7 @@ public class Post {
private final ArrayList<ThmmyFile> attachedFiles; private final ArrayList<ThmmyFile> attachedFiles;
private final String lastEdit; private final String lastEdit;
private final String postURL; private final String postURL;
private final String postDeleteURL;
//Extra info //Extra info
private final String profileURL; private final String profileURL;
@ -61,6 +62,7 @@ public class Post {
attachedFiles = null; attachedFiles = null;
lastEdit = null; lastEdit = null;
postURL = null; postURL = null;
postDeleteURL = null;
} }
/** /**
@ -91,7 +93,8 @@ public class Post {
, int postIndex, int postNumber, String postDate, String profileURl, @Nullable String rank , int postIndex, int postNumber, String postDate, String profileURl, @Nullable String rank
, @Nullable String special_rank, @Nullable String gender, @Nullable String numberOfPosts , @Nullable String special_rank, @Nullable String gender, @Nullable String numberOfPosts
, @Nullable String personalText, int numberOfStars, int userColor , @Nullable String personalText, int numberOfStars, int userColor
, @Nullable ArrayList<ThmmyFile> attachedFiles, @Nullable String lastEdit, String postURL) { , @Nullable ArrayList<ThmmyFile> attachedFiles, @Nullable String lastEdit, String postURL
, @Nullable String postDeleteURL) {
if (Objects.equals(thumbnailUrl, "")) this.thumbnailUrl = null; if (Objects.equals(thumbnailUrl, "")) this.thumbnailUrl = null;
else this.thumbnailUrl = thumbnailUrl; else this.thumbnailUrl = thumbnailUrl;
this.author = author; this.author = author;
@ -112,6 +115,7 @@ public class Post {
this.personalText = personalText; this.personalText = personalText;
this.numberOfStars = numberOfStars; this.numberOfStars = numberOfStars;
this.postURL = postURL; this.postURL = postURL;
this.postDeleteURL = postDeleteURL;
} }
/** /**
@ -133,7 +137,8 @@ public class Post {
*/ */
public Post(@Nullable String thumbnailUrl, String author, String subject, String content public Post(@Nullable String thumbnailUrl, String author, String subject, String content
, int postIndex, int postNumber, String postDate, int userColor , int postIndex, int postNumber, String postDate, int userColor
, @Nullable ArrayList<ThmmyFile> attachedFiles, @Nullable String lastEdit, String postURL) { , @Nullable ArrayList<ThmmyFile> attachedFiles, @Nullable String lastEdit, String postURL
, @Nullable String postDeleteURL) {
if (Objects.equals(thumbnailUrl, "")) this.thumbnailUrl = null; if (Objects.equals(thumbnailUrl, "")) this.thumbnailUrl = null;
else this.thumbnailUrl = thumbnailUrl; else this.thumbnailUrl = thumbnailUrl;
this.author = author; this.author = author;
@ -154,6 +159,7 @@ public class Post {
personalText = ""; personalText = "";
numberOfStars = 0; numberOfStars = 0;
this.postURL = postURL; this.postURL = postURL;
this.postDeleteURL = postDeleteURL;
} }
//Getters //Getters
@ -342,4 +348,14 @@ public class Post {
public String getPostURL() { public String getPostURL() {
return postURL; return postURL;
} }
/**
* Gets this post's delete url.
*
* @return post's delete url
*/
@Nullable
public String getPostDeleteURL() {
return postDeleteURL;
}
} }

BIN
app/src/main/res/drawable-hdpi/ic_more_vert.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

BIN
app/src/main/res/drawable-mdpi/ic_more_vert.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

BIN
app/src/main/res/drawable-xhdpi/ic_more_vert.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

BIN
app/src/main/res/drawable-xxhdpi/ic_more_vert.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

BIN
app/src/main/res/drawable-xxxhdpi/ic_more_vert.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

15
app/src/main/res/layout-v21/activity_topic_post_row.xml

@ -95,7 +95,7 @@
android:contentDescription="@string/post_quote_button" android:contentDescription="@string/post_quote_button"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_format_quote_unchecked" /> android:src="@drawable/ic_format_quote_unchecked" />
<ImageButton <!--<ImageButton
android:id="@+id/post_share_button" android:id="@+id/post_share_button"
android:layout_width="@dimen/post_image_button" android:layout_width="@dimen/post_image_button"
android:layout_height="@dimen/post_image_button" android:layout_height="@dimen/post_image_button"
@ -105,7 +105,18 @@
android:clickable="true" android:clickable="true"
android:contentDescription="@string/post_share_button" android:contentDescription="@string/post_share_button"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_share" /> android:src="@drawable/ic_share" />-->
<ImageButton
android:id="@+id/post_overflow_menu"
android:layout_width="@dimen/post_image_button"
android:layout_height="@dimen/post_image_button"
android:layout_marginTop="9dp"
android:layout_marginEnd="9dp"
android:background="@color/card_background"
android:clickable="true"
android:contentDescription="@string/post_overflow_menu_button"
android:focusable="true"
android:src="@drawable/ic_more_vert" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

15
app/src/main/res/layout/activity_topic_post_row.xml

@ -94,7 +94,7 @@
android:contentDescription="@string/post_quote_button" android:contentDescription="@string/post_quote_button"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_format_quote_unchecked" /> android:src="@drawable/ic_format_quote_unchecked" />
<ImageButton <!--<ImageButton
android:id="@+id/post_share_button" android:id="@+id/post_share_button"
android:layout_width="@dimen/post_image_button" android:layout_width="@dimen/post_image_button"
android:layout_height="@dimen/post_image_button" android:layout_height="@dimen/post_image_button"
@ -104,7 +104,18 @@
android:clickable="true" android:clickable="true"
android:contentDescription="@string/post_share_button" android:contentDescription="@string/post_share_button"
android:focusable="true" android:focusable="true"
android:src="@drawable/ic_share" /> android:src="@drawable/ic_share" />-->
<ImageButton
android:id="@+id/post_overflow_menu"
android:layout_width="@dimen/post_image_button"
android:layout_height="@dimen/post_image_button"
android:layout_marginTop="9dp"
android:layout_marginEnd="9dp"
android:background="@color/card_background"
android:clickable="true"
android:contentDescription="@string/post_overflow_menu_button"
android:focusable="true"
android:src="@drawable/ic_more_vert" />
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

19
app/src/main/res/menu/post_menu.xml

@ -0,0 +1,19 @@
<?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"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".activities.topic.TopicActivity">
<item
android:id="@+id/post_share_button"
android:icon="@drawable/ic_share"
android:title="@string/post_share_button"
app:showAsAction="never" />
<item
android:id="@+id/delete_post"
android:icon="@drawable/ic_delete"
android:title="@string/post_delete_button"
app:showAsAction="never" />
</menu>

1
app/src/main/res/values-v21/styles.xml

@ -17,6 +17,7 @@
<item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item> <item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item>
<item name="android:windowContentTransitions">true</item> <item name="android:windowContentTransitions">true</item>
<item name="popupMenuStyle">@style/PopupMenuStyle</item>
</style> </style>
<style name="AppTheme.NoActionBar"> <style name="AppTheme.NoActionBar">

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

@ -38,7 +38,9 @@
<string name="post">Post</string> <string name="post">Post</string>
<string name="post_thumbnail">Thumbnail</string> <string name="post_thumbnail">Thumbnail</string>
<string name="post_quote_button">Quote button</string> <string name="post_quote_button">Quote button</string>
<string name="post_share_button">Share button</string> <string name="post_overflow_menu_button">Overflow menu button</string>
<string name="post_share_button">Share</string>
<string name="post_delete_button">Delete</string>
<string name="user_number_of_posts">#%1$d</string> <string name="user_number_of_posts">#%1$d</string>
<string name="button_first">first</string> <string name="button_first">first</string>
<string name="button_previous">previous</string> <string name="button_previous">previous</string>
@ -108,11 +110,10 @@
<!--<string name="pref_title_notifications_enable">New posts notification</string> <!--<string name="pref_title_notifications_enable">New posts notification</string>
<string name="pref_summary_notifications_enable">Toggle notifications state</string>--> <string name="pref_summary_notifications_enable">Toggle notifications state</string>-->
<string name="pref_title_notification_vibration_enable">Vibration</string> <string name="pref_title_notification_vibration_enable">Vibration</string>
<string name="pref_summary_notification_vibration_enable">Summary</string>
<string name="pref_title_notifications_sound">Notifications sound</string> <string name="pref_title_notifications_sound">Notifications sound</string>
<string name="pref_summary_notifications_sound">Select your preferred notification sound</string> <string name="pref_summary_notifications_sound">Select your preferred notification sound</string>
<string name="pref_category_posting">Posting</string> <string name="pref_category_posting">Posting</string>
<string name="pref_title_posting_app_signature_enable">App signature</string> <string name="pref_title_posting_app_signature_enable">App signature</string>
<string name="pref_summary_posting_app_signature_enable">If enabled, a \"Posted from mThmmy\" message will be inserted at the end of your posts</string> <string name="pref_summary_posting_app_signature_enable">If enabled, a \"sent from mTHMMY\" message will be inserted at the end of your posts</string>
</resources> </resources>

8
app/src/main/res/values/styles.xml

@ -18,6 +18,8 @@
<item name="colorButtonNormal">@color/primary</item> <item name="colorButtonNormal">@color/primary</item>
<item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item> <item name="alertDialogTheme">@style/AppCompatAlertDialogStyle</item>
<item name="popupMenuStyle">@style/PopupMenuStyle</item>
</style> </style>
<style name="AppTheme.NoActionBar"> <style name="AppTheme.NoActionBar">
@ -26,6 +28,12 @@
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item> <item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style> </style>
<style name="PopupMenuStyle">
<item name="android:popupBackground">@color/primary</item>
<item name="android:textAppearanceLargePopupMenu">@color/accent</item>
<item name="android:textAppearanceSmallPopupMenu">@color/accent</item>
</style>
<style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Light"> <style name="ToolbarTheme" parent="ThemeOverlay.AppCompat.Light">
<item name="android:textColorPrimary">@android:color/white</item> <item name="android:textColorPrimary">@android:color/white</item>
<item name="android:colorBackground">@color/colorPrimary</item> <item name="android:colorBackground">@color/colorPrimary</item>

5
app/src/main/res/xml/app_preferences.xml

@ -12,7 +12,6 @@
<android.support.v7.preference.SwitchPreferenceCompat <android.support.v7.preference.SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"
android:key="pref_notification_vibration_enable_key" android:key="pref_notification_vibration_enable_key"
android:summary="@string/pref_summary_notification_vibration_enable"
android:title="@string/pref_title_notification_vibration_enable" /> android:title="@string/pref_title_notification_vibration_enable" />
<Preference <Preference
@ -22,7 +21,9 @@
</android.support.v7.preference.PreferenceCategory> </android.support.v7.preference.PreferenceCategory>
<android.support.v7.preference.PreferenceCategory android:title="@string/pref_category_posting"> <android.support.v7.preference.PreferenceCategory
android:key="pref_category_posting_key"
android:title="@string/pref_category_posting">
<android.support.v7.preference.SwitchPreferenceCompat <android.support.v7.preference.SwitchPreferenceCompat
android:defaultValue="true" android:defaultValue="true"

Loading…
Cancel
Save