Choose whether receiving post reply notifications or not in PostLinkActivity.

This commit is contained in:
Alex Ning 2021-07-14 22:26:28 +08:00
parent 4363731a81
commit d31d348788
3 changed files with 59 additions and 5 deletions

View File

@ -12,6 +12,7 @@ import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@ -28,6 +29,7 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.button.MaterialButton; import com.google.android.material.button.MaterialButton;
import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar; import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.switchmaterial.SwitchMaterial;
import com.libRG.CustomTextView; import com.libRG.CustomTextView;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@ -94,14 +96,22 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
View divider1; View divider1;
@BindView(R.id.divider_2_post_link_activity) @BindView(R.id.divider_2_post_link_activity)
View divider2; View divider2;
@BindView(R.id.divider_3_post_link_activity) @BindView(R.id.divider_4_post_link_activity)
View divider3; View divider4;
@BindView(R.id.flair_custom_text_view_post_link_activity) @BindView(R.id.flair_custom_text_view_post_link_activity)
CustomTextView flairTextView; CustomTextView flairTextView;
@BindView(R.id.spoiler_custom_text_view_post_link_activity) @BindView(R.id.spoiler_custom_text_view_post_link_activity)
CustomTextView spoilerTextView; CustomTextView spoilerTextView;
@BindView(R.id.nsfw_custom_text_view_post_link_activity) @BindView(R.id.nsfw_custom_text_view_post_link_activity)
CustomTextView nsfwTextView; CustomTextView nsfwTextView;
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_link_activity)
LinearLayout receivePostReplyNotificationsLinearLayout;
@BindView(R.id.receive_post_reply_notifications_text_view_post_link_activity)
TextView receivePostReplyNotificationsTextView;
@BindView(R.id.receive_post_reply_notifications_switch_material_post_link_activity)
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
@BindView(R.id.divider_3_post_link_activity)
View divider3;
@BindView(R.id.post_title_edit_text_post_link_activity) @BindView(R.id.post_title_edit_text_post_link_activity)
EditText titleEditText; EditText titleEditText;
@BindView(R.id.suggest_title_button_post_link_activity) @BindView(R.id.suggest_title_button_post_link_activity)
@ -310,6 +320,10 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
} }
}); });
receivePostReplyNotificationsLinearLayout.setOnClickListener(view -> {
receivePostReplyNotificationsSwitchMaterial.performClick();
});
suggestTitleButton.setOnClickListener(view -> { suggestTitleButton.setOnClickListener(view -> {
Toast.makeText(this, R.string.please_wait, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.please_wait, Toast.LENGTH_SHORT).show();
String url = linkEditText.getText().toString().trim(); String url = linkEditText.getText().toString().trim();
@ -355,11 +369,13 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
subredditNameTextView.setTextColor(secondaryTextColor); subredditNameTextView.setTextColor(secondaryTextColor);
rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor()); rulesButton.setTextColor(mCustomThemeWrapper.getButtonTextColor());
rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme())); rulesButton.setBackgroundTintList(ColorStateList.valueOf(mCustomThemeWrapper.getColorPrimaryLightTheme()));
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
receivePostReplyNotificationsTextView.setTextColor(primaryTextColor);
int dividerColor = mCustomThemeWrapper.getDividerColor(); int dividerColor = mCustomThemeWrapper.getDividerColor();
divider1.setBackgroundColor(dividerColor); divider1.setBackgroundColor(dividerColor);
divider2.setBackgroundColor(dividerColor); divider2.setBackgroundColor(dividerColor);
divider3.setBackgroundColor(dividerColor); divider3.setBackgroundColor(dividerColor);
primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor(); divider4.setBackgroundColor(dividerColor);
flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor(); flairBackgroundColor = mCustomThemeWrapper.getFlairBackgroundColor();
flairTextColor = mCustomThemeWrapper.getFlairTextColor(); flairTextColor = mCustomThemeWrapper.getFlairTextColor();
spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor(); spoilerBackgroundColor = mCustomThemeWrapper.getSpoilerBackgroundColor();
@ -475,6 +491,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair); intent.putExtra(SubmitPostService.EXTRA_FLAIR, flair);
intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler); intent.putExtra(SubmitPostService.EXTRA_IS_SPOILER, isSpoiler);
intent.putExtra(SubmitPostService.EXTRA_IS_NSFW, isNSFW); 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); intent.putExtra(SubmitPostService.EXTRA_POST_TYPE, SubmitPostService.EXTRA_POST_TEXT_OR_LINK);
ContextCompat.startForegroundService(this, intent); ContextCompat.startForegroundService(this, intent);

View File

@ -132,6 +132,43 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" /> android:layout_height="1dp" />
<LinearLayout
android:id="@+id/receive_post_reply_notifications_linear_layout_post_link_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_post_link_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_post_link_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_post_link_activity"
android:layout_width="match_parent"
android:layout_height="1dp" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -163,7 +200,7 @@
</LinearLayout> </LinearLayout>
<View <View
android:id="@+id/divider_3_post_link_activity" android:id="@+id/divider_4_post_link_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="1dp" /> android:layout_height="1dp" />

View File

@ -285,7 +285,7 @@
<string name="posting_video">Posting Video</string> <string name="posting_video">Posting Video</string>
<string name="posting_image">Posting Image</string> <string name="posting_image">Posting Image</string>
<string name="please_wait">Please wait.</string> <string name="please_wait">Please wait</string>
<string name="add_account">Add account</string> <string name="add_account">Add account</string>
<string name="anonymous_account">Anonymous</string> <string name="anonymous_account">Anonymous</string>