mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-12 19:27:12 +01:00
parent
55f4689984
commit
e5ffaf3d97
@ -112,8 +112,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
View divider1;
|
View divider1;
|
||||||
@BindView(R.id.flair_custom_text_view_submit_crosspost_activity)
|
@BindView(R.id.flair_custom_text_view_submit_crosspost_activity)
|
||||||
CustomTextView flairTextView;
|
CustomTextView flairTextView;
|
||||||
@BindView(R.id.spoiler_custom_text_view_submit_crosspost_activity)
|
|
||||||
CustomTextView spoilerTextView;
|
|
||||||
@BindView(R.id.nsfw_custom_text_view_submit_crosspost_activity)
|
@BindView(R.id.nsfw_custom_text_view_submit_crosspost_activity)
|
||||||
CustomTextView nsfwTextView;
|
CustomTextView nsfwTextView;
|
||||||
@BindView(R.id.divider_2_submit_crosspost_activity)
|
@BindView(R.id.divider_2_submit_crosspost_activity)
|
||||||
@ -259,11 +257,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
flairTextView.setBorderColor(flairBackgroundColor);
|
flairTextView.setBorderColor(flairBackgroundColor);
|
||||||
flairTextView.setTextColor(flairTextColor);
|
flairTextView.setTextColor(flairTextColor);
|
||||||
}
|
}
|
||||||
if (isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
}
|
|
||||||
if (isNSFW) {
|
if (isNSFW) {
|
||||||
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
nsfwTextView.setBackgroundColor(nsfwBackgroundColor);
|
||||||
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
nsfwTextView.setBorderColor(nsfwBackgroundColor);
|
||||||
@ -287,13 +280,14 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
titleEditText.setText(post.getTitle());
|
titleEditText.setText(post.getTitle());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (post.getPostType() == Post.TEXT_TYPE) {
|
if (post.getPostType() == Post.TEXT_TYPE || post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
||||||
contentTextView.setVisibility(View.VISIBLE);
|
contentTextView.setVisibility(View.VISIBLE);
|
||||||
contentTextView.setText(post.getSelfTextPlain());
|
contentTextView.setText(generateCrossPostText(post));
|
||||||
} else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
|
||||||
contentTextView.setVisibility(View.VISIBLE);
|
|
||||||
contentTextView.setText(post.getUrl());
|
|
||||||
} else {
|
} else {
|
||||||
|
if (post.getSelfTextPlain() != null && !post.getSelfTextPlain().equals("")) {
|
||||||
|
contentTextView.setVisibility(View.VISIBLE);
|
||||||
|
contentTextView.setText(generateCrossPostText(post));
|
||||||
|
}
|
||||||
Post.Preview preview = getPreview(post);
|
Post.Preview preview = getPreview(post);
|
||||||
if (preview != null) {
|
if (preview != null) {
|
||||||
frameLayout.setVisibility(View.VISIBLE);
|
frameLayout.setVisibility(View.VISIBLE);
|
||||||
@ -368,18 +362,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
spoilerTextView.setOnClickListener(view -> {
|
|
||||||
if (!isSpoiler) {
|
|
||||||
spoilerTextView.setBackgroundColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setBorderColor(spoilerBackgroundColor);
|
|
||||||
spoilerTextView.setTextColor(spoilerTextColor);
|
|
||||||
isSpoiler = true;
|
|
||||||
} else {
|
|
||||||
spoilerTextView.setBackgroundColor(resources.getColor(android.R.color.transparent));
|
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
isSpoiler = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
nsfwTextView.setOnClickListener(view -> {
|
nsfwTextView.setOnClickListener(view -> {
|
||||||
if (!isNSFW) {
|
if (!isNSFW) {
|
||||||
@ -461,7 +443,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
nsfwBackgroundColor = mCustomThemeWrapper.getNsfwBackgroundColor();
|
||||||
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
nsfwTextColor = mCustomThemeWrapper.getNsfwTextColor();
|
||||||
flairTextView.setTextColor(primaryTextColor);
|
flairTextView.setTextColor(primaryTextColor);
|
||||||
spoilerTextView.setTextColor(primaryTextColor);
|
|
||||||
nsfwTextView.setTextColor(primaryTextColor);
|
nsfwTextView.setTextColor(primaryTextColor);
|
||||||
titleEditText.setTextColor(primaryTextColor);
|
titleEditText.setTextColor(primaryTextColor);
|
||||||
titleEditText.setHintTextColor(secondaryTextColor);
|
titleEditText.setHintTextColor(secondaryTextColor);
|
||||||
@ -474,7 +455,6 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
rulesButton.setTypeface(typeface);
|
rulesButton.setTypeface(typeface);
|
||||||
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
receivePostReplyNotificationsTextView.setTypeface(typeface);
|
||||||
flairTextView.setTypeface(typeface);
|
flairTextView.setTypeface(typeface);
|
||||||
spoilerTextView.setTypeface(typeface);
|
|
||||||
nsfwTextView.setTypeface(typeface);
|
nsfwTextView.setTypeface(typeface);
|
||||||
titleEditText.setTypeface(typeface);
|
titleEditText.setTypeface(typeface);
|
||||||
}
|
}
|
||||||
@ -561,22 +541,19 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
|
|
||||||
mPostingSnackbar.show();
|
mPostingSnackbar.show();
|
||||||
|
|
||||||
String subredditName;
|
String subredditName = subredditNameTextView.getText().toString();
|
||||||
if (subredditIsUser) {
|
|
||||||
subredditName = "u_" + subredditNameTextView.getText().toString();
|
|
||||||
} else {
|
|
||||||
subredditName = subredditNameTextView.getText().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent intent = new Intent(this, SubmitPostService.class);
|
Intent intent = new Intent(this, SubmitPostService.class);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
intent.putExtra(SubmitPostService.EXTRA_ACCOUNT, selectedAccount);
|
||||||
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
intent.putExtra(SubmitPostService.EXTRA_SUBREDDIT_NAME, communityData.getId());
|
||||||
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
intent.putExtra(SubmitPostService.EXTRA_TITLE, titleEditText.getText().toString());
|
||||||
if (post.isCrosspost()) {
|
|
||||||
intent.putExtra(SubmitPostService.EXTRA_BODY, "t3_" + post.getCrosspostParentId());
|
intent.putExtra(SubmitPostService.EXTRA_BODY, generateCrossPostText(post));
|
||||||
} else {
|
if (post.getUrl() != null && !post.getUrl().equals("")) {
|
||||||
intent.putExtra(SubmitPostService.EXTRA_BODY, post.getFullName());
|
intent.putExtra(SubmitPostService.EXTRA_URL, post.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_CROSSPOST);
|
intent.putExtra(SubmitPostService.EXTRA_KIND, APIUtils.KIND_CROSSPOST);
|
||||||
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);
|
||||||
@ -699,4 +676,15 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String generateCrossPostText(Post post) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append("cross-posted from: ").append(post.getPermalink()).append("\n");
|
||||||
|
String[] lines = post.getSelfTextPlain().split("\n");
|
||||||
|
for (String line : lines) {
|
||||||
|
stringBuilder.append("> ").append(line).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
}
|
}
|
@ -55,11 +55,11 @@ 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,
|
||||||
int communityId, String title, String crosspostFullname,
|
int communityId, String title, String crosspostFullname,
|
||||||
Flair flair, boolean isSpoiler, boolean isNSFW,
|
String url, boolean isSpoiler, boolean isNSFW,
|
||||||
boolean receivePostReplyNotifications, String kind, PostEnricher postEnricher,
|
boolean receivePostReplyNotifications, String kind, PostEnricher postEnricher,
|
||||||
SubmitPostListener submitPostListener) {
|
SubmitPostListener submitPostListener) {
|
||||||
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, crosspostFullname,
|
submitPost(executor, handler, oauthRetrofit, accessToken, communityId, title, crosspostFullname,
|
||||||
isNSFW, receivePostReplyNotifications, kind, null, postEnricher, submitPostListener);
|
isNSFW, receivePostReplyNotifications, kind, url, postEnricher, 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,
|
||||||
|
@ -144,7 +144,7 @@ public class SubmitPostService extends Service {
|
|||||||
receivePostReplyNotifications, kind);
|
receivePostReplyNotifications, kind);
|
||||||
} else if (postType == EXTRA_POST_TYPE_CROSSPOST) {
|
} else if (postType == EXTRA_POST_TYPE_CROSSPOST) {
|
||||||
submitCrosspost(mExecutor, handler, mRetrofit.getRetrofit(), account, subredditName, title, body,
|
submitCrosspost(mExecutor, handler, mRetrofit.getRetrofit(), account, subredditName, title, body,
|
||||||
flair, isSpoiler, isNSFW, receivePostReplyNotifications);
|
url, 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(mRetrofit, account, mediaUri, subredditName, title, body, flair, isSpoiler, isNSFW,
|
submitImagePost(mRetrofit, account, mediaUri, subredditName, title, body, flair, isSpoiler, isNSFW,
|
||||||
@ -243,10 +243,10 @@ public class SubmitPostService extends Service {
|
|||||||
|
|
||||||
private void submitCrosspost(Executor executor, Handler handler, Retrofit newAuthenticatorOauthRetrofit,
|
private void submitCrosspost(Executor executor, Handler handler, Retrofit newAuthenticatorOauthRetrofit,
|
||||||
Account selectedAccount, int communityId,
|
Account selectedAccount, int communityId,
|
||||||
String title, String content, Flair flair, boolean isSpoiler, boolean isNSFW,
|
String title, String content, String url, boolean isSpoiler, boolean isNSFW,
|
||||||
boolean receivePostReplyNotifications) {
|
boolean receivePostReplyNotifications) {
|
||||||
SubmitPost.submitCrosspost(executor, handler, newAuthenticatorOauthRetrofit, selectedAccount.getAccessToken(), communityId, title,
|
SubmitPost.submitCrosspost(executor, handler, newAuthenticatorOauthRetrofit, selectedAccount.getAccessToken(), communityId, title,
|
||||||
content, flair, isSpoiler, isNSFW, receivePostReplyNotifications, APIUtils.KIND_CROSSPOST, postEnricher,
|
content, url, isSpoiler, isNSFW, receivePostReplyNotifications, APIUtils.KIND_CROSSPOST, postEnricher,
|
||||||
new SubmitPost.SubmitPostListener() {
|
new SubmitPost.SubmitPostListener() {
|
||||||
@Override
|
@Override
|
||||||
public void submitSuccessful(Post post) {
|
public void submitSuccessful(Post post) {
|
||||||
|
@ -124,20 +124,6 @@
|
|||||||
app:lib_setRoundedView="true"
|
app:lib_setRoundedView="true"
|
||||||
app:lib_setShape="rectangle" />
|
app:lib_setShape="rectangle" />
|
||||||
|
|
||||||
<com.libRG.CustomTextView
|
|
||||||
android:id="@+id/spoiler_custom_text_view_submit_crosspost_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
|
<com.libRG.CustomTextView
|
||||||
android:id="@+id/nsfw_custom_text_view_submit_crosspost_activity"
|
android:id="@+id/nsfw_custom_text_view_submit_crosspost_activity"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
Loading…
Reference in New Issue
Block a user