diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-07-14 14:43:13 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-07-14 14:43:13 +0000 |
commit | 04624a1f13e5714b385f964147f7c6e8a8fdfe25 (patch) | |
tree | 038768772ae681d9ea1094fa690d7364364f7ba8 /app/src/main | |
parent | a904282c33fcbd10e78cfc88a6788dee3f4159cb (diff) | |
download | infinity-for-reddit-04624a1f13e5714b385f964147f7c6e8a8fdfe25.tar infinity-for-reddit-04624a1f13e5714b385f964147f7c6e8a8fdfe25.tar.gz infinity-for-reddit-04624a1f13e5714b385f964147f7c6e8a8fdfe25.tar.bz2 infinity-for-reddit-04624a1f13e5714b385f964147f7c6e8a8fdfe25.tar.lz infinity-for-reddit-04624a1f13e5714b385f964147f7c6e8a8fdfe25.tar.xz infinity-for-reddit-04624a1f13e5714b385f964147f7c6e8a8fdfe25.tar.zst infinity-for-reddit-04624a1f13e5714b385f964147f7c6e8a8fdfe25.zip |
Choose whether receiving post reply notifications or not in SubmitCrosspostActivity.
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java | 121 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_submit_crosspost.xml | 39 |
2 files changed, 107 insertions, 53 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java index 7e97c0a6..e76b96f4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java @@ -16,6 +16,7 @@ import android.widget.Button; import android.widget.EditText; import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; @@ -34,6 +35,7 @@ import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView; import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.snackbar.Snackbar; +import com.google.android.material.switchmaterial.SwitchMaterial; import com.libRG.CustomTextView; import org.greenrobot.eventbus.EventBus; @@ -102,10 +104,18 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom CustomTextView nsfwTextView; @BindView(R.id.divider_2_submit_crosspost_activity) View divider2; - @BindView(R.id.post_title_edit_text_submit_crosspost_activity) - EditText titleEditText; + @BindView(R.id.receive_post_reply_notifications_linear_layout_submit_crosspost_activity) + LinearLayout receivePostReplyNotificationsLinearLayout; + @BindView(R.id.receive_post_reply_notifications_text_view_submit_crosspost_activity) + TextView receivePostReplyNotificationsTextView; + @BindView(R.id.receive_post_reply_notifications_switch_material_submit_crosspost_activity) + SwitchMaterial receivePostReplyNotificationsSwitchMaterial; @BindView(R.id.divider_3_submit_crosspost_activity) View divider3; + @BindView(R.id.post_title_edit_text_submit_crosspost_activity) + EditText titleEditText; + @BindView(R.id.divider_4_submit_crosspost_activity) + View divider4; @BindView(R.id.post_content_text_view_submit_crosspost_activity) TextView contentTextView; @BindView(R.id.frame_layout_submit_crosspost_activity) @@ -360,6 +370,10 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom isNSFW = false; } }); + + receivePostReplyNotificationsLinearLayout.setOnClickListener(view -> { + receivePostReplyNotificationsSwitchMaterial.performClick(); + }); } @Nullable @@ -390,11 +404,13 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom subredditNameTextView.setTextColor(secondaryTextColor); rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); + primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); + receivePostReplyNotificationsTextView.setTextColor(primaryTextColor); int dividerColor = mCustomThemeWrapper.getDividerColor(); divider1.setBackgroundColor(dividerColor); divider2.setBackgroundColor(dividerColor); divider3.setBackgroundColor(dividerColor); - primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); + divider4.setBackgroundColor(dividerColor); flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor(); flairTextColor = mCustomThemeWrapper.getFlairTextColor(); spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor(); @@ -457,61 +473,62 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - if (isPosting) { - promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail); - return true; - } else { - if (!titleEditText.getText().toString().equals("")) { - promptAlertDialog(R.string.discard, R.string.discard_detail); - return true; - } - } - finish(); + int itemId = item.getItemId(); + if (itemId == android.R.id.home) { + if (isPosting) { + promptAlertDialog(R.string.exit_when_submit, R.string.exit_when_submit_post_detail); return true; - case R.id.action_send_submit_crosspost_activity: - if (!subredditSelected) { - Snackbar.make(coordinatorLayout, 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(); + } else { + if (!titleEditText.getText().toString().equals("")) { + promptAlertDialog(R.string.discard, R.string.discard_detail); return true; } + } + finish(); + return true; + } else if (itemId == R.id.action_send_submit_crosspost_activity) { + if (!subredditSelected) { + Snackbar.make(coordinatorLayout, R.string.select_a_subreddit, Snackbar.LENGTH_SHORT).show(); + return true; + } - isPosting = true; + if (titleEditText.getText() == null || titleEditText.getText().toString().equals("")) { + Snackbar.make(coordinatorLayout, R.string.title_required, Snackbar.LENGTH_SHORT).show(); + return true; + } - item.setEnabled(false); - item.getIcon().setAlpha(130); + isPosting = true; - mPostingSnackbar.show(); + item.setEnabled(false); + item.getIcon().setAlpha(130); - String subredditName; - if (subredditIsUser) { - subredditName = "u_" + subredditNameTextView.getText().toString(); - } else { - subredditName = subredditNameTextView.getText().toString(); - } + mPostingSnackbar.show(); - 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()); - if (post.isCrosspost()) { - intent.putExtra(SubmitPostService.EXTRA_CONTENT, "t3_" + post.getCrosspostParentId()); - } else { - intent.putExtra(SubmitPostService.EXTRA_CONTENT, post.getFullName()); - } - intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_CROSSPOST); - intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair); - intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler); - intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW); - intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TYPE_CROSSPOST); - ContextCompat.startForegroundService(this, intent); + String subredditName; + if (subredditIsUser) { + subredditName = "u_" + subredditNameTextView.getText().toString(); + } else { + subredditName = subredditNameTextView.getText().toString(); + } - return true; + 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()); + if (post.isCrosspost()) { + intent.putExtra(SubmitPostService.EXTRA_CONTENT, "t3_" + post.getCrosspostParentId()); + } else { + intent.putExtra(SubmitPostService.EXTRA_CONTENT, post.getFullName()); + } + intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_CROSSPOST); + 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_TYPE_CROSSPOST); + ContextCompat.startForegroundService(this, intent); + + return true; } return false; @@ -588,7 +605,7 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom } @Subscribe - public void onSubmitTextPostEvent(SubmitCrosspostEvent submitCrosspostEvent) { + public void onSubmitCrosspostEvent(SubmitCrosspostEvent submitCrosspostEvent) { isPosting = false; mPostingSnackbar.dismiss(); if (submitCrosspostEvent.postSuccess) { @@ -597,8 +614,8 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom startActivity(intent); finish(); } else { - mMenu.findItem(R.id.action_send_post_text_activity).setEnabled(true); - mMenu.findItem(R.id.action_send_post_text_activity).getIcon().setAlpha(255); + mMenu.findItem(R.id.action_send_submit_crosspost_activity).setEnabled(true); + mMenu.findItem(R.id.action_send_submit_crosspost_activity).getIcon().setAlpha(255); if (submitCrosspostEvent.errorMessage == null || submitCrosspostEvent.errorMessage.equals("")) { Snackbar.make(coordinatorLayout, R.string.post_failed, Snackbar.LENGTH_SHORT).show(); } else { diff --git a/app/src/main/res/layout/activity_submit_crosspost.xml b/app/src/main/res/layout/activity_submit_crosspost.xml index ec5b1f42..e40cc0b2 100644 --- a/app/src/main/res/layout/activity_submit_crosspost.xml +++ b/app/src/main/res/layout/activity_submit_crosspost.xml @@ -132,6 +132,43 @@ android:layout_width="match_parent" android:layout_height="1dp" /> + <LinearLayout + android:id="@+id/receive_post_reply_notifications_linear_layout_submit_crosspost_activity" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="8dp" + android:paddingBottom="8dp" + 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_submit_crosspost_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.switchmaterial.SwitchMaterial + android:id="@+id/receive_post_reply_notifications_switch_material_submit_crosspost_activity" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:checked="true" /> + + </LinearLayout> + + <View + android:id="@+id/divider_3_submit_crosspost_activity" + android:layout_width="match_parent" + android:layout_height="1dp" /> + <EditText android:id="@+id/post_title_edit_text_submit_crosspost_activity" android:layout_width="match_parent" @@ -146,7 +183,7 @@ android:fontFamily="?attr/title_font_family" /> <View - android:id="@+id/divider_3_submit_crosspost_activity" + android:id="@+id/divider_4_submit_crosspost_activity" android:layout_width="match_parent" android:layout_height="1dp" /> |