From 9055e6099416a2ac0ae0ce494a9e7c6519f78ab2 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Wed, 25 May 2022 09:53:17 -0700 Subject: [PATCH 1/3] Pulled changes --- .../java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java b/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java index 5552350fb7..8abef7539c 100644 --- a/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java +++ b/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java @@ -268,7 +268,7 @@ public static void showMultiChoiceDialogWithSearchFilterUI(final Activity activi // ========================================================================================= // Ok button action - if (((dopt.callback != null) || (dopt.isMultiSelectEnabled)) && dopt.okButtonText != 0) { + if (((dopt.callback != null && dopt.isSearchEnabled) || (dopt.positionCallback != null && dopt.isMultiSelectEnabled)) && dopt.okButtonText != 0) { dialogBuilder.setPositiveButton(dopt.okButtonText, (dialogInterface, i) -> { final String searchText = dopt.isSearchEnabled ? searchEditText.getText().toString() : null; if (dopt.positionCallback != null && !listAdapter._selectedItems.isEmpty()) { From 37a459f9b91108a9e547238938969e97fac69244 Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Wed, 25 May 2022 10:09:53 -0700 Subject: [PATCH 2/3] Using positioncallback --- .../gsantner/markor/ui/SearchOrCustomTextDialogCreator.java | 3 +-- .../java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/net/gsantner/markor/ui/SearchOrCustomTextDialogCreator.java b/app/src/main/java/net/gsantner/markor/ui/SearchOrCustomTextDialogCreator.java index eeed5c2114..a802c4c0a4 100644 --- a/app/src/main/java/net/gsantner/markor/ui/SearchOrCustomTextDialogCreator.java +++ b/app/src/main/java/net/gsantner/markor/ui/SearchOrCustomTextDialogCreator.java @@ -674,9 +674,8 @@ public static void showInsertSnippetDialog(final Activity activity, final Callba dopt.data = data; dopt.isSearchEnabled = true; dopt.titleText = R.string.insert_snippet; - dopt.okButtonText = 0; dopt.messageText = Html.fromHtml("" + folder.getAbsolutePath() + ""); - dopt.callback = (key) -> callback.callback(FileUtils.readTextFileFast(texts.get(key)).first); + dopt.positionCallback = (ind) -> callback.callback(FileUtils.readTextFileFast(texts.get(data.get(ind.get(0)))).first); SearchOrCustomTextDialog.showMultiChoiceDialogWithSearchFilterUI(activity, dopt); } diff --git a/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java b/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java index 8abef7539c..cb880160c7 100644 --- a/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java +++ b/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java @@ -267,8 +267,8 @@ public static void showMultiChoiceDialogWithSearchFilterUI(final Activity activi // ========================================================================================= - // Ok button action - if (((dopt.callback != null && dopt.isSearchEnabled) || (dopt.positionCallback != null && dopt.isMultiSelectEnabled)) && dopt.okButtonText != 0) { + // Ok button only present under these circumstances + if (((dopt.callback != null && dopt.isSearchEnabled) || (dopt.positionCallback != null && dopt.isMultiSelectEnabled))) { dialogBuilder.setPositiveButton(dopt.okButtonText, (dialogInterface, i) -> { final String searchText = dopt.isSearchEnabled ? searchEditText.getText().toString() : null; if (dopt.positionCallback != null && !listAdapter._selectedItems.isEmpty()) { @@ -342,8 +342,8 @@ public static void showMultiChoiceDialogWithSearchFilterUI(final Activity activi }; // Helper function to append selection count to OK button - final Button okButton = dialog.getButton(Dialog.BUTTON_POSITIVE); final String okText = activity.getString(dopt.okButtonText) + (dopt.isMultiSelectEnabled ? " (%d)" : ""); + final Button okButton = dialog.getButton(Dialog.BUTTON_POSITIVE); final Callback.a0 setOkButtonState = () -> { okButton.setText(okText.replace("%d", Integer.toString(listAdapter._selectedItems.size()))); }; From e24ac58c3a8268e39172539a53927117557d294c Mon Sep 17 00:00:00 2001 From: Harshad Vedartham Date: Wed, 25 May 2022 11:29:38 -0700 Subject: [PATCH 3/3] Unnecessary change reverted --- .../java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java b/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java index cb880160c7..4fbe043964 100644 --- a/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java +++ b/app/src/main/java/net/gsantner/opoc/ui/SearchOrCustomTextDialog.java @@ -342,8 +342,8 @@ public static void showMultiChoiceDialogWithSearchFilterUI(final Activity activi }; // Helper function to append selection count to OK button - final String okText = activity.getString(dopt.okButtonText) + (dopt.isMultiSelectEnabled ? " (%d)" : ""); final Button okButton = dialog.getButton(Dialog.BUTTON_POSITIVE); + final String okText = activity.getString(dopt.okButtonText) + (dopt.isMultiSelectEnabled ? " (%d)" : ""); final Callback.a0 setOkButtonState = () -> { okButton.setText(okText.replace("%d", Integer.toString(listAdapter._selectedItems.size()))); };