-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Don't ask user to start G6 before connectivity #2757
Don't ask user to start G6 before connectivity #2757
Conversation
@@ -2612,7 +2614,12 @@ private void updateCurrentBgInfoCommon(DexCollectionType collector, TextView not | |||
} | |||
|
|||
if (!isSensorActive) { | |||
notificationText.setText(R.string.now_start_your_sensor); | |||
boolean G6_not_connected_yet = Pref.getBooleanDefaultFalse("using_g6") && DexTimeKeeper.getTransmitterAgeInDays(getTransmitterID()) == -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could stick to the Java convention that variable names should be camelCase, i.e. start with a lower character.
boolean G6_not_connected_yet = Pref.getBooleanDefaultFalse("using_g6") && DexTimeKeeper.getTransmitterAgeInDays(getTransmitterID()) == -1; | |
boolean g6NotConnectedYet = Pref.getBooleanDefaultFalse("using_g6") && DexTimeKeeper.getTransmitterAgeInDays(getTransmitterID()) == -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My objective is to get this change added so that xDrip functionality improves for the inexperienced user.
I am more than happy to make any necessary change to get approval.
Therefore, if I am told that this is what's holding this PR up, I will change it.
Let me add that looking at this same file, I can see plenty of existing uppercase instances. For example:
private static final int SHOWCASE_G5FIRMWARE = 9; |
So, SHOWCASE_G5FIRMWARE is already there. If we are going to change the code for some reason, we should be consistent.
If, we want to say, let's leave the existing cases alone. But, let's follow this guideline for the new variables, I am happy to follow such a guideline if I can get an approval of it.
So, I thank you for having a look and making the suggestion. But, I am not going to make your requested change because I have no idea it is going to make any difference in what really matters in getting this approved or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just caught my eye when skimming through your PR. The constant in line 258 is fine by convention. https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for providing this guidance.
I will change to follow the standard. I have no reason not to follow it.
@@ -2628,7 +2635,7 @@ private void updateCurrentBgInfoCommon(DexCollectionType collector, TextView not | |||
dialog = builder.create(); | |||
dialog.show(); | |||
} else { | |||
if (!Experience.gotData() && !QuickSettingsDialogs.isDialogShowing() && JoH.ratelimit("start-sensor_prompt", 20)) { | |||
if (!Experience.gotData() && !QuickSettingsDialogs.isDialogShowing() && JoH.ratelimit("start-sensor_prompt", 20) && !notConnectedToG6Yet) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So your !notConnectedToG6Yet
condition should come before the ratelimit as everything to the right of the ratelimit is not evaluated when the ratelimit has been exceeded. I believe in this case you would only want the ratelimit to restricting firing of the conditional block after all conditions have been met.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have looked at this again. I don't believe there is any issue:
If anything in the if statement fails to be true, like the ratelimit, we don't care, we don't want it to be true then. In that case, we want the "if" statement to fail as it did before this PR anyway.
But, if everything in the "if" statement is true, we are adding one more check. In that case, only if the user has not selected G6, or G6 is already connected, do we allow the command to be executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other words, if the user has not selected G6 or if they have and it is already connected, the dialog will be shown as it did before this PR.
However, if G6 is selected and is not connected yet, this PR does not allow the dialog to be shown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but if the user reaches the condition and the timekeeper condition is not met, but then the connection occurs in the background and would be true and the user then re-enters this conditional block again within the 20 second rate limit period, it will fail because the ratelimit has been triggered even though it otherwise would have passed if the check order is changed so the ratelimiting is last. The &&
operator means the other clauses are not evaluated once one is false. Simply checking the ratelimit by calling its method triggers the time to be stored so that the condition will fail the next time you call it within the specified time period.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm so sorry I don't follow you.
I keep comparing what xDrip does now to what I want it to do after this PR, to help me see that this PR is correct.
If ratelimit fails, xDrip does not show the dialog right now. In that case, I don't want xDrip to show the dialog after this PR either. So, I don't understand the dellima you are describing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry!
I misunderstood the purpose of the bracket. As soon as ratelimit executes, it is going to show the dialog.
Thanks for catching this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested
This doesn't seem to be conditional on using dex collection type so I think it would break for other collector types as the condition can never be met. |
Thanks for the review. This PR behaves differently than what exists currently on two occasions only and in both of those G6 has been selected. Please let me explain. Because of the following variable definition, it only becomes true if G6 has been selected. boolean notConnectedToG6Yet = Pref.getBooleanDefaultFalse("using_g6") && DexTimeKeeper.getTransmitterAgeInDays(getTransmitterID()) == -1; 1- This is the first case where this PR behaves differently than before: if (notConnectedToG6Yet) { And you can see that it happens only if the variable is true, meaning only if G6 is selected by the user. 2- This is the only other case this PR behaves differently than before: if (!Experience.gotData() && !QuickSettingsDialogs.isDialogShowing() && JoH.ratelimit("start-sensor_prompt", 20) && !notConnectedToG6Yet) { When the if condition above is true, the conditional command shows a dialog. If the user has chosen any sensor other than G6, "!notConnectedToG6Yet" will be true. In that case, the "if" condition result is not affected by this PR (A && TRUE = A). The only time the above "if" condition fails to be true due to this PR is if the user has selected a G6 and G6 is not connected yet. In that case, this change will not allow the dialog to be shown. Therefore, the xDrip behavior is not affected by this PR if any sensor other than G6 is selected. I admit that this is not very easy to understand. Again, I will make changes to address your comment about ratelimit. |
Now that the other PR is merged, should I edit this one to use the new method from it? |
Resolved conflict after refactoring to utilitymodels. Tested. Everything works fine. |
a2d5682
to
9153bba
Compare
Resolved conflicts after refactoring to models. Tested. Everything works fine. |
I think if you test by selecting G6 from the source wizard and then change collector type to Libre then your condition will still be triggered as |
Thanks for catching my error, and offering guidance. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should work and I believe you have tested it.
Yes, it is tested. |
After selecting G6 in source wizard, a red notification on the main screen asks user to start sensor or change settings.
Shortly after, a dialog appears asking user to start sensor.
This PR delays those until transmitter number of days resolves to a valid integer.
In the meantime, it shows the following instead.
This PR complements this PR: #2746
But, the two PRs are independent. Meaning if you merge only one and hold off on the other for more info, there will be no issue. It will still be a step forward,