Skip to content

Commit

Permalink
Release 1.2.0 last minute fixes (#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
TWiStErRob authored Aug 30, 2023
1 parent ebff49d commit 8eca619
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 11 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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());
}
}
}
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -28,6 +31,9 @@ public class KeywordsDialogActor extends AlertDialogActor {
public void assertKeywords(@StringRes int keywords) {
assertDialogMessage(withText(keywords));
}
public void assertKeywords(@NonNull Matcher<String> matcher) {
assertDialogMessage(withText(matcher));
}

public void close() {
// Could also "tap outside", but not sure how to do that.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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;
}
});
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion docs/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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<version>.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
Expand Down

0 comments on commit 8eca619

Please sign in to comment.