Skip to content

Commit

Permalink
CATROID-910 Regex Popup Redesign
Browse files Browse the repository at this point in the history
Redesign the Regex Popup according to the Ticket: Moved link to wiki to "Help" button and made dialog smaller.
  • Loading branch information
ChriMoser authored and mseiser committed Feb 10, 2022
1 parent 95aab59 commit 6b5683a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,30 @@ 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()));
}

@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 {
Expand All @@ -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),
Expand All @@ -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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);

Expand All @@ -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());
}
}

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions catroid/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
~ You should have received a copy of the GNU Affero General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<resources xmlns:tools="http://schemas.android.com/tools">
<resources xmlns:tools="http://schemas.android.com/tools">

<!-- General terms -->
<string name="stage">Stage</string>
Expand All @@ -37,6 +37,7 @@
<string name="ignore">Ignore</string>
<string name="cancel">Cancel</string>
<string name="save">Save</string>
<string name="help">Help</string>

<string name="discard">Discard</string>

Expand Down Expand Up @@ -1804,7 +1805,6 @@ needs read and write access to it. You can always change permissions through you
assistant</string>
<string name="formula_editor_dialog_regular_expression_assistant_title">Regular
expression assistant</string>
<string name="formula_editor_dialog_wiki_button">More information</string>
<string name="formula_editor_function_regex_html_extractor_not_found">The keyword could not be found.</string>
<string name="formula_editor_function_regex_json_extractor_title">JSON extractor</string>
<string name="formula_editor_function_arduino_read_pin_value_digital">arduino digital pin</string>
Expand Down

0 comments on commit 6b5683a

Please sign in to comment.