Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add possibility to use QuantityStrings for the toolbar #39

Merged
merged 2 commits into from Feb 2, 2017
Merged

add possibility to use QuantityStrings for the toolbar #39

merged 2 commits into from Feb 2, 2017

Conversation

hardysim
Copy link
Contributor

@hardysim hardysim commented Jan 31, 2017

closes #31 #33

Copy link
Contributor Author

@hardysim hardysim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a problem here:

I've copied setTitles() from the builder and overloaded it with my quantity-string-res. It's working fine but only if the caller (sample-app) defines both setTitles()-methods.

If not (just using the new quantity-one), the list is empty and the app runs into an Exception when Builder#build() is reached:

rxjava's SafeSubscriber#onNext()

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.trim()' on a null object reference

Any idea?

@@ -90,7 +90,8 @@ private void setUpAdapter(List<String> strings) {

MultiChoiceToolbar multiChoiceToolbar =
new MultiChoiceToolbar.Builder(SampleToolbarActivity.this, toolbar)
.setTitles(toolbarTitle(), "item selected")
.setTitles(toolbarTitle(), "item selected") // TODO crashing when removed !?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't remove this. Otherwise the list is empty?!

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is an issue with the way i'm populating the data with RXjava check out that piece of code, it's just generating some items.

@@ -31,13 +33,13 @@
}
}

