mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-27 18:33:56 +01:00
Choose whether receiving post reply notifications or not in PostTextActivity.
This commit is contained in:
parent
e2e7a8cdcd
commit
4363731a81
@ -16,6 +16,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;
|
||||||
|
|
||||||
@ -34,6 +35,7 @@ import com.bumptech.glide.request.RequestOptions;
|
|||||||
import com.google.android.material.appbar.AppBarLayout;
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
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;
|
||||||
@ -97,9 +99,9 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
AppBarLayout appBarLayout;
|
AppBarLayout appBarLayout;
|
||||||
@BindView(R.id.toolbar_post_text_activity)
|
@BindView(R.id.toolbar_post_text_activity)
|
||||||
Toolbar toolbar;
|
Toolbar toolbar;
|
||||||
@BindView(R.id.subreddit_icon_gif_image_view_search_activity)
|
@BindView(R.id.subreddit_icon_gif_image_view_post_text_activity)
|
||||||
GifImageView iconGifImageView;
|
GifImageView iconGifImageView;
|
||||||
@BindView(R.id.subreddit_name_text_view_search_activity)
|
@BindView(R.id.subreddit_name_text_view_post_text_activity)
|
||||||
TextView subredditNameTextView;
|
TextView subredditNameTextView;
|
||||||
@BindView(R.id.rules_button_post_text_activity)
|
@BindView(R.id.rules_button_post_text_activity)
|
||||||
Button rulesButton;
|
Button rulesButton;
|
||||||
@ -113,10 +115,18 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.divider_2_post_text_activity)
|
@BindView(R.id.divider_2_post_text_activity)
|
||||||
View divider2;
|
View divider2;
|
||||||
@BindView(R.id.post_title_edit_text_post_text_activity)
|
@BindView(R.id.receive_post_reply_notifications_linear_layout_post_text_activity)
|
||||||
EditText titleEditText;
|
LinearLayout receivePostReplyNotificationsLinearLayout;
|
||||||
|
@BindView(R.id.receive_post_reply_notifications_text_view_post_text_activity)
|
||||||
|
TextView receivePostReplyNotificationsTextView;
|
||||||
|
@BindView(R.id.receive_post_reply_notifications_switch_material_post_text_activity)
|
||||||
|
SwitchMaterial receivePostReplyNotificationsSwitchMaterial;
|
||||||
@BindView(R.id.divider_3_post_text_activity)
|
@BindView(R.id.divider_3_post_text_activity)
|
||||||
View divider3;
|
View divider3;
|
||||||
|
@BindView(R.id.post_title_edit_text_post_text_activity)
|
||||||
|
EditText titleEditText;
|
||||||
|
@BindView(R.id.divider_4_post_text_activity)
|
||||||
|
View divider4;
|
||||||
@BindView(R.id.post_text_content_edit_text_post_text_activity)
|
@BindView(R.id.post_text_content_edit_text_post_text_activity)
|
||||||
EditText contentEditText;
|
EditText contentEditText;
|
||||||
@BindView(R.id.markdown_bottom_bar_recycler_view_post_text_activity)
|
@BindView(R.id.markdown_bottom_bar_recycler_view_post_text_activity)
|
||||||
@ -333,6 +343,10 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
receivePostReplyNotificationsLinearLayout.setOnClickListener(view -> {
|
||||||
|
receivePostReplyNotificationsSwitchMaterial.performClick();
|
||||||
|
});
|
||||||
|
|
||||||
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
|
MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(
|
||||||
mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
|
mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -376,11 +390,13 @@ public class PostTextActivity 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();
|
||||||
@ -423,9 +439,9 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
|
|||||||
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
new MaterialAlertDialogBuilder(this, R.style.MaterialAlertDialogTheme)
|
||||||
.setTitle(titleResId)
|
.setTitle(titleResId)
|
||||||
.setMessage(messageResId)
|
.setMessage(messageResId)
|
||||||
.setPositiveButton(R.string.yes, (dialogInterface, i)
|
.setPositiveButton(R.string.discard, (dialogInterface, i)
|
||||||
-> finish())
|
-> finish())
|
||||||
.setNegativeButton(R.string.no, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,6 +510,7 @@ public class PostTextActivity 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);
|
||||||
|
|
||||||
|
@ -13,7 +13,6 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
|
||||||
@ -31,22 +30,24 @@ import retrofit2.Retrofit;
|
|||||||
|
|
||||||
public class SubmitPost {
|
public class SubmitPost {
|
||||||
public static void submitTextOrLinkPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
public static void submitTextOrLinkPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
||||||
Locale locale, String subredditName, String title, String content,
|
String subredditName, String title, String content,
|
||||||
Flair flair, boolean isSpoiler, boolean isNSFW, String kind,
|
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||||
|
boolean receivePostReplyNotifications, String kind,
|
||||||
SubmitPostListener submitPostListener) {
|
SubmitPostListener submitPostListener) {
|
||||||
submitPost(executor, handler, oauthRetrofit, accessToken, subredditName, title, content,
|
submitPost(executor, handler, oauthRetrofit, accessToken, subredditName, title, content,
|
||||||
flair, isSpoiler, isNSFW, kind, null, submitPostListener);
|
flair, isSpoiler, isNSFW, receivePostReplyNotifications, kind, null, submitPostListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void submitImagePost(Executor executor, Handler handler, Retrofit oauthRetrofit, Retrofit uploadMediaRetrofit,
|
public static void submitImagePost(Executor executor, Handler handler, Retrofit oauthRetrofit, Retrofit uploadMediaRetrofit,
|
||||||
String accessToken, String subredditName, String title, Bitmap image,
|
String accessToken, String subredditName, String title, Bitmap image,
|
||||||
Flair flair, boolean isSpoiler, boolean isNSFW, SubmitPostListener submitPostListener) {
|
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||||
|
boolean receivePostReplyNotifications, SubmitPostListener submitPostListener) {
|
||||||
try {
|
try {
|
||||||
String imageUrlOrError = UploadImageUtils.uploadImage(oauthRetrofit, uploadMediaRetrofit, accessToken, image);
|
String imageUrlOrError = UploadImageUtils.uploadImage(oauthRetrofit, uploadMediaRetrofit, accessToken, image);
|
||||||
if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) {
|
if (imageUrlOrError != null && !imageUrlOrError.startsWith("Error: ")) {
|
||||||
submitPost(executor, handler, oauthRetrofit, accessToken,
|
submitPost(executor, handler, oauthRetrofit, accessToken,
|
||||||
subredditName, title, imageUrlOrError, flair, isSpoiler, isNSFW,
|
subredditName, title, imageUrlOrError, flair, isSpoiler, isNSFW,
|
||||||
APIUtils.KIND_IMAGE, null, submitPostListener);
|
receivePostReplyNotifications, APIUtils.KIND_IMAGE, null, submitPostListener);
|
||||||
} else {
|
} else {
|
||||||
submitPostListener.submitFailed(imageUrlOrError);
|
submitPostListener.submitFailed(imageUrlOrError);
|
||||||
}
|
}
|
||||||
@ -60,7 +61,7 @@ public class SubmitPost {
|
|||||||
Retrofit uploadVideoRetrofit, String accessToken,
|
Retrofit uploadVideoRetrofit, String accessToken,
|
||||||
String subredditName, String title, File buffer, String mimeType,
|
String subredditName, String title, File buffer, String mimeType,
|
||||||
Bitmap posterBitmap, Flair flair, boolean isSpoiler, boolean isNSFW,
|
Bitmap posterBitmap, Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||||
SubmitPostListener submitPostListener) {
|
boolean receivePostReplyNotifications, SubmitPostListener submitPostListener) {
|
||||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
String fileType = mimeType.substring(mimeType.indexOf("/") + 1);
|
String fileType = mimeType.substring(mimeType.indexOf("/") + 1);
|
||||||
@ -97,11 +98,13 @@ public class SubmitPost {
|
|||||||
if (fileType.equals("gif")) {
|
if (fileType.equals("gif")) {
|
||||||
submitPost(executor, handler, oauthRetrofit, accessToken,
|
submitPost(executor, handler, oauthRetrofit, accessToken,
|
||||||
subredditName, title, url, flair, isSpoiler, isNSFW,
|
subredditName, title, url, flair, isSpoiler, isNSFW,
|
||||||
APIUtils.KIND_VIDEOGIF, imageUrlOrError, submitPostListener);
|
receivePostReplyNotifications, APIUtils.KIND_VIDEOGIF, imageUrlOrError,
|
||||||
|
submitPostListener);
|
||||||
} else {
|
} else {
|
||||||
submitPost(executor, handler, oauthRetrofit, accessToken,
|
submitPost(executor, handler, oauthRetrofit, accessToken,
|
||||||
subredditName, title, url, flair, isSpoiler, isNSFW,
|
subredditName, title, url, flair, isSpoiler, isNSFW,
|
||||||
APIUtils.KIND_VIDEO, imageUrlOrError, submitPostListener);
|
receivePostReplyNotifications, APIUtils.KIND_VIDEO, imageUrlOrError,
|
||||||
|
submitPostListener);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
submitPostListener.submitFailed(imageUrlOrError);
|
submitPostListener.submitFailed(imageUrlOrError);
|
||||||
@ -120,15 +123,17 @@ public class SubmitPost {
|
|||||||
|
|
||||||
public static void submitCrosspost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
public static void submitCrosspost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
||||||
String subredditName, String title, String crosspostFullname,
|
String subredditName, String title, String crosspostFullname,
|
||||||
Flair flair, boolean isSpoiler, boolean isNSFW, String kind,
|
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||||
|
boolean receivePostReplyNotifications, String kind,
|
||||||
SubmitPostListener submitPostListener) {
|
SubmitPostListener submitPostListener) {
|
||||||
submitPost(executor, handler, oauthRetrofit, accessToken, subredditName, title, crosspostFullname,
|
submitPost(executor, handler, oauthRetrofit, accessToken, subredditName, title, crosspostFullname,
|
||||||
flair, isSpoiler, isNSFW, kind, null, submitPostListener);
|
flair, isSpoiler, isNSFW, receivePostReplyNotifications, kind, null, submitPostListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void submitPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
private static void submitPost(Executor executor, Handler handler, Retrofit oauthRetrofit, String accessToken,
|
||||||
String subredditName, String title, String content,
|
String subredditName, String title, String content,
|
||||||
Flair flair, boolean isSpoiler, boolean isNSFW, String kind,
|
Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||||
|
boolean receivePostReplyNotifications, String kind,
|
||||||
@Nullable String posterUrl, SubmitPostListener submitPostListener) {
|
@Nullable String posterUrl, SubmitPostListener submitPostListener) {
|
||||||
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
RedditAPI api = oauthRetrofit.create(RedditAPI.class);
|
||||||
|
|
||||||
@ -165,6 +170,7 @@ public class SubmitPost {
|
|||||||
}
|
}
|
||||||
params.put(APIUtils.SPOILER_KEY, Boolean.toString(isSpoiler));
|
params.put(APIUtils.SPOILER_KEY, Boolean.toString(isSpoiler));
|
||||||
params.put(APIUtils.NSFW_KEY, Boolean.toString(isNSFW));
|
params.put(APIUtils.NSFW_KEY, Boolean.toString(isNSFW));
|
||||||
|
params.put(APIUtils.SEND_REPLIES_KEY, Boolean.toString(receivePostReplyNotifications));
|
||||||
|
|
||||||
Call<String> submitPostCall = api.submit(APIUtils.getOAuthHeader(accessToken), params);
|
Call<String> submitPostCall = api.submit(APIUtils.getOAuthHeader(accessToken), params);
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ public class SubmitPostService extends Service {
|
|||||||
public static final String EXTRA_FLAIR = "EF";
|
public static final String EXTRA_FLAIR = "EF";
|
||||||
public static final String EXTRA_IS_SPOILER = "EIS";
|
public static final String EXTRA_IS_SPOILER = "EIS";
|
||||||
public static final String EXTRA_IS_NSFW = "EIN";
|
public static final String EXTRA_IS_NSFW = "EIN";
|
||||||
|
public static final String EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS = "ERPRN";
|
||||||
public static final String EXTRA_POST_TYPE = "EPT";
|
public static final String EXTRA_POST_TYPE = "EPT";
|
||||||
public static final int EXTRA_POST_TEXT_OR_LINK = 0;
|
public static final int EXTRA_POST_TEXT_OR_LINK = 0;
|
||||||
public static final int EXTRA_POST_TYPE_IMAGE = 1;
|
public static final int EXTRA_POST_TYPE_IMAGE = 1;
|
||||||
@ -107,22 +108,26 @@ public class SubmitPostService extends Service {
|
|||||||
Flair flair = bundle.getParcelable(EXTRA_FLAIR);
|
Flair flair = bundle.getParcelable(EXTRA_FLAIR);
|
||||||
boolean isSpoiler = bundle.getBoolean(EXTRA_IS_SPOILER, false);
|
boolean isSpoiler = bundle.getBoolean(EXTRA_IS_SPOILER, false);
|
||||||
boolean isNSFW = bundle.getBoolean(EXTRA_IS_NSFW, false);
|
boolean isNSFW = bundle.getBoolean(EXTRA_IS_NSFW, false);
|
||||||
|
boolean receivePostReplyNotifications = bundle.getBoolean(EXTRA_RECEIVE_POST_REPLY_NOTIFICATIONS, true);
|
||||||
int postType = bundle.getInt(EXTRA_POST_TYPE, EXTRA_POST_TEXT_OR_LINK);
|
int postType = bundle.getInt(EXTRA_POST_TYPE, EXTRA_POST_TEXT_OR_LINK);
|
||||||
|
|
||||||
if (postType == EXTRA_POST_TEXT_OR_LINK) {
|
if (postType == EXTRA_POST_TEXT_OR_LINK) {
|
||||||
String content = bundle.getString(EXTRA_CONTENT);
|
String content = bundle.getString(EXTRA_CONTENT);
|
||||||
String kind = bundle.getString(EXTRA_KIND);
|
String kind = bundle.getString(EXTRA_KIND);
|
||||||
submitTextOrLinkPost(accessToken, subredditName, title, content, flair, isSpoiler, isNSFW, kind);
|
submitTextOrLinkPost(accessToken, subredditName, title, content, flair, isSpoiler, isNSFW,
|
||||||
|
receivePostReplyNotifications, kind);
|
||||||
} else if (postType == EXTRA_POST_TYPE_CROSSPOST) {
|
} else if (postType == EXTRA_POST_TYPE_CROSSPOST) {
|
||||||
String content = bundle.getString(EXTRA_CONTENT);
|
String content = bundle.getString(EXTRA_CONTENT);
|
||||||
submitCrosspost(mExecutor, handler, accessToken, subredditName, title, content,
|
submitCrosspost(mExecutor, handler, accessToken, subredditName, title, content,
|
||||||
flair, isSpoiler, isNSFW);
|
flair, isSpoiler, isNSFW, receivePostReplyNotifications);
|
||||||
} else if (postType == EXTRA_POST_TYPE_IMAGE) {
|
} else if (postType == EXTRA_POST_TYPE_IMAGE) {
|
||||||
Uri mediaUri = Uri.parse(bundle.getString(EXTRA_MEDIA_URI));
|
Uri mediaUri = Uri.parse(bundle.getString(EXTRA_MEDIA_URI));
|
||||||
submitImagePost(accessToken, mediaUri, subredditName, title, flair, isSpoiler, isNSFW);
|
submitImagePost(accessToken, mediaUri, subredditName, title, flair, isSpoiler, isNSFW,
|
||||||
|
receivePostReplyNotifications);
|
||||||
} else {
|
} else {
|
||||||
Uri mediaUri = Uri.parse(bundle.getString(EXTRA_MEDIA_URI));
|
Uri mediaUri = Uri.parse(bundle.getString(EXTRA_MEDIA_URI));
|
||||||
submitVideoPost(accessToken, mediaUri, subredditName, title, flair, isSpoiler, isNSFW);
|
submitVideoPost(accessToken, mediaUri, subredditName, title, flair, isSpoiler, isNSFW,
|
||||||
|
receivePostReplyNotifications);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,10 +195,12 @@ public class SubmitPostService extends Service {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submitTextOrLinkPost(String accessToken, String subredditName, String title, String content, Flair flair, boolean isSpoiler, boolean isNSFW, String kind) {
|
private void submitTextOrLinkPost(String accessToken, String subredditName, String title, String content,
|
||||||
|
Flair flair, boolean isSpoiler, boolean isNSFW, boolean receivePostReplyNotifications,
|
||||||
|
String kind) {
|
||||||
SubmitPost.submitTextOrLinkPost(mExecutor, handler, mOauthRetrofit, accessToken,
|
SubmitPost.submitTextOrLinkPost(mExecutor, handler, mOauthRetrofit, accessToken,
|
||||||
getResources().getConfiguration().locale, subredditName, title, content, flair, isSpoiler,
|
subredditName, title, content, flair, isSpoiler,
|
||||||
isNSFW, kind, new SubmitPost.SubmitPostListener() {
|
isNSFW, receivePostReplyNotifications, kind, new SubmitPost.SubmitPostListener() {
|
||||||
@Override
|
@Override
|
||||||
public void submitSuccessful(Post post) {
|
public void submitSuccessful(Post post) {
|
||||||
handler.post(() -> EventBus.getDefault().post(new SubmitTextOrLinkPostEvent(true, post, null)));
|
handler.post(() -> EventBus.getDefault().post(new SubmitTextOrLinkPostEvent(true, post, null)));
|
||||||
@ -211,9 +218,11 @@ public class SubmitPostService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void submitCrosspost(Executor executor, Handler handler, String accessToken, String subredditName,
|
private void submitCrosspost(Executor executor, Handler handler, String accessToken, String subredditName,
|
||||||
String title, String content, Flair flair, boolean isSpoiler, boolean isNSFW) {
|
String title, String content, Flair flair, boolean isSpoiler, boolean isNSFW,
|
||||||
|
boolean receivePostReplyNotifications) {
|
||||||
SubmitPost.submitCrosspost(executor, handler, mOauthRetrofit, accessToken, subredditName, title,
|
SubmitPost.submitCrosspost(executor, handler, mOauthRetrofit, accessToken, subredditName, title,
|
||||||
content, flair, isSpoiler, isNSFW, APIUtils.KIND_CROSSPOST, new SubmitPost.SubmitPostListener() {
|
content, flair, isSpoiler, isNSFW, receivePostReplyNotifications, APIUtils.KIND_CROSSPOST,
|
||||||
|
new SubmitPost.SubmitPostListener() {
|
||||||
@Override
|
@Override
|
||||||
public void submitSuccessful(Post post) {
|
public void submitSuccessful(Post post) {
|
||||||
handler.post(() -> EventBus.getDefault().post(new SubmitCrosspostEvent(true, post, null)));
|
handler.post(() -> EventBus.getDefault().post(new SubmitCrosspostEvent(true, post, null)));
|
||||||
@ -230,11 +239,12 @@ public class SubmitPostService extends Service {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void submitImagePost(String accessToken, Uri mediaUri, String subredditName, String title, Flair flair, boolean isSpoiler, boolean isNSFW) {
|
private void submitImagePost(String accessToken, Uri mediaUri, String subredditName, String title,
|
||||||
|
Flair flair, boolean isSpoiler, boolean isNSFW, boolean receivePostReplyNotifications) {
|
||||||
try {
|
try {
|
||||||
Bitmap resource = Glide.with(this).asBitmap().load(mediaUri).submit().get();
|
Bitmap resource = Glide.with(this).asBitmap().load(mediaUri).submit().get();
|
||||||
SubmitPost.submitImagePost(mExecutor, handler, mOauthRetrofit, mUploadMediaRetrofit,
|
SubmitPost.submitImagePost(mExecutor, handler, mOauthRetrofit, mUploadMediaRetrofit,
|
||||||
accessToken, subredditName, title, resource, flair, isSpoiler, isNSFW,
|
accessToken, subredditName, title, resource, flair, isSpoiler, isNSFW, receivePostReplyNotifications,
|
||||||
new SubmitPost.SubmitPostListener() {
|
new SubmitPost.SubmitPostListener() {
|
||||||
@Override
|
@Override
|
||||||
public void submitSuccessful(Post post) {
|
public void submitSuccessful(Post post) {
|
||||||
@ -261,7 +271,7 @@ public class SubmitPostService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void submitVideoPost(String accessToken, Uri mediaUri, String subredditName, String title,
|
private void submitVideoPost(String accessToken, Uri mediaUri, String subredditName, String title,
|
||||||
Flair flair, boolean isSpoiler, boolean isNSFW) {
|
Flair flair, boolean isSpoiler, boolean isNSFW, boolean receivePostReplyNotifications) {
|
||||||
try {
|
try {
|
||||||
InputStream in = getContentResolver().openInputStream(mediaUri);
|
InputStream in = getContentResolver().openInputStream(mediaUri);
|
||||||
String type = getContentResolver().getType(mediaUri);
|
String type = getContentResolver().getType(mediaUri);
|
||||||
@ -279,7 +289,8 @@ public class SubmitPostService extends Service {
|
|||||||
if (type != null) {
|
if (type != null) {
|
||||||
SubmitPost.submitVideoPost(mExecutor, handler, mOauthRetrofit, mUploadMediaRetrofit,
|
SubmitPost.submitVideoPost(mExecutor, handler, mOauthRetrofit, mUploadMediaRetrofit,
|
||||||
mUploadVideoRetrofit, accessToken, subredditName, title, new File(cacheFilePath),
|
mUploadVideoRetrofit, accessToken, subredditName, title, new File(cacheFilePath),
|
||||||
type, resource, flair, isSpoiler, isNSFW, new SubmitPost.SubmitPostListener() {
|
type, resource, flair, isSpoiler, isNSFW, receivePostReplyNotifications,
|
||||||
|
new SubmitPost.SubmitPostListener() {
|
||||||
@Override
|
@Override
|
||||||
public void submitSuccessful(Post post) {
|
public void submitSuccessful(Post post) {
|
||||||
handler.post(() -> {
|
handler.post(() -> {
|
||||||
|
@ -73,6 +73,7 @@ public class APIUtils {
|
|||||||
public static final String SPOILER_KEY = "spoiler";
|
public static final String SPOILER_KEY = "spoiler";
|
||||||
public static final String NSFW_KEY = "nsfw";
|
public static final String NSFW_KEY = "nsfw";
|
||||||
public static final String CROSSPOST_FULLNAME_KEY = "crosspost_fullname";
|
public static final String CROSSPOST_FULLNAME_KEY = "crosspost_fullname";
|
||||||
|
public static final String SEND_REPLIES_KEY = "sendreplies";
|
||||||
public static final String KIND_KEY = "kind";
|
public static final String KIND_KEY = "kind";
|
||||||
public static final String KIND_SELF = "self";
|
public static final String KIND_SELF = "self";
|
||||||
public static final String KIND_LINK = "link";
|
public static final String KIND_LINK = "link";
|
||||||
|
@ -48,21 +48,21 @@
|
|||||||
android:paddingBottom="8dp">
|
android:paddingBottom="8dp">
|
||||||
|
|
||||||
<pl.droidsonroids.gif.GifImageView
|
<pl.droidsonroids.gif.GifImageView
|
||||||
android:id="@+id/subreddit_icon_gif_image_view_search_activity"
|
android:id="@+id/subreddit_icon_gif_image_view_post_text_activity"
|
||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_centerVertical="true" />
|
android:layout_centerVertical="true" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/subreddit_name_text_view_search_activity"
|
android:id="@+id/subreddit_name_text_view_post_text_activity"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginStart="32dp"
|
android:layout_marginStart="32dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:layout_toStartOf="@id/rules_button_post_text_activity"
|
android:layout_toStartOf="@id/rules_button_post_text_activity"
|
||||||
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_search_activity"
|
android:layout_toEndOf="@id/subreddit_icon_gif_image_view_post_text_activity"
|
||||||
android:text="@string/choose_a_subreddit"
|
android:text="@string/choose_a_subreddit"
|
||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_default"
|
||||||
android:fontFamily="?attr/font_family" />
|
android:fontFamily="?attr/font_family" />
|
||||||
@ -95,7 +95,6 @@
|
|||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:padding="4dp"
|
android:padding="4dp"
|
||||||
android:text="@string/flair"
|
android:text="@string/flair"
|
||||||
android:textColor="?attr/primaryTextColor"
|
|
||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_default"
|
||||||
android:fontFamily="?attr/font_family"
|
android:fontFamily="?attr/font_family"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
@ -110,7 +109,6 @@
|
|||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:padding="4dp"
|
android:padding="4dp"
|
||||||
android:text="@string/spoiler"
|
android:text="@string/spoiler"
|
||||||
android:textColor="?attr/primaryTextColor"
|
|
||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_default"
|
||||||
android:fontFamily="?attr/font_family"
|
android:fontFamily="?attr/font_family"
|
||||||
app:lib_setRadius="3dp"
|
app:lib_setRadius="3dp"
|
||||||
@ -124,7 +122,6 @@
|
|||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:padding="4dp"
|
android:padding="4dp"
|
||||||
android:text="@string/nsfw"
|
android:text="@string/nsfw"
|
||||||
android:textColor="?attr/primaryTextColor"
|
|
||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_default"
|
||||||
android:fontFamily="?attr/font_family"
|
android:fontFamily="?attr/font_family"
|
||||||
app:lib_setRadius="3dp"
|
app:lib_setRadius="3dp"
|
||||||
@ -138,6 +135,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_text_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_text_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_text_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_text_activity"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/post_title_edit_text_post_text_activity"
|
android:id="@+id/post_title_edit_text_post_text_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -147,12 +181,11 @@
|
|||||||
android:hint="@string/post_title_hint"
|
android:hint="@string/post_title_hint"
|
||||||
android:inputType="textCapSentences|textMultiLine"
|
android:inputType="textCapSentences|textMultiLine"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:textColor="?attr/primaryTextColor"
|
|
||||||
android:textSize="?attr/title_font_18"
|
android:textSize="?attr/title_font_18"
|
||||||
android:fontFamily="?attr/title_font_family" />
|
android:fontFamily="?attr/title_font_family" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/divider_3_post_text_activity"
|
android:id="@+id/divider_4_post_text_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp" />
|
android:layout_height="1dp" />
|
||||||
|
|
||||||
@ -165,7 +198,6 @@
|
|||||||
android:hint="@string/post_text_content_hint"
|
android:hint="@string/post_text_content_hint"
|
||||||
android:inputType="textCapSentences|textMultiLine"
|
android:inputType="textCapSentences|textMultiLine"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:textColor="?attr/primaryTextColor"
|
|
||||||
android:textSize="?attr/content_font_18"
|
android:textSize="?attr/content_font_18"
|
||||||
android:fontFamily="?attr/content_font_family" />
|
android:fontFamily="?attr/content_font_family" />
|
||||||
|
|
||||||
|
@ -205,6 +205,7 @@
|
|||||||
<string name="choose_a_subreddit">Choose a subreddit</string>
|
<string name="choose_a_subreddit">Choose a subreddit</string>
|
||||||
<string name="rules">Rules</string>
|
<string name="rules">Rules</string>
|
||||||
<string name="post_link_hint">URL</string>
|
<string name="post_link_hint">URL</string>
|
||||||
|
<string name="receive_post_reply_notifications">Receive post reply notifications</string>
|
||||||
|
|
||||||
<string name="subreddits">Subreddits</string>
|
<string name="subreddits">Subreddits</string>
|
||||||
<string name="users">Users</string>
|
<string name="users">Users</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user