aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-03-15 02:41:21 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-03-15 02:41:21 +0000
commitda6191f60f08aaa3f1801f24ddff05d78bdc718e (patch)
treeaea182e84f3d1d6221538721a872226182c0a237 /app
parent70672fdc401b4425b1be172bbfd84ee35ef02a94 (diff)
downloadinfinity-for-reddit-da6191f60f08aaa3f1801f24ddff05d78bdc718e.tar
infinity-for-reddit-da6191f60f08aaa3f1801f24ddff05d78bdc718e.tar.gz
infinity-for-reddit-da6191f60f08aaa3f1801f24ddff05d78bdc718e.tar.bz2
infinity-for-reddit-da6191f60f08aaa3f1801f24ddff05d78bdc718e.tar.lz
infinity-for-reddit-da6191f60f08aaa3f1801f24ddff05d78bdc718e.tar.xz
infinity-for-reddit-da6191f60f08aaa3f1801f24ddff05d78bdc718e.tar.zst
infinity-for-reddit-da6191f60f08aaa3f1801f24ddff05d78bdc718e.zip
Submit video posts with text content (without embedded images).
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java46
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java325
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/post/SubmitPost.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java13
-rw-r--r--app/src/main/res/layout/activity_post_video.xml441
7 files changed, 425 insertions, 420 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
index 27467802..68051528 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java
@@ -560,7 +560,9 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
if (isPosting) {
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail);
} else {
- if (!binding.postTitleEditTextPostImageActivity.getText().toString().isEmpty() || imageUri != null) {
+ if (!binding.postTitleEditTextPostImageActivity.getText().toString().isEmpty()
+ || !binding.postContentEditTextPostImageActivity.getText().toString().isEmpty()
+ || imageUri != null) {
promptAlertDialog(R.string.discard, R.string.discard_detail);
} else {
finish();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
index 217e3e89..5caa5c27 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java
@@ -488,7 +488,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail);
return true;
} else {
- if (!binding.postTitleEditTextPostLinkActivity.getText().toString().isEmpty() || !binding.postLinkEditTextPostLinkActivity.getText().toString().isEmpty()) {
+ if (!binding.postTitleEditTextPostLinkActivity.getText().toString().isEmpty()
+ || !binding.postContentEditTextPostLinkActivity.getText().toString().isEmpty()
+ || !binding.postLinkEditTextPostLinkActivity.getText().toString().isEmpty()) {
promptAlertDialog(R.string.discard, R.string.discard_detail);
return true;
}
@@ -550,7 +552,9 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
if (isPosting) {
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail);
} else {
- if (!binding.postTitleEditTextPostLinkActivity.getText().toString().isEmpty() || !binding.postLinkEditTextPostLinkActivity.getText().toString().isEmpty()) {
+ if (!binding.postTitleEditTextPostLinkActivity.getText().toString().isEmpty()
+ || !binding.postContentEditTextPostLinkActivity.getText().toString().isEmpty()
+ || !binding.postLinkEditTextPostLinkActivity.getText().toString().isEmpty()) {
promptAlertDialog(R.string.discard, R.string.discard_detail);
} else {
finish();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java
index a786a16f..813d1ec4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java
@@ -486,7 +486,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
}
private void displaySubredditIcon() {
- if (iconUrl != null && !iconUrl.equals("")) {
+ if (iconUrl != null && !iconUrl.isEmpty()) {
mGlide.load(iconUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
@@ -538,13 +538,14 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail);
return true;
} else {
- if (!binding.postTitleEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option1TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option2TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option3TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option4TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option5TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option6TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")) {
+ if (!binding.postTitleEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.postContentEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option1TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option2TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option3TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option4TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option5TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option6TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()) {
promptAlertDialog(R.string.discard, R.string.discard_detail);
return true;
}
@@ -570,22 +571,22 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
}
ArrayList<String> optionList = new ArrayList<>();
- if (!binding.option1TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")) {
+ if (!binding.option1TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()) {
optionList.add(binding.option1TextInputLayoutEditTextPostPollActivity.getText().toString());
}
- if (!binding.option2TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")) {
+ if (!binding.option2TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()) {
optionList.add(binding.option2TextInputLayoutEditTextPostPollActivity.getText().toString());
}
- if (!binding.option3TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")) {
+ if (!binding.option3TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()) {
optionList.add(binding.option3TextInputLayoutEditTextPostPollActivity.getText().toString());
}
- if (!binding.option4TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")) {
+ if (!binding.option4TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()) {
optionList.add(binding.option4TextInputLayoutEditTextPostPollActivity.getText().toString());
}
- if (!binding.option5TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")) {
+ if (!binding.option5TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()) {
optionList.add(binding.option5TextInputLayoutEditTextPostPollActivity.getText().toString());
}
- if (!binding.option6TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")) {
+ if (!binding.option6TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()) {
optionList.add(binding.option6TextInputLayoutEditTextPostPollActivity.getText().toString());
}
@@ -647,13 +648,14 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
if (isPosting) {
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail);
} else {
- if (!binding.postTitleEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option1TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option2TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option3TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option4TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option5TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")
- || !binding.option6TextInputLayoutEditTextPostPollActivity.getText().toString().equals("")) {
+ if (!binding.postTitleEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.postContentEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option1TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option2TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option3TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option4TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option5TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()
+ || !binding.option6TextInputLayoutEditTextPostPollActivity.getText().toString().isEmpty()) {
promptAlertDialog(R.string.discard, R.string.discard_detail);
} else {
finish();
@@ -791,7 +793,7 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr
} else {
mMemu.findItem(R.id.action_send_post_poll_activity).setEnabled(true);
mMemu.findItem(R.id.action_send_post_poll_activity).getIcon().setAlpha(255);
- if (submitPollPostEvent.errorMessage == null || submitPollPostEvent.errorMessage.equals("")) {
+ if (submitPollPostEvent.errorMessage == null || submitPollPostEvent.errorMessage.isEmpty()) {
Snackbar.make(binding.coordinatorLayoutPostPollActivity, R.string.post_failed, Snackbar.LENGTH_SHORT).show();
} else {
Snackbar.make(binding.coordinatorLayoutPostPollActivity, submitPollPostEvent.errorMessage.substring(0, 1).toUpperCase()
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
index 61e78787..925bb565 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java
@@ -12,17 +12,12 @@ import android.provider.MediaStore;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.appcompat.widget.Toolbar;
-import androidx.constraintlayout.widget.ConstraintLayout;
-import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.content.ContextCompat;
+import androidx.recyclerview.widget.LinearLayoutManager;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
@@ -31,18 +26,11 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
-import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.util.Util;
-import com.google.android.material.appbar.AppBarLayout;
-import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
-import com.google.android.material.divider.MaterialDivider;
-import com.google.android.material.floatingactionbutton.FloatingActionButton;
-import com.google.android.material.materialswitch.MaterialSwitch;
import com.google.android.material.snackbar.Snackbar;
-import com.libRG.CustomTextView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
@@ -52,23 +40,23 @@ import java.util.concurrent.Executor;
import javax.inject.Inject;
import javax.inject.Named;
-import butterknife.BindView;
-import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import ml.docilealligator.infinityforreddit.Flair;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.account.Account;
+import ml.docilealligator.infinityforreddit.adapters.MarkdownBottomBarRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.asynctasks.LoadSubredditIcon;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.AccountChooserBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.FlairBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
+import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed;
+import ml.docilealligator.infinityforreddit.databinding.ActivityPostVideoBinding;
import ml.docilealligator.infinityforreddit.events.SubmitVideoOrGifPostEvent;
import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.services.SubmitPostService;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
-import pl.droidsonroids.gif.GifImageView;
import retrofit2.Retrofit;
public class PostVideoActivity extends BaseActivity implements FlairBottomSheetFragment.FlairSelectionCallback,
@@ -92,52 +80,6 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
private static final int PICK_VIDEO_REQUEST_CODE = 1;
private static final int CAPTURE_VIDEO_REQUEST_CODE = 2;
- @BindView(R.id.coordinator_layout_post_video_activity)
- CoordinatorLayout coordinatorLayout;
- @BindView(R.id.appbar_layout_post_video_activity)
- AppBarLayout appBarLayout;
- @BindView(R.id.toolbar_post_video_activity)
- Toolbar toolbar;
- @BindView(R.id.account_linear_layout_post_video_activity)
- LinearLayout accountLinearLayout;
- @BindView(R.id.account_icon_gif_image_view_post_video_activity)
- GifImageView accountIconImageView;
- @BindView(R.id.account_name_text_view_post_video_activity)
- TextView accountNameTextView;
- @BindView(R.id.subreddit_icon_gif_image_view_post_video_activity)
- GifImageView iconGifImageView;
- @BindView(R.id.subreddit_name_text_view_post_video_activity)
- TextView subredditNameTextView;
- @BindView(R.id.rules_button_post_video_activity)
- MaterialButton rulesButton;
- @BindView(R.id.divider_1_post_video_activity)
- MaterialDivider divider1;
- @BindView(R.id.flair_custom_text_view_post_video_activity)
- CustomTextView flairTextView;
- @BindView(R.id.spoiler_custom_text_view_post_video_activity)
- CustomTextView spoilerTextView;
- @BindView(R.id.nsfw_custom_text_view_post_video_activity)
- CustomTextView nsfwTextView;
- @BindView(R.id.receive_post_reply_notifications_linear_layout_post_video_activity)
- LinearLayout receivePostReplyNotificationsLinearLayout;
- @BindView(R.id.receive_post_reply_notifications_text_view_post_video_activity)
- TextView receivePostReplyNotificationsTextView;
- @BindView(R.id.receive_post_reply_notifications_switch_material_post_video_activity)
- MaterialSwitch receivePostReplyNotificationsSwitchMaterial;
- @BindView(R.id.divider_2_post_video_activity)
- MaterialDivider divider2;
- @BindView(R.id.post_title_edit_text_post_video_activity)
- EditText titleEditText;
- @BindView(R.id.select_video_constraint_layout_post_video_activity)
- ConstraintLayout constraintLayout;
- @BindView(R.id.capture_fab_post_video_activity)
- FloatingActionButton captureFab;
- @BindView(R.id.select_from_library_fab_post_video_activity)
- FloatingActionButton selectFromLibraryFab;
- @BindView(R.id.select_again_text_view_post_video_activity)
- TextView selectAgainTextView;
- @BindView(R.id.player_view_post_video_activity)
- PlayerView videoPlayerView;
@Inject
@Named("no_oauth")
Retrofit mRetrofit;
@@ -188,6 +130,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
private Snackbar mPostingSnackbar;
private DataSource.Factory dataSourceFactory;
private ExoPlayer player;
+ private ActivityPostVideoBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -197,25 +140,24 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_post_video);
-
- ButterKnife.bind(this);
+ binding = ActivityPostVideoBinding.inflate(getLayoutInflater());
+ setContentView(binding.getRoot());
EventBus.getDefault().register(this);
applyCustomTheme();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
- addOnOffsetChangedListener(appBarLayout);
+ addOnOffsetChangedListener(binding.appbarLayoutPostVideoActivity);
}
- setSupportActionBar(toolbar);
+ setSupportActionBar(binding.toolbarPostVideoActivity);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mGlide = Glide.with(this);
player = new ExoPlayer.Builder(this).build();
- videoPlayerView.setPlayer(player);
+ binding.playerViewPostVideoActivity.setPlayer(player);
dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "Infinity"));
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.LOOP_VIDEO, true)) {
@@ -224,7 +166,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
player.setRepeatMode(Player.REPEAT_MODE_OFF);
}
- mPostingSnackbar = Snackbar.make(coordinatorLayout, R.string.posting, Snackbar.LENGTH_INDEFINITE);
+ mPostingSnackbar = Snackbar.make(binding.coordinatorLayoutPostVideoActivity, R.string.posting, Snackbar.LENGTH_INDEFINITE);
resources = getResources();
@@ -245,9 +187,9 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(accountIconImageView);
+ .into(binding.accountIconGifImageViewPostVideoActivity);
- accountNameTextView.setText(selectedAccount.getAccountName());
+ binding.accountNameTextViewPostVideoActivity.setText(selectedAccount.getAccountName());
} else {
loadCurrentAccount();
}
@@ -258,9 +200,9 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
}
if (subredditName != null) {
- subredditNameTextView.setTextColor(primaryTextColor);
- subredditNameTextView.setText(subredditName);
- flairTextView.setVisibility(View.VISIBLE);
+ binding.subredditNameTextViewPostVideoActivity.setTextColor(primaryTextColor);
+ binding.subredditNameTextViewPostVideoActivity.setText(subredditName);
+ binding.flairCustomTextViewPostVideoActivity.setVisibility(View.VISIBLE);
if (!loadSubredditIconSuccessful) {
loadSubredditIcon();
}
@@ -272,20 +214,20 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
}
if (flair != null) {
- flairTextView.setText(flair.getText());
- flairTextView.setBackgroundColor(flairBackgroundColor);
- flairTextView.setBorderColor(flairBackgroundColor);
- flairTextView.setTextColor(flairTextColor);
+ binding.flairCustomTextViewPostVideoActivity.setText(flair.getText());
+ binding.flairCustomTextViewPostVideoActivity.setBackgroundColor(flairBackgroundColor);
+ binding.flairCustomTextViewPostVideoActivity.setBorderColor(flairBackgroundColor);
+ binding.flairCustomTextViewPostVideoActivity.setTextColor(flairTextColor);
}
if (isSpoiler) {
- spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
- spoilerTextView.setBorderColor(spoilerBackgroundColor);
- spoilerTextView.setTextColor(spoilerTextColor);
+ binding.spoilerCustomTextViewPostVideoActivity.setBackgroundColor(spoilerBackgroundColor);
+ binding.spoilerCustomTextViewPostVideoActivity.setBorderColor(spoilerBackgroundColor);
+ binding.spoilerCustomTextViewPostVideoActivity.setTextColor(spoilerTextColor);
}
if (isNSFW) {
- nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
- nsfwTextView.setBorderColor(nsfwBackgroundColor);
- nsfwTextView.setTextColor(nsfwTextColor);
+ binding.nsfwCustomTextViewPostVideoActivity.setBackgroundColor(nsfwBackgroundColor);
+ binding.nsfwCustomTextViewPostVideoActivity.setBorderColor(nsfwBackgroundColor);
+ binding.nsfwCustomTextViewPostVideoActivity.setTextColor(nsfwTextColor);
}
} else {
isPosting = false;
@@ -296,14 +238,14 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
loadSubredditIconSuccessful = false;
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME);
subredditSelected = true;
- subredditNameTextView.setTextColor(primaryTextColor);
- subredditNameTextView.setText(subredditName);
- flairTextView.setVisibility(View.VISIBLE);
+ binding.subredditNameTextViewPostVideoActivity.setTextColor(primaryTextColor);
+ binding.subredditNameTextViewPostVideoActivity.setText(subredditName);
+ binding.flairCustomTextViewPostVideoActivity.setVisibility(View.VISIBLE);
loadSubredditIcon();
} else {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(iconGifImageView);
+ .into(binding.subredditIconGifImageViewPostVideoActivity);
}
videoUri = getIntent().getData();
@@ -312,24 +254,24 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
}
}
- accountLinearLayout.setOnClickListener(view -> {
+ binding.accountLinearLayoutPostVideoActivity.setOnClickListener(view -> {
AccountChooserBottomSheetFragment fragment = new AccountChooserBottomSheetFragment();
fragment.show(getSupportFragmentManager(), fragment.getTag());
});
- iconGifImageView.setOnClickListener(view -> {
- subredditNameTextView.performClick();
+ binding.subredditIconGifImageViewPostVideoActivity.setOnClickListener(view -> {
+ binding.subredditNameTextViewPostVideoActivity.performClick();
});
- subredditNameTextView.setOnClickListener(view -> {
+ binding.subredditNameTextViewPostVideoActivity.setOnClickListener(view -> {
Intent intent = new Intent(this, SubredditSelectionActivity.class);
intent.putExtra(SubredditSelectionActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount);
startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE);
});
- rulesButton.setOnClickListener(view -> {
+ binding.rulesButtonPostVideoActivity.setOnClickListener(view -> {
if (subredditName == null) {
- Snackbar.make(coordinatorLayout, R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show();
+ Snackbar.make(binding.coordinatorLayoutPostVideoActivity, R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show();
} else {
Intent intent = new Intent(this, RulesActivity.class);
if (subredditIsUser) {
@@ -341,7 +283,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
}
});
- flairTextView.setOnClickListener(view -> {
+ binding.flairCustomTextViewPostVideoActivity.setOnClickListener(view -> {
if (flair == null) {
mFlairSelectionBottomSheetFragment = new FlairBottomSheetFragment();
Bundle bundle = new Bundle();
@@ -349,44 +291,44 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
mFlairSelectionBottomSheetFragment.setArguments(bundle);
mFlairSelectionBottomSheetFragment.show(getSupportFragmentManager(), mFlairSelectionBottomSheetFragment.getTag());
} else {
- flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
- flairTextView.setTextColor(primaryTextColor);
- flairTextView.setText(getString(R.string.flair));
+ binding.flairCustomTextViewPostVideoActivity.setBackgroundColor(resources.getColor(android.R.color.transparent));
+ binding.flairCustomTextViewPostVideoActivity.setTextColor(primaryTextColor);
+ binding.flairCustomTextViewPostVideoActivity.setText(getString(R.string.flair));
flair = null;
}
});
- spoilerTextView.setOnClickListener(view -> {
+ binding.spoilerCustomTextViewPostVideoActivity.setOnClickListener(view -> {
if (!isSpoiler) {
- spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
- spoilerTextView.setBorderColor(spoilerBackgroundColor);
- spoilerTextView.setTextColor(spoilerTextColor);
+ binding.spoilerCustomTextViewPostVideoActivity.setBackgroundColor(spoilerBackgroundColor);
+ binding.spoilerCustomTextViewPostVideoActivity.setBorderColor(spoilerBackgroundColor);
+ binding.spoilerCustomTextViewPostVideoActivity.setTextColor(spoilerTextColor);
isSpoiler = true;
} else {
- spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
- spoilerTextView.setTextColor(primaryTextColor);
+ binding.spoilerCustomTextViewPostVideoActivity.setBackgroundColor(resources.getColor(android.R.color.transparent));
+ binding.spoilerCustomTextViewPostVideoActivity.setTextColor(primaryTextColor);
isSpoiler = false;
}
});
- nsfwTextView.setOnClickListener(view -> {
+ binding.nsfwCustomTextViewPostVideoActivity.setOnClickListener(view -> {
if (!isNSFW) {
- nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
- nsfwTextView.setBorderColor(nsfwBackgroundColor);
- nsfwTextView.setTextColor(nsfwTextColor);
+ binding.nsfwCustomTextViewPostVideoActivity.setBackgroundColor(nsfwBackgroundColor);
+ binding.nsfwCustomTextViewPostVideoActivity.setBorderColor(nsfwBackgroundColor);
+ binding.nsfwCustomTextViewPostVideoActivity.setTextColor(nsfwTextColor);
isNSFW = true;
} else {
- nsfwTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
- nsfwTextView.setTextColor(primaryTextColor);
+ binding.nsfwCustomTextViewPostVideoActivity.setBackgroundColor(resources.getColor(android.R.color.transparent));
+ binding.nsfwCustomTextViewPostVideoActivity.setTextColor(primaryTextColor);
isNSFW = false;
}
});
- receivePostReplyNotificationsLinearLayout.setOnClickListener(view -> {
- receivePostReplyNotificationsSwitchMaterial.performClick();
+ binding.receivePostReplyNotificationsLinearLayoutPostVideoActivity.setOnClickListener(view -> {
+ binding.receivePostReplyNotificationsSwitchMaterialPostVideoActivity.performClick();
});
- captureFab.setOnClickListener(view -> {
+ binding.captureFabPostVideoActivity.setOnClickListener(view -> {
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
try {
startActivityForResult(takeVideoIntent, CAPTURE_VIDEO_REQUEST_CODE);
@@ -395,21 +337,39 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
}
});
- selectFromLibraryFab.setOnClickListener(view -> {
+ binding.selectFromLibraryFabPostVideoActivity.setOnClickListener(view -> {
Intent intent = new Intent();
intent.setType("video/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, resources.getString(R.string.select_from_gallery)), PICK_VIDEO_REQUEST_CODE);
});
- selectAgainTextView.setOnClickListener(view -> {
+ binding.selectAgainTextViewPostVideoActivity.setOnClickListener(view -> {
wasPlaying = false;
player.setPlayWhenReady(false);
videoUri = null;
- videoPlayerView.setVisibility(View.GONE);
- selectAgainTextView.setVisibility(View.GONE);
- constraintLayout.setVisibility(View.VISIBLE);
+ binding.playerViewPostVideoActivity.setVisibility(View.GONE);
+ binding.selectAgainTextViewPostVideoActivity.setVisibility(View.GONE);
+ binding.selectVideoConstraintLayoutPostVideoActivity.setVisibility(View.VISIBLE);
+ });
+
+ MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
+ mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
+ @Override
+ public void onClick(int item) {
+ MarkdownBottomBarRecyclerViewAdapter.bindEditTextWithItemClickListener(
+ PostVideoActivity.this, binding.postContentEditTextPostVideoActivity, item);
+ }
+
+ @Override
+ public void onUploadImage() {
+
+ }
});
+
+ binding.markdownBottomBarRecyclerViewPostVideoActivity.setLayoutManager(new LinearLayoutManagerBugFixed(this,
+ LinearLayoutManager.HORIZONTAL, false));
+ binding.markdownBottomBarRecyclerViewPostVideoActivity.setAdapter(adapter);
}
private void loadCurrentAccount() {
@@ -423,9 +383,9 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(accountIconImageView);
+ .into(binding.accountIconGifImageViewPostVideoActivity);
- accountNameTextView.setText(account.getAccountName());
+ binding.accountNameTextViewPostVideoActivity.setText(account.getAccountName());
}
});
});
@@ -448,64 +408,66 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
@Override
protected void applyCustomTheme() {
- coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
- applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar);
+ binding.coordinatorLayoutPostVideoActivity.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
+ applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(binding.appbarLayoutPostVideoActivity, null, binding.toolbarPostVideoActivity);
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
- accountNameTextView.setTextColor(primaryTextColor);
+ binding.accountNameTextViewPostVideoActivity.setTextColor(primaryTextColor);
int secondaryTextColor = mCustomThemeWrapper.getSecondaryTextColor();
- subredditNameTextView.setTextColor(secondaryTextColor);
- rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
- rulesButton.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme());
- receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
+ binding.subredditNameTextViewPostVideoActivity.setTextColor(secondaryTextColor);
+ binding.rulesButtonPostVideoActivity.setTextColor(mCustomThemeWrapper.getButtonTextColor());
+ binding.rulesButtonPostVideoActivity.setBackgroundColor(mCustomThemeWrapper.getColorPrimaryLightTheme());
+ binding.receivePostReplyNotificationsTextViewPostVideoActivity.setTextColor(primaryTextColor);
int dividerColor = mCustomThemeWrapper.getDividerColor();
- divider1.setDividerColor(dividerColor);
- divider2.setDividerColor(dividerColor);
+ binding.divider1PostVideoActivity.setDividerColor(dividerColor);
+ binding.divider2PostVideoActivity.setDividerColor(dividerColor);
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
flairTextColor = mCustomThemeWrapper.getFlairTextColor();
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
spoilerTextColor = mCustomThemeWrapper.getSpoilerTextColor();
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
- flairTextView.setTextColor(primaryTextColor);
- spoilerTextView.setTextColor(primaryTextColor);
- nsfwTextView.setTextColor(primaryTextColor);
- titleEditText.setTextColor(primaryTextColor);
- titleEditText.setHintTextColor(secondaryTextColor);
- applyFABTheme(captureFab);
- applyFABTheme(selectFromLibraryFab);
- selectAgainTextView.setTextColor(mCustomThemeWrapper.getColorAccent());
+ binding.flairCustomTextViewPostVideoActivity.setTextColor(primaryTextColor);
+ binding.spoilerCustomTextViewPostVideoActivity.setTextColor(primaryTextColor);
+ binding.nsfwCustomTextViewPostVideoActivity.setTextColor(primaryTextColor);
+ binding.postTitleEditTextPostVideoActivity.setTextColor(primaryTextColor);
+ binding.postTitleEditTextPostVideoActivity.setHintTextColor(secondaryTextColor);
+ binding.postContentEditTextPostVideoActivity.setTextColor(primaryTextColor);
+ binding.postContentEditTextPostVideoActivity.setHintTextColor(secondaryTextColor);
+ applyFABTheme(binding.captureFabPostVideoActivity);
+ applyFABTheme(binding.selectFromLibraryFabPostVideoActivity);
+ binding.selectAgainTextViewPostVideoActivity.setTextColor(mCustomThemeWrapper.getColorAccent());
if (typeface != null) {
- subredditNameTextView.setTypeface(typeface);
- rulesButton.setTypeface(typeface);
- receivePostReplyNotificationsTextView.setTypeface(typeface);
- flairTextView.setTypeface(typeface);
- spoilerTextView.setTypeface(typeface);
- nsfwTextView.setTypeface(typeface);
- titleEditText.setTypeface(typeface);
- selectAgainTextView.setTypeface(typeface);
+ binding.subredditNameTextViewPostVideoActivity.setTypeface(typeface);
+ binding.rulesButtonPostVideoActivity.setTypeface(typeface);
+ binding.receivePostReplyNotificationsTextViewPostVideoActivity.setTypeface(typeface);
+ binding.flairCustomTextViewPostVideoActivity.setTypeface(typeface);
+ binding.spoilerCustomTextViewPostVideoActivity.setTypeface(typeface);
+ binding.nsfwCustomTextViewPostVideoActivity.setTypeface(typeface);
+ binding.postTitleEditTextPostVideoActivity.setTypeface(typeface);
+ binding.selectAgainTextViewPostVideoActivity.setTypeface(typeface);
}
}
private void loadVideo() {
- constraintLayout.setVisibility(View.GONE);
- selectAgainTextView.setVisibility(View.VISIBLE);
- videoPlayerView.setVisibility(View.VISIBLE);
+ binding.selectVideoConstraintLayoutPostVideoActivity.setVisibility(View.GONE);
+ binding.selectAgainTextViewPostVideoActivity.setVisibility(View.VISIBLE);
+ binding.playerViewPostVideoActivity.setVisibility(View.VISIBLE);
player.prepare(new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(videoUri)));
player.setPlayWhenReady(true);
wasPlaying = true;
}
private void displaySubredditIcon() {
- if (iconUrl != null && !iconUrl.equals("")) {
+ if (iconUrl != null && !iconUrl.isEmpty()) {
mGlide.load(iconUrl)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(iconGifImageView);
+ .into(binding.subredditIconGifImageViewPostVideoActivity);
} else {
mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
- .into(iconGifImageView);
+ .into(binding.subredditIconGifImageViewPostVideoActivity);
}
}
@@ -547,7 +509,9 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail);
return true;
} else {
- if (!titleEditText.getText().toString().equals("") || videoUri != null) {
+ if (!binding.postTitleEditTextPostVideoActivity.getText().toString().isEmpty()
+ || !binding.postContentEditTextPostVideoActivity.getText().toString().isEmpty()
+ || videoUri != null) {
promptAlertDialog(R.string.discard, R.string.discard_detail);
return true;
}
@@ -556,17 +520,17 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
return true;
} else if (itemId == R.id.action_send_post_video_activity) {
if (!subredditSelected) {
- Snackbar.make(coordinatorLayout, R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show();
+ Snackbar.make(binding.coordinatorLayoutPostVideoActivity, R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show();
return true;
}
- if (titleEditText.getText() == null || titleEditText.getText().toString().equals("")) {
- Snackbar.make(coordinatorLayout, R.string.title_required, Snackbar.LENGTH_SHORT).show();
+ if (binding.postTitleEditTextPostVideoActivity.getText() == null || binding.postTitleEditTextPostVideoActivity.getText().toString().isEmpty()) {
+ Snackbar.make(binding.coordinatorLayoutPostVideoActivity, R.string.title_required, Snackbar.LENGTH_SHORT).show();
return true;
}
if (videoUri == null) {
- Snackbar.make(coordinatorLayout, R.string.select_an_image, Snackbar.LENGTH_SHORT).show();
+ Snackbar.make(binding.coordinatorLayoutPostVideoActivity, R.string.select_an_image, Snackbar.LENGTH_SHORT).show();
return true;
}
@@ -579,20 +543,21 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
String subredditName;
if (subredditIsUser) {
- subredditName = "u_" + subredditNameTextView.getText().toString();
+ subredditName = "u_" + binding.subredditNameTextViewPostVideoActivity.getText().toString();
} else {
- subredditName = subredditNameTextView.getText().toString();
+ subredditName = binding.subredditNameTextViewPostVideoActivity.getText().toString();
}
Intent intent = new Intent(this, SubmitPostService.class);
intent.setData(videoUri);
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, subredditName);
- intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_TITLE, binding.postTitleEditTextPostVideoActivity.getText().toString());
+ intent.putExtra(SubmitPostService.EXTRA_CONTENT, binding.postContentEditTextPostVideoActivity.getText().toString());
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_RECEIVE_POST_REPLY_NOTIFICATIONS, binding.receivePostReplyNotificationsSwitchMaterialPostVideoActivity.isChecked());
intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_VIDEO);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
@@ -609,7 +574,9 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
if (isPosting) {
promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail);
} else {
- if (!titleEditText.getText().toString().equals("") || videoUri != null) {
+ if (!binding.postTitleEditTextPostVideoActivity.getText().toString().isEmpty()
+ || !binding.postContentEditTextPostVideoActivity.getText().toString().isEmpty()
+ || videoUri != null) {
promptAlertDialog(R.string.discard, R.string.discard_detail);
} else {
finish();
@@ -660,21 +627,21 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
subredditSelected = true;
subredditIsUser = data.getBooleanExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER, false);
- subredditNameTextView.setTextColor(primaryTextColor);
- subredditNameTextView.setText(subredditName);
+ binding.subredditNameTextViewPostVideoActivity.setTextColor(primaryTextColor);
+ binding.subredditNameTextViewPostVideoActivity.setText(subredditName);
displaySubredditIcon();
- flairTextView.setVisibility(View.VISIBLE);
- flairTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
- flairTextView.setTextColor(primaryTextColor);
- flairTextView.setText(getString(R.string.flair));
+ binding.flairCustomTextViewPostVideoActivity.setVisibility(View.VISIBLE);
+ binding.flairCustomTextViewPostVideoActivity.setBackgroundColor(resources.getColor(android.R.color.transparent));
+ binding.flairCustomTextViewPostVideoActivity.setTextColor(primaryTextColor);
+ binding.flairCustomTextViewPostVideoActivity.setText(getString(R.string.flair));
flair = null;
}
}
} else if (requestCode == PICK_VIDEO_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
if (data == null) {
- Snackbar.make(coordinatorLayout, R.string.error_getting_video, Snackbar.LENGTH_SHORT).show();
+ Snackbar.make(binding.coordinatorLayoutPostVideoActivity, R.string.error_getting_video, Snackbar.LENGTH_SHORT).show();
return;
}
@@ -687,7 +654,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
videoUri = data.getData();
loadVideo();
} else {
- Snackbar.make(coordinatorLayout, R.string.error_getting_video, Snackbar.LENGTH_SHORT).show();
+ Snackbar.make(binding.coordinatorLayoutPostVideoActivity, R.string.error_getting_video, Snackbar.LENGTH_SHORT).show();
}
}
}
@@ -705,10 +672,10 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
@Override
public void flairSelected(Flair flair) {
this.flair = flair;
- flairTextView.setText(flair.getText());
- flairTextView.setBackgroundColor(flairBackgroundColor);
- flairTextView.setBorderColor(flairBackgroundColor);
- flairTextView.setTextColor(flairTextColor);
+ binding.flairCustomTextViewPostVideoActivity.setText(flair.getText());
+ binding.flairCustomTextViewPostVideoActivity.setBackgroundColor(flairBackgroundColor);
+ binding.flairCustomTextViewPostVideoActivity.setBorderColor(flairBackgroundColor);
+ binding.flairCustomTextViewPostVideoActivity.setTextColor(flairTextColor);
}
@Override
@@ -720,9 +687,9 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0)))
.error(mGlide.load(R.drawable.subreddit_default_icon)
.apply(RequestOptions.bitmapTransform(new RoundedCornersTransformation(72, 0))))
- .into(accountIconImageView);
+ .into(binding.accountIconGifImageViewPostVideoActivity);
- accountNameTextView.setText(selectedAccount.getAccountName());
+ binding.accountNameTextViewPostVideoActivity.setText(selectedAccount.getAccountName());
}
}
@@ -745,12 +712,12 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
startActivity(intent);
finish();
} else if (submitVideoOrGifPostEvent.errorProcessingVideoOrGif) {
- Snackbar.make(coordinatorLayout, R.string.error_processing_video, Snackbar.LENGTH_SHORT).show();
+ Snackbar.make(binding.coordinatorLayoutPostVideoActivity, R.string.error_processing_video, Snackbar.LENGTH_SHORT).show();
} else {
- if (submitVideoOrGifPostEvent.errorMessage == null || submitVideoOrGifPostEvent.errorMessage.equals("")) {
- Snackbar.make(coordinatorLayout, R.string.post_failed, Snackbar.LENGTH_SHORT).show();
+ if (submitVideoOrGifPostEvent.errorMessage == null || submitVideoOrGifPostEvent.errorMessage.isEmpty()) {
+ Snackbar.make(binding.coordinatorLayoutPostVideoActivity, R.string.post_failed, Snackbar.LENGTH_SHORT).show();
} else {
- Snackbar.make(coordinatorLayout, submitVideoOrGifPostEvent.errorMessage.substring(0, 1).toUpperCase()
+ Snackbar.make(binding.coordinatorLayoutPostVideoActivity, submitVideoOrGifPostEvent.errorMessage.substring(0, 1).toUpperCase()
+ submitVideoOrGifPostEvent.errorMessage.substring(1), Snackbar.LENGTH_SHORT).show();
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/SubmitPost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/SubmitPost.java
index 5d607740..fbb15bc8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/SubmitPost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/SubmitPost.java
@@ -61,7 +61,7 @@ public class SubmitPost {
public static void submitVideoPost(Executor executor, Handler handler, Retrofit oauthRetrofit, Retrofit uploadMediaRetrofit,
Retrofit uploadVideoRetrofit, String accessToken,
- String subredditName, String title, File buffer, String mimeType,
+ String subredditName, String title, String content, File buffer, String mimeType,
Bitmap posterBitmap, Flair flair, boolean isSpoiler, boolean isNSFW,
boolean receivePostReplyNotifications, SubmitPostListener submitPostListener) {
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
@@ -99,12 +99,12 @@ public class SubmitPost {
if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) {
if (fileType.equals("gif")) {
submitPost(executor, handler, oauthRetrofit, accessToken,
- subredditName, title, null, url, flair, isSpoiler, isNSFW,
+ subredditName, title, content, url, flair, isSpoiler, isNSFW,
receivePostReplyNotifications, false, APIUtils.KIND_VIDEOGIF, imageUrlOrError,
submitPostListener);
} else {
submitPost(executor, handler, oauthRetrofit, accessToken,
- subredditName, title, null, url, flair, isSpoiler, isNSFW,
+ subredditName, title, content, url, flair, isSpoiler, isNSFW,
receivePostReplyNotifications, false, APIUtils.KIND_VIDEO, imageUrlOrError,
submitPostListener);
}
@@ -159,11 +159,13 @@ public class SubmitPost {
params.put(APIUtils.URL_KEY, url);
break;
case APIUtils.KIND_VIDEOGIF:
+ params.put(APIUtils.TEXT_KEY, content);
params.put(APIUtils.KIND_KEY, APIUtils.KIND_IMAGE);
params.put(APIUtils.URL_KEY, url);
params.put(APIUtils.VIDEO_POSTER_URL_KEY, posterUrl);
break;
case APIUtils.KIND_VIDEO:
+ params.put(APIUtils.TEXT_KEY, content);
params.put(APIUtils.URL_KEY, url);
params.put(APIUtils.VIDEO_POSTER_URL_KEY, posterUrl);
break;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java
index eb24bf73..72395162 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/SubmitPostService.java
@@ -176,8 +176,8 @@ public class SubmitPostService extends Service {
bundle.getString(EXTRA_CONTENT), flair, isSpoiler, isNSFW, receivePostReplyNotifications);
} else if (postType == EXTRA_POST_TYPE_VIDEO) {
Uri mediaUri = Uri.parse(bundle.getString(EXTRA_MEDIA_URI));
- submitVideoPost(newAuthenticatorOauthRetrofit, account, mediaUri, subredditName, title, flair,
- isSpoiler, isNSFW, receivePostReplyNotifications);
+ submitVideoPost(newAuthenticatorOauthRetrofit, account, mediaUri, subredditName, title,
+ bundle.getString(EXTRA_CONTENT), flair, isSpoiler, isNSFW, receivePostReplyNotifications);
} else if (postType == EXTRA_POST_TYPE_GALLERY) {
submitGalleryPost(newAuthenticatorOauthRetrofit, account, bundle.getString(EXTRA_REDDIT_GALLERY_PAYLOAD));
} else {
@@ -327,8 +327,9 @@ public class SubmitPostService extends Service {
}
}
- private void submitVideoPost(Retrofit newAuthenticatorOauthRetrofit, Account selectedAccount, Uri mediaUri, String subredditName, String title,
- Flair flair, boolean isSpoiler, boolean isNSFW, boolean receivePostReplyNotifications) {
+ private void submitVideoPost(Retrofit newAuthenticatorOauthRetrofit, Account selectedAccount, Uri mediaUri,
+ String subredditName, String title, String content, Flair flair,
+ boolean isSpoiler, boolean isNSFW, boolean receivePostReplyNotifications) {
try {
InputStream in = getContentResolver().openInputStream(mediaUri);
String type = getContentResolver().getType(mediaUri);
@@ -345,8 +346,8 @@ public class SubmitPostService extends Service {
if (type != null) {
SubmitPost.submitVideoPost(mExecutor, handler, newAuthenticatorOauthRetrofit, mUploadMediaRetrofit,
- mUploadVideoRetrofit, selectedAccount.getAccessToken(), subredditName, title, new File(cacheFilePath),
- type, resource, flair, isSpoiler, isNSFW, receivePostReplyNotifications,
+ mUploadVideoRetrofit, selectedAccount.getAccessToken(), subredditName, title, content,
+ new File(cacheFilePath), type, resource, flair, isSpoiler, isNSFW, receivePostReplyNotifications,
new SubmitPost.SubmitPostListener() {
@Override
public void submitSuccessful(Post post) {
diff --git a/app/src/main/res/layout/activity_post_video.xml b/app/src/main/res/layout/activity_post_video.xml
index 9fdae5a3..14812cae 100644
--- a/app/src/main/res/layout/activity_post_video.xml
+++ b/app/src/main/res/layout/activity_post_video.xml
@@ -23,239 +23,266 @@
</com.google.android.material.appbar.AppBarLayout>
- <androidx.core.widget.NestedScrollView
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:orientation="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
- <LinearLayout
+ <androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="0dp"
+ android:layout_weight="1">
<LinearLayout
- android:id="@+id/account_linear_layout_post_video_activity"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="16dp"
- android:paddingBottom="16dp"
- android:clickable="true"
- android:focusable="true"
- android:background="?attr/selectableItemBackground">
-
- <pl.droidsonroids.gif.GifImageView
- android:id="@+id/account_icon_gif_image_view_post_video_activity"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:layout_marginStart="16dp" />
+ android:layout_height="match_parent"
+ android:orientation="vertical">
- <TextView
- android:id="@+id/account_name_text_view_post_video_activity"
- android:layout_width="wrap_content"
+ <LinearLayout
+ android:id="@+id/account_linear_layout_post_video_activity"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:layout_marginStart="32dp"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family" />
-
- </LinearLayout>
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingTop="8dp"
- android:paddingBottom="8dp">
-
- <pl.droidsonroids.gif.GifImageView
- android:id="@+id/subreddit_icon_gif_image_view_post_video_activity"
- android:layout_width="24dp"
- android:layout_height="24dp"
- android:layout_alignParentStart="true"
- android:layout_centerVertical="true"
- android:layout_marginStart="16dp" />
-
- <TextView
- android:id="@+id/subreddit_name_text_view_post_video_activity"
- android:layout_width="wrap_content"
+ android:paddingTop="16dp"
+ android:paddingBottom="16dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground">
+
+ <pl.droidsonroids.gif.GifImageView
+ android:id="@+id/account_icon_gif_image_view_post_video_activity"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_marginStart="16dp" />
+
+ <TextView
+ android:id="@+id/account_name_text_view_post_video_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_marginStart="32dp"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family" />
+
+ </LinearLayout>
+
+ <RelativeLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_centerVertical="true"
- android:layout_marginStart="32dp"
- android:layout_toStartOf="@id/rules_button_post_video_activity"
- android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_video_activity"
- android:text="@string/choose_a_subreddit"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family" />
-
- <com.google.android.material.button.MaterialButton
- android:id="@+id/rules_button_post_video_activity"
- android:layout_width="wrap_content"
+ android:paddingTop="8dp"
+ android:paddingBottom="8dp">
+
+ <pl.droidsonroids.gif.GifImageView
+ android:id="@+id/subreddit_icon_gif_image_view_post_video_activity"
+ android:layout_width="24dp"
+ android:layout_height="24dp"
+ android:layout_alignParentStart="true"
+ android:layout_centerVertical="true"
+ android:layout_marginStart="16dp" />
+
+ <TextView
+ android:id="@+id/subreddit_name_text_view_post_video_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_centerVertical="true"
+ android:layout_marginStart="32dp"
+ android:layout_toStartOf="@id/rules_button_post_video_activity"
+ android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_video_activity"
+ android:text="@string/choose_a_subreddit"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/rules_button_post_video_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_alignParentEnd="true"
+ android:layout_centerVertical="true"
+ android:layout_marginStart="16dp"
+ android:layout_marginEnd="16dp"
+ android:text="@string/rules"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family" />
+
+ </RelativeLayout>
+
+ <com.google.android.material.divider.MaterialDivider
+ android:id="@+id/divider_1_post_video_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <com.libRG.CustomTextView
+ android:id="@+id/flair_custom_text_view_post_video_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:padding="4dp"
+ android:text="@string/flair"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ android:visibility="gone"
+ app:lib_setRadius="6dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/spoiler_custom_text_view_post_video_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:padding="4dp"
+ android:text="@string/spoiler"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ app:lib_setRadius="6dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ <com.libRG.CustomTextView
+ android:id="@+id/nsfw_custom_text_view_post_video_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:padding="4dp"
+ android:text="@string/nsfw"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family"
+ app:lib_setRadius="6dp"
+ app:lib_setRoundedView="true"
+ app:lib_setShape="rectangle" />
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/receive_post_reply_notifications_linear_layout_post_video_activity"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_alignParentEnd="true"
- android:layout_centerVertical="true"
- android:layout_marginStart="16dp"
- android:layout_marginEnd="16dp"
- android:text="@string/rules"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family" />
-
- </RelativeLayout>
-
- <com.google.android.material.divider.MaterialDivider
- android:id="@+id/divider_1_post_video_activity"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <com.libRG.CustomTextView
- android:id="@+id/flair_custom_text_view_post_video_activity"
- android:layout_width="wrap_content"
+ android:paddingStart="16dp"
+ android:paddingEnd="16dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackground">
+
+ <TextView
+ android:id="@+id/receive_post_reply_notifications_text_view_post_video_activity"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_gravity="center_vertical"
+ android:layout_marginEnd="16dp"
+ android:text="@string/receive_post_reply_notifications"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family" />
+
+ <com.google.android.material.materialswitch.MaterialSwitch
+ android:id="@+id/receive_post_reply_notifications_switch_material_post_video_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:checked="true" />
+
+ </LinearLayout>
+
+ <com.google.android.material.divider.MaterialDivider
+ android:id="@+id/divider_2_post_video_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <EditText
+ android:id="@+id/post_title_edit_text_post_video_activity"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="16dp"
- android:padding="4dp"
- android:text="@string/flair"
+ android:background="#00000000"
+ android:gravity="top"
+ android:hint="@string/post_title_hint"
+ android:inputType="textCapSentences|textMultiLine"
+ android:padding="16dp"
android:textColor="?attr/primaryTextColor"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family"
- android:visibility="gone"
- app:lib_setRadius="6dp"
- app:lib_setRoundedView="true"
- app:lib_setShape="rectangle" />
+ android:textSize="?attr/title_font_18"
+ android:fontFamily="?attr/title_font_family" />
+
+ <EditText
+ android:id="@+id/post_content_edit_text_post_video_activity"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#00000000"
+ android:gravity="top"
+ android:hint="@string/post_optional_text_content_hint"
+ android:inputType="textCapSentences|textMultiLine"
+ android:padding="16dp"
+ android:textSize="?attr/content_font_18"
+ android:fontFamily="?attr/content_font_family" />
- <com.libRG.CustomTextView
- android:id="@+id/spoiler_custom_text_view_post_video_activity"
- android:layout_width="wrap_content"
+ <androidx.constraintlayout.widget.ConstraintLayout
+ android:id="@+id/select_video_constraint_layout_post_video_activity"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_margin="16dp"
- android:padding="4dp"
- android:text="@string/spoiler"
- android:textColor="?attr/primaryTextColor"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family"
- app:lib_setRadius="6dp"
- app:lib_setRoundedView="true"
- app:lib_setShape="rectangle" />
+ android:padding="32dp">
+
+ <com.google.android.material.floatingactionbutton.FloatingActionButton
+ android:id="@+id/capture_fab_post_video_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ android:src="@drawable/ic_outline_add_a_photo_24dp"
+ app:useCompatPadding="true"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_video_activity"
+ app:layout_constraintHorizontal_chainStyle="spread"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <com.google.android.material.floatingactionbutton.FloatingActionButton
+ android:id="@+id/select_from_library_fab_post_video_activity"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="16dp"
+ android:src="@drawable/ic_outline_select_photo_24dp"
+ app:useCompatPadding="true"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_chainStyle="spread"
+ app:layout_constraintStart_toEndOf="@+id/capture_fab_post_video_activity"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ </androidx.constraintlayout.widget.ConstraintLayout>
- <com.libRG.CustomTextView
- android:id="@+id/nsfw_custom_text_view_post_video_activity"
+ <TextView
+ android:id="@+id/select_again_text_view_post_video_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_margin="16dp"
- android:padding="4dp"
- android:text="@string/nsfw"
- android:textColor="?attr/primaryTextColor"
+ android:padding="16dp"
+ android:text="@string/select_again"
+ android:textColor="?attr/colorAccent"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family"
- app:lib_setRadius="6dp"
- app:lib_setRoundedView="true"
- app:lib_setShape="rectangle" />
+ android:visibility="gone" />
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/receive_post_reply_notifications_linear_layout_post_video_activity"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:paddingStart="16dp"
- android:paddingEnd="16dp"
- android:clickable="true"
- android:focusable="true"
- android:background="?attr/selectableItemBackground">
-
- <TextView
- android:id="@+id/receive_post_reply_notifications_text_view_post_video_activity"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_gravity="center_vertical"
- android:layout_marginEnd="16dp"
- android:text="@string/receive_post_reply_notifications"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family" />
-
- <com.google.android.material.materialswitch.MaterialSwitch
- android:id="@+id/receive_post_reply_notifications_switch_material_post_video_activity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:checked="true" />
+ <com.google.android.exoplayer2.ui.PlayerView
+ android:id="@+id/player_view_post_video_activity"
+ android:layout_width="match_parent"
+ android:layout_height="400dp"
+ android:visibility="gone"
+ app:controller_layout_id="@layout/exo_playback_control_view" />
</LinearLayout>
- <com.google.android.material.divider.MaterialDivider
- android:id="@+id/divider_2_post_video_activity"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <EditText
- android:id="@+id/post_title_edit_text_post_video_activity"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="#00000000"
- android:gravity="top"
- android:hint="@string/post_title_hint"
- android:inputType="textCapSentences|textMultiLine"
- android:padding="16dp"
- android:textColor="?attr/primaryTextColor"
- android:textSize="?attr/title_font_18"
- android:fontFamily="?attr/title_font_family" />
-
- <androidx.constraintlayout.widget.ConstraintLayout
- android:id="@+id/select_video_constraint_layout_post_video_activity"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:padding="32dp">
+ </androidx.core.widget.NestedScrollView>
- <com.google.android.material.floatingactionbutton.FloatingActionButton
- android:id="@+id/capture_fab_post_video_activity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="16dp"
- android:src="@drawable/ic_outline_add_a_photo_24dp"
- app:useCompatPadding="true"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toStartOf="@+id/select_from_library_fab_post_video_activity"
- app:layout_constraintHorizontal_chainStyle="spread"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent" />
-
- <com.google.android.material.floatingactionbutton.FloatingActionButton
- android:id="@+id/select_from_library_fab_post_video_activity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="16dp"
- android:src="@drawable/ic_outline_select_photo_24dp"
- app:useCompatPadding="true"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHorizontal_chainStyle="spread"
- app:layout_constraintStart_toEndOf="@+id/capture_fab_post_video_activity"
- app:layout_constraintTop_toTopOf="parent" />
-
- </androidx.constraintlayout.widget.ConstraintLayout>
-
- <TextView
- android:id="@+id/select_again_text_view_post_video_activity"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:padding="16dp"
- android:text="@string/select_again"
- android:textColor="?attr/colorAccent"
- android:textSize="?attr/font_default"
- android:fontFamily="?attr/font_family"
- android:visibility="gone" />
-
- <com.google.android.exoplayer2.ui.PlayerView
- android:id="@+id/player_view_post_video_activity"
- android:layout_width="match_parent"
- android:layout_height="400dp"
- android:visibility="gone"
- app:controller_layout_id="@layout/exo_playback_control_view" />
-
- </LinearLayout>
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/markdown_bottom_bar_recycler_view_post_video_activity"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:scrollbars="horizontal"
+ android:layout_gravity="bottom" />
- </androidx.core.widget.NestedScrollView>
+ </LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file