void updateToolbar(int itemNumber) throws IllegalStateException {
if (itemNumber == ZERO) {
void updateToolbar(int selectedItemCount) throws IllegalStateException {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to change the name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable-name wasn't clear to be so I changed it. I think this is clearer now.

I can revert it, if you like. Should I?

@@ -90,7 +90,8 @@ private void setUpAdapter(List<String> strings) {

MultiChoiceToolbar multiChoiceToolbar =
new MultiChoiceToolbar.Builder(SampleToolbarActivity.this, toolbar)
.setTitles(toolbarTitle(), "item selected")
.setTitles(toolbarTitle(), "item selected") // TODO crashing when removed !?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep the plural, remove the other one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - tried that of course but then it isn't working. When only keeping the plural-setTitles() I get an exception and the list is empty (no adapter added). See comment above.

@dvdciri
Copy link
Owner

dvdciri commented Jan 31, 2017

  1. Please bump the release version accordingly to the changes done.
  2. Can't help you at the moment with the issue, make sure everything is working fine and tested manually and unit test.

@hardysim
Copy link
Contributor Author

Everything seems fine and working now.


Please bump the release version accordingly to the changes done

@dvdciri What do you mean? Should I increase PUBLISH_VERSION in build.gradle to 2.1.0?

@dvdciri
Copy link
Owner

dvdciri commented Jan 31, 2017

Yes, exactly also, squash everything into a single commit with testing and stuff and i don't know why i can't see the test running on this PR, can you create a branch under my repo in feature/branch_name? Not sure if have the access though

Provide enough info on the commit message

@@ -147,7 +147,7 @@ public void testMultiChoiceToolbar() {
.perform(RecyclerViewActions.actionOnItemAtPosition(0, longClick()));

onView(allOf(isAssignableFrom(TextView.class), withParent(isAssignableFrom(Toolbar.class))))
.check(matches(withText(containsString("1"))));
.check(matches(withText(containsString("One"))));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't change this test because this was checking that the item number has changed to the correct, create some new test, with the specific plural scenarios about the feature that you added and make sure al the tests instrumental and unit are passing!

@@ -238,7 +238,7 @@ public void testSingleClickModeOptionMenu() {

//Check the toolbar as well
onView(allOf(isAssignableFrom(TextView.class), withParent(isAssignableFrom(Toolbar.class))))
.check(matches(withText(containsString("1"))));
.check(matches(withText(containsString("One"))));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

@hardysim
Copy link
Contributor Author

Sry, didn't check all tests. Should be fine now.


I've add a switch to SampleToolbarActivity to use different setTitles()-methods and added SampleToolbarActivityPluralsTest to test the new plural-toolbar.


Something left now?

@hardysim
Copy link
Contributor Author

squash everything into a single commit with testing and stuff

You mean to have only one (merge-) commit with all changes in your history once merged? Can't you rebase right here from the PR?

If not, what's the best practice to get this work? Merge into my fork and use a cherry-pick on the merge-commit for the PR into your project? Wouldn't this result in a new PR (and close of this one)?

i don't know why i can't see the test running on this PR

Already wondered. Do you have a check for the branch-name (like "starts with feature/")?

can you create a branch under my repo in feature/branch_name

No, it seems like I don't have enough permissions for that

@dvdciri
Copy link
Owner

dvdciri commented Jan 31, 2017

Nope, no check for branch name, is not running because is not a branch under my repo.. weird.
Anyway please do the following:

  • We don't need to change the sample, so everything related to it just keep it in the same way, the changes must be retro-compatible so please, keep the sample as is with the normale setTitle() but make sure you check all the cases with both, on or the other, run test and add test for that specific scenario (you did).
  • I can squash when i merge

So everything under the sample package, a part from the instrumental testing should not be touched , try to keep everything as simple as possible
I'll review everythin again once you finished

@hardysim
Copy link
Contributor Author

The changes I made to the sample are only needed to get an activity using the new method. As I did not replaced the original .setTitles() everything is retro-compatible.

So, what do you want? An additional Activity using the new plural-setTitles() (which I can use for my UI-test)?

@dvdciri
Copy link
Owner

dvdciri commented Jan 31, 2017

The it's fine. I'll review everything again later on. We need to find a way to run CircleCI on it.

@hardysim
Copy link
Contributor Author

If I get it right, CircleCI should run checks for PR of a fork automatically. But yes, it's obviously not working.

https://circleci.com/docs/fork-pr-builds/


I found this - seems like it's possible that CircleCI doesn't recognize this project as OpenSource !?

@dvdciri
Copy link
Owner

dvdciri commented Feb 1, 2017

Yeah looks like is not recognising it as OpenSource but we need to run CircleCI on it before i can merge it.

@hardysim
Copy link
Contributor Author

hardysim commented Feb 1, 2017

I'm not familiar with CircleCI and cannot help you with that - maybe create a bug on their tracker?

@hardysim
Copy link
Contributor Author

hardysim commented Feb 1, 2017

I got an answer from @ ecgreb (lostzen/lost#94 (comment)):

try under the Circle web UI Settings > Advanced Settings make sure "Free and Open Source" and "Build forked pull requests" are both enabled.

@dvdciri can you check that?

@dvdciri
Copy link
Owner

dvdciri commented Feb 1, 2017

Done, enabled it! Let's see

@hardysim
Copy link
Contributor Author

hardysim commented Feb 1, 2017

Do we need to do an other push to this branch to get it triggered?

@dvdciri
Copy link
Owner

dvdciri commented Feb 1, 2017

Can you do an interactive git squash into a single commit? so we trigger the build?

@hardysim
Copy link
Contributor Author

hardysim commented Feb 2, 2017

So it looks running now :)


But I'm not happy with the way I squashed the commits. I used the workflow from http://stackoverflow.com/a/25357146 which worked fine (other than rebase, which results in one conflict after an other) but I needed to force-push.

Is there a non-rebase, non-force-push way to squash a whole branch into one commit to contribute to a foreign project (just like this case here)?

I think the squash-merge in this very PR here would do the trick, right?

@dvdciri
Copy link
Owner

dvdciri commented Feb 2, 2017

That's the only way, you have conflict because is rewriting the history and adding one commit in the other on top of the branch you reabsed.

@hardysim
Copy link
Contributor Author

hardysim commented Feb 2, 2017

That's the only way, you have conflict because is rewriting the history and adding one commit in the other on top of the branch you rebased.

Yeah, think so. But just to make sure I get it right: Squash-Merging a PR in github would work too, right?

https://help.github.com/articles/configuring-commit-squashing-for-pull-requests/

@dvdciri
Copy link
Owner

dvdciri commented Feb 2, 2017

Yes, correct!

I would just do one change, don't add the possibility to change the mode via UI through the option menu, just keep the logic for the test but remove the changes done to the menu, option menu clicked and what need to change accordingly.
So in the sample will always be plurals but for test we can have different.

Other that that LGTM!

@hardysim
Copy link
Contributor Author

hardysim commented Feb 2, 2017

So in the sample will always be plurals but for test we can have different.

That won't work as your unit-tests rely on the toolbar showing "1", remember? So I need to leave SampleToolbarActivity as it is and cannot use the plurals.

@dvdciri
Copy link
Owner

dvdciri commented Feb 2, 2017

Right.. then just show a toast in the Case that the use clicks on the option menu explaining what he've just enabled/disabled, cause ATM you're just doing the logic bug at least a feedback for the user is needed

@hardysim hardysim changed the title WIP add possibility to use QuantityStrings for the toolbar add possibility to use QuantityStrings for the toolbar Feb 2, 2017
@hardysim
Copy link
Contributor Author

hardysim commented Feb 2, 2017

All done. Ready to merge?

PS: Will you create a new release so I can use this new feature right now? ;-)

@dvdciri dvdciri merged commit d9be4ce into dvdciri:develop Feb 2, 2017
@dvdciri
Copy link
Owner

dvdciri commented Feb 2, 2017

Not sure when i'm gonna do a release, but will definitely happen sometimes soon. Thanks

@hardysim hardysim deleted the 33-QuantityStrings branch February 2, 2017 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants