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 additional JSON params for server control of update prompts #26

Merged
merged 5 commits into from
Nov 18, 2017

Conversation

saraht129
Copy link

@saraht129 saraht129 commented Oct 5, 2017

Close #25

This PR adds two additional parameters on the JSON file

  1. force (Boolean, if true, alertType on all types of version update will be set to FORCE)
  2. enable (Boolean, toggle version check functionality. If disabled, Siren will not do version check)

@mikemee
Copy link
Collaborator

mikemee commented Oct 5, 2017

@saraht129 Thanks!

A couple of things:

  1. Can you please add instructions to the readme?

  2. Note that the build is failing ./gradlew check with a PMD error:

     siren/Siren.java | 211 | A switch statement does not contain a break
    

If you get a chance to fix, that would be great, otherwise, I'll take care of it when I review.

Thanks so much for the PR!

@saraht129
Copy link
Author

Apologies for the build error. I've taken care of that and added instructions regarding the new parameters.

@saraht129
Copy link
Author

Hi, any chance that this can be merged? Thanks!

@saraht129
Copy link
Author

Just like to check if there's any update on this?

@mikemee
Copy link
Collaborator

mikemee commented Nov 13, 2017

@saraht129 Hi, sorry about the delay! I must have looked at the git notification on the phone but then forgot. I've added this to my list for tomorrow. Thanks!

@mikemee
Copy link
Collaborator

mikemee commented Nov 17, 2017

@Apisov Can you please take a look at this and especially confirm that the new switch code does the same as the replaced if/else chain (taking into account the new functionality)? Thanks!

@@ -231,13 +245,21 @@ private int checkVersionDigit(String[] minVersionNumbers, String[] currentVersio
private boolean checkVersionCode(JSONObject appJson) throws JSONException{
if (!appJson.isNull(Constants.JSON_MIN_VERSION_CODE)) {
int minAppVersionCode = appJson.getInt(Constants.JSON_MIN_VERSION_CODE);
// If no config found, assume version check is enabled
Boolean versionCheckEnabled = appJson.has(Constants.JSON_ENABLE_VERSION_CHECK) ? appJson.getBoolean(Constants.JSON_ENABLE_VERSION_CHECK) : true;
Copy link
Contributor

Choose a reason for hiding this comment

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

As a small improvement, we can move the logic of getting Constants.JSON_ENABLE_VERSION_CHECK value to separate method that returns boolean.

Because we have duplication of the logic in the code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Created #30

}

// If no config found, assume force update = false
Boolean forceUpdateEnabled = appJson.has(Constants.JSON_FORCE_ALERT_TYPE) ? appJson.getBoolean(Constants.JSON_FORCE_ALERT_TYPE) : false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think here it's possible to do the same as with Constants.JSON_ENABLE_VERSION_CHECK logic. But for Constants.JSON_FORCE_ALERT_TYPE

Copy link
Collaborator

Choose a reason for hiding this comment

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

Created #30

alertType = SirenAlertType.FORCE;
} else {
switch (index) {
case 0: alertType = majorUpdateAlertType; break;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it will add more readability if we will use constants instead of "magic numbers".
ie INDEX_MAJOR = 0 ... INDEX_REVISION = 3

Copy link
Collaborator

Choose a reason for hiding this comment

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

Create #30

Copy link
Contributor

@Apisov Apisov left a comment

Choose a reason for hiding this comment

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

All logic seems correct.
I have left only some refactoring notes.

@mikemee mikemee merged commit 0f93c13 into eggheadgames:develop Nov 18, 2017
@mikemee mikemee mentioned this pull request Nov 18, 2017
@mikemee mikemee changed the title Json additional params Add additional JSON params for server control of update prompts Nov 18, 2017
@mikemee
Copy link
Collaborator

mikemee commented Nov 18, 2017

@saraht129 Released as version 1.5.0. Thanks for your the idea, your contribution and the follow-up!

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

3 participants