diff options
author | Thomas <tschneider.ac@gmail.com> | 2022-07-15 18:12:29 +0200 |
---|---|---|
committer | Thomas <tschneider.ac@gmail.com> | 2022-07-15 18:12:29 +0200 |
commit | 27b05d5b6bef79c2bcea6e9b09022e4857106724 (patch) | |
tree | 4f86718c60dc2fa8c6368f43ecb5f080efed4bd3 /app/src | |
parent | 61ddd2a22d31ea368180177b1fc06a33787f76da (diff) |
Fix issue #248 - nsfw no respected when posting
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/app/fedilab/android/activities/ComposeActivity.java | 26 | ||||
-rw-r--r-- | app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java | 17 |
2 files changed, 28 insertions, 15 deletions
diff --git a/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java b/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java index dc06ddcfc..ceea97968 100644 --- a/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/ComposeActivity.java @@ -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; diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java index 2ce9f3fa5..34509b108 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/ComposeAdapter.java @@ -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); |