From 508f3c62536300ad825122577253436fee5351d1 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 2 Jan 2023 16:20:58 +0100 Subject: [PATCH] comment #702 - Add post local only (Glitch) --- .../android/client/entities/api/Status.java | 2 ++ .../fedilab/android/jobs/ComposeWorker.java | 3 +++ .../android/ui/drawer/ComposeAdapter.java | 23 +++++++++++++++++++ .../android/ui/drawer/StatusAdapter.java | 7 ++++++ .../drawable/ic_baseline_local_only_24.xml | 10 ++++++++ app/src/main/res/layout/drawer_status.xml | 8 +++++++ .../main/res/layout/drawer_status_compose.xml | 13 ++++++++++- app/src/main/res/values/strings.xml | 8 +++++++ 8 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable/ic_baseline_local_only_24.xml diff --git a/app/src/main/java/app/fedilab/android/client/entities/api/Status.java b/app/src/main/java/app/fedilab/android/client/entities/api/Status.java index 994a0d39b..98ad50cda 100644 --- a/app/src/main/java/app/fedilab/android/client/entities/api/Status.java +++ b/app/src/main/java/app/fedilab/android/client/entities/api/Status.java @@ -102,6 +102,8 @@ public class Status implements Serializable, Cloneable { public List filtered; @SerializedName("pleroma") public Pleroma pleroma; + @SerializedName("local_only") + public boolean local_only = false; @SerializedName("cached") public boolean cached = false; public Attachment art_attachment; diff --git a/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java b/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java index 05ed092b9..6637c03cc 100644 --- a/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java +++ b/app/src/main/java/app/fedilab/android/jobs/ComposeWorker.java @@ -218,6 +218,9 @@ public class ComposeWorker extends Worker { return; } String language = sharedPreferences.getString(context.getString(R.string.SET_COMPOSE_LANGUAGE) + dataPost.userId + dataPost.instance, null); + if (statuses.get(i).local_only) { + statuses.get(i).text += " \uD83D\uDC41"; + } if (dataPost.scheduledDate == null) { if (dataPost.statusEditId == null) { statusCall = mastodonStatusesService.createStatus(null, dataPost.token, statuses.get(i).text, attachmentIds, poll_options, poll_expire_in, 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 6e8f290d2..054e6e4de 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 @@ -1279,6 +1279,7 @@ public class ComposeAdapter extends RecyclerView.Adapter { AlertDialog.Builder builder = new AlertDialog.Builder(context, Helper.dialogStyle()); builder.setTitle(context.getString(R.string.post_format)); @@ -1304,6 +1305,28 @@ public class ComposeAdapter extends RecyclerView.Adapter dialog.dismiss()); builder.create().show(); }); + holder.binding.buttonLocalOnly.setOnClickListener(v -> { + AlertDialog.Builder builder = new AlertDialog.Builder(context, Helper.dialogStyle()); + builder.setTitle(context.getString(R.string.local_only)); + Resources res = context.getResources(); + boolean[] valArr = new boolean[]{false, true}; + String[] labelArr = res.getStringArray(R.array.set_local_only); + + int selection = 0; + boolean localOnly = sharedpreferences.getBoolean(context.getString(R.string.SET_LOCAL_ONLY) + account.user_id + account.instance, false); + if (statusDraft.local_only || localOnly) { + selection = 1; + } + builder.setSingleChoiceItems(labelArr, selection, null); + builder.setPositiveButton(R.string.validate, (dialog, which) -> { + int selectedPosition = ((AlertDialog) dialog).getListView().getCheckedItemPosition(); + statusDraft.local_only = valArr[selectedPosition]; + notifyItemChanged(holder.getLayoutPosition()); + dialog.dismiss(); + }); + builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss()); + builder.create().show(); + }); } else { holder.binding.buttonTextFormat.setVisibility(View.GONE); } diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index eaa6a1de7..6a7c78753 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -1053,6 +1053,13 @@ public class StatusAdapter extends RecyclerView.Adapter ressource = R.drawable.ic_baseline_mail_24; break; } + + if (statusToDeal.local_only) { + holder.binding.localOnly.setVisibility(View.VISIBLE); + } else { + holder.binding.localOnly.setVisibility(View.GONE); + } + if (status.isFocused) { holder.binding.statusInfo.setVisibility(View.VISIBLE); holder.binding.reblogsCount.setText(String.valueOf(status.reblogs_count)); diff --git a/app/src/main/res/drawable/ic_baseline_local_only_24.xml b/app/src/main/res/drawable/ic_baseline_local_only_24.xml new file mode 100644 index 000000000..ba4d830ec --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_local_only_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/drawer_status.xml b/app/src/main/res/layout/drawer_status.xml index 7dcc0a61d..d28cfe2bb 100644 --- a/app/src/main/res/layout/drawer_status.xml +++ b/app/src/main/res/layout/drawer_status.xml @@ -159,6 +159,14 @@ android:singleLine="true" tools:text="@tools:sample/full_names" /> + + @@ -103,6 +103,17 @@ app:layout_constraintTop_toBottomOf="@id/button_emoji_one" tools:visibility="visible" /> + + text/x.misskeymarkdown + + + No + Yes + + Always Wifi only @@ -1435,6 +1441,7 @@ SET_DISPLAY_TRANSLATE SET_POST_FORMAT + SET_LOCAL_ONLY SET_TRANSLATOR SET_TRANSLATOR_VERSION @@ -2186,4 +2193,5 @@ Self Remote profiles The app will display publicly profiles to get all messages. Interactions will need an extra step to federate messages. + Local only \ No newline at end of file