Fix issue #248 - nsfw no respected when posting

This commit is contained in:
Thomas 2022-07-15 18:12:29 +02:00
parent 61ddd2a22d
commit 27b05d5b6b
2 changed files with 28 additions and 15 deletions

View File

@ -103,7 +103,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
public static final int REQUEST_AUDIO_PERMISSION_RESULT = 1653;
public static final int PICK_MEDIA = 5700;
public static final int TAKE_PHOTO = 5600;
private final Timer timer = new Timer();
private List<Status> statusList;
private Status statusReply, statusMention;
private StatusDraft statusDraft;
@ -353,12 +353,14 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
.registerReceiver(imageReceiver,
new IntentFilter(Helper.INTENT_SEND_MODIFIED_IMAGE));
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
storeDraft(false);
}
}, 0, 10000);
if (timer != null) {
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
storeDraft(false);
}
}, 0, 10000);
}
if (sharedUriList != null && sharedUriList.size() > 0) {
@ -393,6 +395,9 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
@Override
protected void onDestroy() {
super.onDestroy();
if (timer != null) {
timer.cancel();
}
LocalBroadcastManager.getInstance(this)
.unregisterReceiver(imageReceiver);
}
@ -665,6 +670,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
} else {
statusReplies.add(status);
}
}
if (statusDraft == null) {
statusDraft = new StatusDraft(ComposeActivity.this);
@ -675,10 +681,12 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
}
}
if (statusReplies.size() > 0) {
statusDraft.statusReplyList = statusReplies;
statusDraft.statusReplyList = new ArrayList<>();
statusDraft.statusReplyList.addAll(statusReplies);
}
if (statusDrafts.size() > 0) {
statusDraft.statusDraftList = statusDrafts;
statusDraft.statusDraftList = new ArrayList<>();
statusDraft.statusDraftList.addAll(statusDrafts);
}
if (statusDraft.instance == null) {
statusDraft.instance = account.instance;

View File

@ -456,13 +456,18 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
List<Attachment> attachmentList = statusList.get(position).media_attachments;
if (attachmentList != null && attachmentList.size() > 0) {
holder.binding.sensitiveMedia.setVisibility(View.VISIBLE);
if (currentAccount.mastodon_account.source != null) {
holder.binding.sensitiveMedia.setChecked(currentAccount.mastodon_account.source.sensitive);
statusList.get(position).sensitive = currentAccount.mastodon_account.source.sensitive;
} else {
statusList.get(position).sensitive = false;
if (!statusList.get(position).sensitive) {
if (currentAccount.mastodon_account.source != null) {
holder.binding.sensitiveMedia.setChecked(currentAccount.mastodon_account.source.sensitive);
statusList.get(position).sensitive = currentAccount.mastodon_account.source.sensitive;
} else {
statusList.get(position).sensitive = false;
}
}
holder.binding.sensitiveMedia.setOnCheckedChangeListener((buttonView, isChecked) -> statusList.get(position).sensitive = isChecked);
holder.binding.sensitiveMedia.setOnCheckedChangeListener((buttonView, isChecked) -> {
statusList.get(position).sensitive = isChecked;
});
int mediaPosition = 0;
for (Attachment attachment : attachmentList) {
ComposeAttachmentItemBinding composeAttachmentItemBinding = ComposeAttachmentItemBinding.inflate(LayoutInflater.from(context), holder.binding.attachmentsList, false);