aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java1
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java75
-rw-r--r--app/src/main/res/menu/full_markdown_activity.xml10
6 files changed, 73 insertions, 33 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
index a7e675b2..6d9abd84 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/CommentActivity.java
@@ -348,6 +348,7 @@ public class CommentActivity extends BaseActivity implements UploadImageEnabledA
} else if (itemId == R.id.action_preview_comment_activity) {
Intent intent = new Intent(this, FullMarkdownActivity.class);
intent.putExtra(FullMarkdownActivity.EXTRA_COMMENT_MARKDOWN, commentEditText.getText().toString());
+ intent.putExtra(FullMarkdownActivity.EXTRA_SUBMIT_POST, true);
startActivity(intent);
} else if (itemId == R.id.action_send_comment_activity) {
if (!isSubmitting) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java
index 8ebb0015..3e69dd9a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditCommentActivity.java
@@ -206,6 +206,7 @@ public class EditCommentActivity extends BaseActivity implements UploadImageEnab
if (item.getItemId() == R.id.action_preview_edit_comment_activity) {
Intent intent = new Intent(this, FullMarkdownActivity.class);
intent.putExtra(FullMarkdownActivity.EXTRA_COMMENT_MARKDOWN, contentEditText.getText().toString());
+ intent.putExtra(FullMarkdownActivity.EXTRA_SUBMIT_POST, true);
startActivity(intent);
} else if (item.getItemId() == R.id.action_send_edit_comment_activity) {
if (!isSubmitting) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java
index 50574e15..e17e8753 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditPostActivity.java
@@ -218,6 +218,7 @@ public class EditPostActivity extends BaseActivity implements UploadImageEnabled
if (item.getItemId() == R.id.action_preview_edit_post_activity) {
Intent intent = new Intent(this, FullMarkdownActivity.class);
intent.putExtra(FullMarkdownActivity.EXTRA_COMMENT_MARKDOWN, contentEditText.getText().toString());
+ intent.putExtra(FullMarkdownActivity.EXTRA_SUBMIT_POST, true);
startActivity(intent);
} else if (item.getItemId() == R.id.action_send_edit_post_activity) {
if (!isSubmitting) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
index 312fe6cd..117adf81 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FullMarkdownActivity.java
@@ -1,5 +1,6 @@
package ml.docilealligator.infinityforreddit.activities;
+import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
@@ -11,6 +12,7 @@ import android.text.Spanned;
import android.text.TextPaint;
import android.text.style.ClickableSpan;
import android.text.util.Linkify;
+import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
@@ -58,6 +60,7 @@ public class FullMarkdownActivity extends BaseActivity {
public static final String EXTRA_COMMENT_MARKDOWN = "ECM";
public static final String EXTRA_IS_NSFW = "EIN";
+ public static final String EXTRA_SUBMIT_POST = "ESP";
@BindView(R.id.coordinator_layout_comment_full_markdown_activity)
CoordinatorLayout coordinatorLayout;
@@ -234,10 +237,25 @@ public class FullMarkdownActivity extends BaseActivity {
}
@Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ if (getIntent().getBooleanExtra(EXTRA_SUBMIT_POST, false)) {
+ getMenuInflater().inflate(R.menu.full_markdown_activity, menu);
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
return true;
+ } else if (item.getItemId() == R.id.action_send_full_markdown_activity) {
+ Intent returnIntent = new Intent();
+ setResult(Activity.RESULT_OK, returnIntent);
+ finish();
+ return true;
}
return false;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
index cf0758f7..78009c94 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java
@@ -91,6 +91,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0;
private static final int PICK_IMAGE_REQUEST_CODE = 100;
private static final int CAPTURE_IMAGE_REQUEST_CODE = 200;
+ private static final int MARKDOWN_PREVIEW_REQUEST_CODE = 300;
@BindView(R.id.coordinator_layout_post_text_activity)
CoordinatorLayout coordinatorLayout;
@@ -474,49 +475,55 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
} else if (itemId == R.id.action_preview_post_text_activity) {
Intent intent = new Intent(this, FullMarkdownActivity.class);
intent.putExtra(FullMarkdownActivity.EXTRA_COMMENT_MARKDOWN, contentEditText.getText().toString());
- startActivity(intent);
+ intent.putExtra(FullMarkdownActivity.EXTRA_SUBMIT_POST, true);
+ startActivityForResult(intent, MARKDOWN_PREVIEW_REQUEST_CODE);
} else if (itemId == R.id.action_send_post_text_activity) {
- if (!subredditSelected) {
- Snackbar.make(coordinatorLayout, R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show();
- return true;
- }
+ submitPost(item);
+ return true;
+ }
- if (titleEditText.getText() == null || titleEditText.getText().toString().equals("")) {
- Snackbar.make(coordinatorLayout, R.string.title_required, Snackbar.LENGTH_SHORT).show();
- return true;
- }
+ return false;
+ }
+
+ private void submitPost(MenuItem item) {
+ if (!subredditSelected) {
+ Snackbar.make(coordinatorLayout, R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show();
+ return;
+ }
+
+ if (titleEditText.getText() == null || titleEditText.getText().toString().equals("")) {
+ Snackbar.make(coordinatorLayout, R.string.title_required, Snackbar.LENGTH_SHORT).show();
+ return;
+ }
- isPosting = true;
+ isPosting = true;
+ if (item != null) {
item.setEnabled(false);
item.getIcon().setAlpha(130);
+ }
- mPostingSnackbar.show();
-
- String subredditName;
- if (subredditIsUser) {
- subredditName = "u_" + subredditNameTextView.getText().toString();
- } else {
- subredditName = subredditNameTextView.getText().toString();
- }
-
- Intent intent = new Intent(this, SubmitPostService.class);
- intent.putExtra(SubmitPostService.EXTRA_ACCESS_TOKEN, mAccessToken);
- intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
- intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
- intent.putExtra(SubmitPostService.EXTRA_CONTENT, contentEditText.getText().toString());
- intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_SELF);
- intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
- intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
- intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
- intent.putExtra(SubmitPostService.EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS, receivePostReplyNotificationsSwitchMaterial.isChecked());
- intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TEXT_OR_LINK);
- ContextCompat.startForegroundService(this, intent);
+ mPostingSnackbar.show();
- return true;
+ String subredditName;
+ if (subredditIsUser) {
+ subredditName = "u_" + subredditNameTextView.getText().toString();
+ } else {
+ subredditName = subredditNameTextView.getText().toString();
}
- return false;
+ Intent intent = new Intent(this, SubmitPostService.class);
+ intent.putExtra(SubmitPostService.EXTRA_ACCESS_TOKEN, mAccessToken);
+ intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
+ intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_CONTENT, contentEditText.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_SELF);
+ intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
+ intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
+ intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW);
+ intent.putExtra(SubmitPostService.EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS, receivePostReplyNotificationsSwitchMaterial.isChecked());
+ intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TEXT_OR_LINK);
+ ContextCompat.startForegroundService(this, intent);
}
@Override
@@ -577,6 +584,8 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
} else if (requestCode == CAPTURE_IMAGE_REQUEST_CODE) {
Utils.uploadImageToReddit(this, mExecutor, mOauthRetrofit, mUploadMediaRetrofit,
mAccessToken, contentEditText, coordinatorLayout, capturedImageUri, uploadedImages);
+ } else if (requestCode == MARKDOWN_PREVIEW_REQUEST_CODE) {
+ submitPost(mMenu.findItem(R.id.action_send_post_text_activity));
}
}
diff --git a/app/src/main/res/menu/full_markdown_activity.xml b/app/src/main/res/menu/full_markdown_activity.xml
new file mode 100644
index 00000000..ef700721
--- /dev/null
+++ b/app/src/main/res/menu/full_markdown_activity.xml
@@ -0,0 +1,10 @@
+<?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_send_full_markdown_activity"
+ android:orderInCategory="1"
+ android:title="@string/action_send"
+ android:icon="@drawable/ic_send_toolbar_24dp"
+ app:showAsAction="ifRoom" />
+</menu> \ No newline at end of file