From 6b5683a9668ac4d0ab4fb9d6032f6d7312a16e6f Mon Sep 17 00:00:00 2001 From: Christian Moser Date: Tue, 3 Aug 2021 15:08:26 +0200 Subject: [PATCH] CATROID-910 Regex Popup Redesign Redesign the Regex Popup according to the Ticket: Moved link to wiki to "Help" button and made dialog smaller. --- .../RegularExpressionAssistantDialogTest.java | 17 ++++---- .../RegularExpressionAssistantDialog.java | 14 ++---- .../RegularExpressionFeatureDummy.java | 43 ------------------- .../dialogs/regexassistant/WikiWebPage.java | 41 ------------------ .../dialog_regular_expression_assistant.xml | 32 -------------- catroid/src/main/res/values/strings.xml | 4 +- 6 files changed, 15 insertions(+), 136 deletions(-) delete mode 100644 catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/RegularExpressionFeatureDummy.java delete mode 100644 catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/WikiWebPage.java delete mode 100644 catroid/src/main/res/layout/dialog_regular_expression_assistant.xml diff --git a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/RegularExpressionAssistantDialogTest.java b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/RegularExpressionAssistantDialogTest.java index 91332c41920..924e57ec084 100644 --- a/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/RegularExpressionAssistantDialogTest.java +++ b/catroid/src/androidTest/java/org/catrobat/catroid/uiespresso/ui/dialog/RegularExpressionAssistantDialogTest.java @@ -98,7 +98,6 @@ public void testCancelButton() { @Test (expected = NoMatchingViewException.class) public void testCancelButtonFunctionality() { clickOnAssistantInFunctionList(); - onView(withText(R.string.cancel)).perform(click()); onView(withText(R.string.cancel)).check(matches(isDisplayed())); } @@ -106,19 +105,23 @@ public void testCancelButtonFunctionality() { @Test public void testIsHtmlExtractorInList() { clickOnAssistantInFunctionList(); - onView(withText(R.string.formula_editor_regex_html_extractor_dialog_title)).check(matches(isDisplayed())); } @Test - public void testIsWikiButtonInList() { + public void testIsJsonExtractorInList() { clickOnAssistantInFunctionList(); - onView(withText(R.string.formula_editor_dialog_wiki_button)).check(matches(isDisplayed())); + onView(withText(R.string.formula_editor_function_regex_json_extractor_title)).check(matches(isDisplayed())); } @Test - public void testOpenWikipageOnWikiButtonClick() { + public void testHelpButton() { + clickOnAssistantInFunctionList(); + onView(withText(R.string.help)).check(matches(isDisplayed())); + } + @Test + public void testOpenWikipageOnHelpButtonClick() { clickOnAssistantInFunctionList(); try { @@ -129,7 +132,7 @@ public void testOpenWikipageOnWikiButtonClick() { new Instrumentation.ActivityResult(Activity.RESULT_OK, intent); intending(anyIntent()).respondWith(intentResult); - onView(withText(R.string.formula_editor_dialog_wiki_button)).perform(click()); + onView(withText(R.string.help)).perform(click()); intended(allOf( hasAction(Intent.ACTION_VIEW), @@ -142,14 +145,12 @@ public void testOpenWikipageOnWikiButtonClick() { @Test public void testDoesHtmlExtractorOpensCorrectDialog() { clickOnAssistantInFunctionList(); - onView(withText(R.string.formula_editor_regex_html_extractor_dialog_title)).perform(click()); onView(withText(R.string.formula_editor_regex_html_extractor_dialog_title)).check(matches(isDisplayed())); } @Test public void testDoesJsonExtractorOpensCorrectDialog() { clickOnAssistantInFunctionList(); - onView(withText(R.string.formula_editor_function_regex_json_extractor_title)).perform(click()); onView(withText(R.string.formula_editor_function_regex_json_extractor_title)).check(matches(isDisplayed())); } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/RegularExpressionAssistantDialog.java b/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/RegularExpressionAssistantDialog.java index 72afae2aa7c..99bbf10b7d6 100644 --- a/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/RegularExpressionAssistantDialog.java +++ b/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/RegularExpressionAssistantDialog.java @@ -24,9 +24,9 @@ package org.catrobat.catroid.ui.dialogs.regexassistant; import android.content.Context; -import android.content.DialogInterface; import org.catrobat.catroid.R; +import org.catrobat.catroid.web.WebpageUtils; import java.util.ArrayList; import java.util.List; @@ -50,9 +50,9 @@ public RegularExpressionAssistantDialog(Context context, FragmentManager fragmen public void createAssistant() { AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setView(R.layout.dialog_regular_expression_assistant); builder.setTitle(R.string.formula_editor_dialog_regular_expression_assistant_title); - builder.setNegativeButton(R.string.cancel, null); + builder.setNegativeButton(R.string.help, (dialog, id) -> WebpageUtils.openWikiPage(context)); + builder.setPositiveButton(R.string.cancel, null); buildListOfFeatures(builder); @@ -68,18 +68,12 @@ private void buildListOfFeatures(AlertDialog.Builder builder) { } builder.setItems(namesOfFeatures.toArray(new String[0]), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int indexInList) { - listOfFeatures.get(indexInList).openDialog(context); - } - }); + (dialog, indexInList) -> listOfFeatures.get(indexInList).openDialog(context)); } private void createListOfFeatures() { listOfFeatures = new ArrayList<>(); listOfFeatures.add(new HtmlExtractorDialog(fragmentManager)); listOfFeatures.add(new JsonExtractorDialog(fragmentManager)); - listOfFeatures.add(new WikiWebPage()); } } diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/RegularExpressionFeatureDummy.java b/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/RegularExpressionFeatureDummy.java deleted file mode 100644 index 82ec18527ff..00000000000 --- a/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/RegularExpressionFeatureDummy.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2020 The Catrobat Team - * () - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * An additional term exception under section 7 of the GNU Affero - * General Public License, version 3, is available at - * http://developer.catrobat.org/license_additional_term - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package org.catrobat.catroid.ui.dialogs.regexassistant; - -import android.app.AlertDialog; -import android.content.Context; - -import org.catrobat.catroid.R; - -public class RegularExpressionFeatureDummy extends RegularExpressionFeature { - - public RegularExpressionFeatureDummy(int titleId) { - this.titleId = titleId; - } - - public void openDialog(Context context) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setTitle(context.getString(titleId) + "Dialog"); - builder.setView(R.layout.dialog_regular_expression_assistant); - builder.show(); - } -} diff --git a/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/WikiWebPage.java b/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/WikiWebPage.java deleted file mode 100644 index a1ef09aebb3..00000000000 --- a/catroid/src/main/java/org/catrobat/catroid/ui/dialogs/regexassistant/WikiWebPage.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Catroid: An on-device visual programming system for Android devices - * Copyright (C) 2010-2020 The Catrobat Team - * () - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * An additional term exception under section 7 of the GNU Affero - * General Public License, version 3, is available at - * http://developer.catrobat.org/license_additional_term - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package org.catrobat.catroid.ui.dialogs.regexassistant; - -import android.content.Context; - -import org.catrobat.catroid.R; -import org.catrobat.catroid.web.WebpageUtils; - -public class WikiWebPage extends RegularExpressionFeature { - - public WikiWebPage() { - this.titleId = R.string.formula_editor_dialog_wiki_button; - } - - @Override - public void openDialog(Context context) { - WebpageUtils.openWikiPage(context); - } -} diff --git a/catroid/src/main/res/layout/dialog_regular_expression_assistant.xml b/catroid/src/main/res/layout/dialog_regular_expression_assistant.xml deleted file mode 100644 index 1f3a3475fc4..00000000000 --- a/catroid/src/main/res/layout/dialog_regular_expression_assistant.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - \ No newline at end of file diff --git a/catroid/src/main/res/values/strings.xml b/catroid/src/main/res/values/strings.xml index 44b4194e6f8..4df6ac2ac0a 100644 --- a/catroid/src/main/res/values/strings.xml +++ b/catroid/src/main/res/values/strings.xml @@ -21,7 +21,7 @@ ~ You should have received a copy of the GNU Affero General Public License ~ along with this program. If not, see . --> - + Stage @@ -37,6 +37,7 @@ Ignore Cancel Save + Help Discard @@ -1804,7 +1805,6 @@ needs read and write access to it. You can always change permissions through you assistant Regular expression assistant - More information The keyword could not be found. JSON extractor arduino digital pin