mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 20:57:25 +01:00
Directly submit post in FullMarkdownActivity.
This commit is contained in:
parent
7803b376b2
commit
8b0aed58b2
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
@ -233,11 +236,26 @@ public class FullMarkdownActivity extends BaseActivity {
|
||||
markwonAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@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;
|
||||
|
@ -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,22 +475,33 @@ 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) {
|
||||
submitPost(item);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void submitPost(MenuItem item) {
|
||||
if (!subredditSelected) {
|
||||
Snackbar.make(coordinatorLayout, R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (titleEditText.getText() == null || titleEditText.getText().toString().equals("")) {
|
||||
Snackbar.make(coordinatorLayout, R.string.title_required, Snackbar.LENGTH_SHORT).show();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
isPosting = true;
|
||||
|
||||
if (item != null) {
|
||||
item.setEnabled(false);
|
||||
item.getIcon().setAlpha(130);
|
||||
}
|
||||
|
||||
mPostingSnackbar.show();
|
||||
|
||||
@ -512,11 +524,6 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
||||
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);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@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));
|
||||
}
|
||||
}
|
||||
|
||||
|
10
app/src/main/res/menu/full_markdown_activity.xml
Normal file
10
app/src/main/res/menu/full_markdown_activity.xml
Normal file
@ -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>
|
Loading…
Reference in New Issue
Block a user