From 8eca6197b613c2eb2ba7b350b1d1c67a6273b0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B3bert=20Papp?= Date: Wed, 30 Aug 2023 14:10:17 +0100 Subject: [PATCH] Release 1.2.0 last minute fixes (#328) --- README.md | 8 ++--- .../activity/ItemEditActivityTest_Edit.java | 10 +++++++ .../test/actors/CategoryActivityActor.java | 21 +++++++++++++ .../test/actors/EditActivityActor.java | 30 +++++++++++++++++++ .../test/actors/KeywordsDialogActor.java | 6 ++++ .../content/model/CategoryVisuals.java | 5 ++-- .../fragment/data/BaseEditFragment.java | 6 ++-- docs/release.md | 7 ++++- libs | 2 +- 9 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/CategoryActivityActor.java diff --git a/README.md b/README.md index 581a2d7a1..66152e48b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Magic Home Inventory -![Project logo](https://www.twisterrob.net/images/projects/inventory/icon-512.png) - ---- - App Store: https://play.google.com/store/apps/details?id=net.twisterrob.inventory Website: https://www.twisterrob.net/project/inventory/ See [`docs` folder](docs) for contribution details. + +--- + +![Project logo](android/src/main/art/Hi-res%20Icon.png) diff --git a/android/src/androidTest/java/net/twisterrob/inventory/android/activity/ItemEditActivityTest_Edit.java b/android/src/androidTest/java/net/twisterrob/inventory/android/activity/ItemEditActivityTest_Edit.java index 8920f0b83..7ecf72eb3 100644 --- a/android/src/androidTest/java/net/twisterrob/inventory/android/activity/ItemEditActivityTest_Edit.java +++ b/android/src/androidTest/java/net/twisterrob/inventory/android/activity/ItemEditActivityTest_Edit.java @@ -4,6 +4,9 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; +import static org.hamcrest.Matchers.emptyString; +import static org.hamcrest.Matchers.not; + import androidx.test.ext.junit.runners.AndroidJUnit4; import net.twisterrob.inventory.android.activity.data.ItemEditActivity; @@ -60,4 +63,11 @@ public class ItemEditActivityTest_Edit { // changes applied db.assertItemHasType(TEST_ITEM, TEST_ITEM_CATEGORY_OTHER); } + + @Category({On.Category.class}) + @Test public void testShowKeywords() { + KeywordsDialogActor keywords = itemEdit.help().showKeywords(); + keywords.assertKeywords(not(emptyString())); + keywords.close(); + } } diff --git a/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/CategoryActivityActor.java b/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/CategoryActivityActor.java new file mode 100644 index 000000000..210c37ea3 --- /dev/null +++ b/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/CategoryActivityActor.java @@ -0,0 +1,21 @@ +package net.twisterrob.inventory.android.test.actors; + +import net.twisterrob.inventory.android.R; +import net.twisterrob.inventory.android.activity.data.CategoryActivity; + +public class CategoryActivityActor extends ItemContainingViewActivityActor { + public CategoryActivityActor() { + super(CategoryActivity.class); + } + + @Override public void assertShowing(String itemName) { + assertActionTitle(itemName); + } + + public CategoryActivityActor flatten() { + clickActionBar(R.id.action_category_viewAllItems); + CategoryActivityActor activity = new CategoryActivityActor(); + activity.assertIsInFront(); + return activity; + } +} diff --git a/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/EditActivityActor.java b/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/EditActivityActor.java index e69b72c72..df302f230 100644 --- a/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/EditActivityActor.java +++ b/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/EditActivityActor.java @@ -99,6 +99,12 @@ public void checkType(@StringRes int type) { public void checkPicture(@ColorInt int backgroundColor) { onView(imageMatcher).perform(scrollTo()).check(matches(withBitmap(hasBackgroundColor(backgroundColor)))); } + public InfoPopupActor help() { + onView(withId(R.id.help)).perform(click()); + InfoPopupActor popup = new InfoPopupActor(); + popup.assertDisplayed(); + return popup; + } public SaveResultActor save() { onView(withId(R.id.btn_save)).perform(click()); return new SaveResultActor(); @@ -161,4 +167,28 @@ public final void checkToastAlreadyExists() { assertToastMessage(withText(matcher)); } } + + public static class InfoPopupActor { + public void assertDisplayed() { + onRoot(isPlatformPopup()).check(matches(isCompletelyDisplayed())); + } + + public KeywordsDialogActor showKeywords() { + onData(withMenuItemId(R.id.action_category_keywords)).perform(click()); + KeywordsDialogActor dialog = new KeywordsDialogActor(); + dialog.assertDisplayed(); + return dialog; + } + + public CategoryActivityActor jumpToCategory() { + onData(withMenuItemId(R.id.action_category_goto)).perform(click()); + CategoryActivityActor activity = new CategoryActivityActor(); + activity.assertIsInFront(); + return activity; + } + + public void suggestCategories() { + onData(withMenuItemId(R.id.action_category_suggest)).perform(click()); + } + } } diff --git a/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/KeywordsDialogActor.java b/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/KeywordsDialogActor.java index 256659f59..ca35de484 100644 --- a/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/KeywordsDialogActor.java +++ b/android/src/androidTest/java/net/twisterrob/inventory/android/test/actors/KeywordsDialogActor.java @@ -1,9 +1,12 @@ package net.twisterrob.inventory.android.test.actors; +import org.hamcrest.Matcher; + import static org.hamcrest.Matchers.anyOf; import android.content.Context; +import androidx.annotation.NonNull; import androidx.annotation.StringRes; import androidx.test.espresso.Espresso; @@ -28,6 +31,9 @@ public class KeywordsDialogActor extends AlertDialogActor { public void assertKeywords(@StringRes int keywords) { assertDialogMessage(withText(keywords)); } + public void assertKeywords(@NonNull Matcher matcher) { + assertDialogMessage(withText(matcher)); + } public void close() { // Could also "tap outside", but not sure how to do that. diff --git a/android/src/main/java/net/twisterrob/inventory/android/content/model/CategoryVisuals.java b/android/src/main/java/net/twisterrob/inventory/android/content/model/CategoryVisuals.java index c54ba5675..011f005e5 100644 --- a/android/src/main/java/net/twisterrob/inventory/android/content/model/CategoryVisuals.java +++ b/android/src/main/java/net/twisterrob/inventory/android/content/model/CategoryVisuals.java @@ -5,6 +5,7 @@ import javax.inject.Inject; +import android.app.Activity; import android.content.Context; import android.content.res.Resources.NotFoundException; import android.text.SpannableStringBuilder; @@ -95,8 +96,8 @@ public CategoryVisuals( } } - public void showKeywords(long categoryID) { + public void showKeywords(@NonNull Activity activity, long categoryID) { CharSequence keywords = getKeywords(cache.getCategoryKey(categoryID), true); - ChangeTypeDialog.showKeywords(context, cache.getCategoryPath(categoryID), keywords); + ChangeTypeDialog.showKeywords(activity, cache.getCategoryPath(categoryID), keywords); } } diff --git a/android/src/main/java/net/twisterrob/inventory/android/fragment/data/BaseEditFragment.java b/android/src/main/java/net/twisterrob/inventory/android/fragment/data/BaseEditFragment.java index de7eb07d2..b6f9f86c9 100644 --- a/android/src/main/java/net/twisterrob/inventory/android/fragment/data/BaseEditFragment.java +++ b/android/src/main/java/net/twisterrob/inventory/android/fragment/data/BaseEditFragment.java @@ -236,7 +236,7 @@ public void onClick(View v) { Hinter.unhighlight(name.getText()); } @Override public void categoryQueried(long categoryID) { - visuals.showKeywords(categoryID); + visuals.showKeywords(requireActivity(), categoryID); } }); hint.setAdapter(hinter.getAdapter()); @@ -281,7 +281,7 @@ public void onItemSelected(AdapterView parent, View view, int position, long // CONSIDER setOnItemLongClickListener is not supported, any way to work around? So user has the same "tooltip" as in ChangeTypeDialog type.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View view) { - visuals.showKeywords(getTypeId()); + visuals.showKeywords(requireActivity(), getTypeId()); return true; } }); @@ -330,7 +330,7 @@ private void onPrepareContextMenu(Menu menu, MenuInflater inflater) { updateHint(name.getText(), true); return true; } else if (id == R.id.action_category_keywords) { - visuals.showKeywords(getTypeId()); + visuals.showKeywords(requireActivity(), getTypeId()); return true; } else { return super.onContextItemSelected(item); diff --git a/docs/release.md b/docs/release.md index 9bb248fbf..34806f564 100644 --- a/docs/release.md +++ b/docs/release.md @@ -2,6 +2,7 @@ For the full process see [.github/release.md](https://github.com/TWiStErRob/.git # Release Process +1. Double-check the version number in `android/build.gradle` is the same as the milestone, if not, PR. 1. Ensure clean latest working copy. ```shell git checkout main @@ -22,7 +23,7 @@ For the full process see [.github/release.md](https://github.com/TWiStErRob/.git * `proguard_mapping.txt` @ Developer Console \> Release - \> [App bundle explorer](https://play.google.com/console/u/0/developers/7995455198986011414/app/4974852622245161228/bundle-explorer) + \> [App bundle explorer](https://play.google.com/console/u/0/developers/7995455198986011414/app/4974852622245161228/bundle-explorer-selector) \> Downloads tab \> Assets \> ReTrace mapping file @@ -31,6 +32,10 @@ For the full process see [.github/release.md](https://github.com/TWiStErRob/.git 1. Make a backup of current version on the phone with ```shell adb backup -f Inventory-pre.ab -apk -noobb -noshared -nosystem net.twisterrob.inventory + # > Now unlock your device and confirm the backup operation... + # At this point have to press "Back up my data" on the phone really quickly. + # If the CLI prompt is shown after this message, + # it's too late and the backup will not happen regardless what the toast says. ``` Note: to restore a backup for testing use ```shell diff --git a/libs b/libs index 97deb8823..1d1df61bc 160000 --- a/libs +++ b/libs @@ -1 +1 @@ -Subproject commit 97deb882365f6c21c1b510cd00b04653431cb203 +Subproject commit 1d1df61bc330cce281dca88d7d10aa6a17a3b693