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

Fix: Double tapping of TimeTravel button #238

Merged
merged 1 commit into from
Apr 28, 2019

Conversation

utkarsh530
Copy link
Contributor

Fixes #237
Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with gradlew app:connectedGmsDebugAndroidTest to make sure you didn't break anything (with an emulator running or phone connected)

  • If you have multiple commits please combine them into one commit by squashing them.

@@ -108,7 +108,7 @@ public GeocentricCoordinates getSearchLocation() {
ArrayList<TextSource> points = new ArrayList<TextSource>(proto.getLabelCount());
for (LabelElementProto element : proto.getLabelList()) {
points.add(new TextSourceImpl(getCoords(element.getLocation()),
resources.getString(element.getStringIndex()),
"TestElement",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be seen that further iterating through the implementation resource variable we find that it is an empty collection declared here. Also errors were popping up when building without this fix. Please correct me if I am wrong.

@@ -76,7 +76,7 @@ public ProtobufAstronomicalSource(AstronomicalSourceProto proto, Resources resou
if (names == null) {
names = new ArrayList<String>(proto.getNameIdsCount());
for (int id : proto.getNameIdsList()) {
names.add(resources.getString(id));
names.add("TestElement");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can be seen that further iterating through the implementation resource variable we find that it is an empty collection declared here. Also errors were popping up when building without this fix. Please correct me if I am wrong.

Copy link
Contributor

Choose a reason for hiding this comment

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

Without diving into the code again (it's been a while), I believe that this is where the names are extracted from the protocol buffer data that's bundled with the app. If you replace this with a hard-coded string I believe it will remove all astronomical names from the app, so the change should be reverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@barbeau here's the Logcat if the change is reverted
2019-03-21 20:33:33.156 19958-20073/? E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-1 Process: com.google.android.stardroid, PID: 19958 android.content.res.Resources$NotFoundException: String resource ID #0x7f0d01e1 at android.content.res.Resources.getText(Resources.java:351) at android.content.res.MiuiResources.getText(MiuiResources.java:97) at android.content.res.Resources.getString(Resources.java:445) at com.google.android.stardroid.source.proto.ProtobufAstronomicalSource.getLabels(ProtobufAstronomicalSource.java:112) at com.google.android.stardroid.layers.AbstractSourceLayer.initialize(AbstractSourceLayer.java:74) at com.google.android.stardroid.layers.AbstractFileBasedLayer.access$201(AbstractFileBasedLayer.java:46) at com.google.android.stardroid.layers.AbstractFileBasedLayer$1.run(AbstractFileBasedLayer.java:65) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)
What may had happened that Resources would have been removed after the Application was made open-source.

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you run the build_skymap.sh script?

https://github.com/sky-map-team/stardroid/tree/master/tools

Copy link
Contributor

Choose a reason for hiding this comment

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

@jaydeetay would need to weigh in, but in general it would be great to have build_skymap.sh integrated as part of the primary app Gradle build process, so when loaded into Android Studio everything would magically work. But it would need to be done carefully to ensure that all stages aren't repeated on every debug build, and some only occur on first execution or when the data changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@barbeau Could you please guide me why Travis CI build is failing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like the emulator startup isn't working - I'm guessing it's the same long-running problem I've seen here:

I haven't revisited this myself in a while, but it looks like there are other projects now running emulator-based tests on Travis - see OneBusAway/onebusaway-android#720 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So do we need to change the .travis.yml file to add support for higher API emulators?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks Utkarsh for your fixes, and Sean for answering. Yes, the current flow is pretty hideous, but it is documented in tools/README. The only reason it hasn't been integrated into gradle is I'd much rather make it go away entirely and revamp the way we store the data. As for the Travis CI build, this has been a frustration for a while.

@utkarsh530 utkarsh530 force-pushed the beta branch 2 times, most recently from 8ac029d to 98c6e69 Compare March 22, 2019 13:52
@@ -57,6 +58,7 @@
// This is the date we will apply to the controller when the user hits go.
private Calendar calendar = Calendar.getInstance();
private AstronomerModel model;
private long LastClickTime = 0;
Copy link
Member

Choose a reason for hiding this comment

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

Style nit: java variables usually start with lower case.

@@ -76,13 +78,17 @@ protected void onCreate(Bundle savedInstanceState) {
Button changeDateButton = (Button) findViewById(R.id.pickDate);
changeDateButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (SystemClock.elapsedRealtime() - LastClickTime < 1000) return;
LastClickTime = SystemClock.elapsedRealtime();
Copy link
Member

Choose a reason for hiding this comment

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

Someone else has come up with a similar solution. I'm not sure it's the way to go - what's special about 1000ms?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually 1000 ms act like limit on simultaneous clicks. It differentiates two clicks if and only if their time difference is less than 1000.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I can see that. I'm just wondering how the number was picked.

@jaydeetay
Copy link
Member

High level comment: it's generally better to have PRs focused on one particular issue (ie fix the build OR do a bug fix). Otherwise you can get a PR blocked on agreement on one part of it when the other part might be easy to agree on and merge. (Also, if you ever need to roll something back, it's easier to focus on rolling back one thing).

Lastly - an apology for my slowness at replying. Sky Map is kinda dormant and only gets attention from me now and again.

@utkarsh530
Copy link
Contributor Author

@jaydeetay No problem at all! Its really good that you are reviewing our PRs.
I'll fix the requested changes.

@utkarsh530
Copy link
Contributor Author

@jaydeetay PR is updated.

@utkarsh530 utkarsh530 changed the title Fix: Build errors and double tapping of TimeTravel button Fix: Double tapping of TimeTravel button Mar 26, 2019
@jaydeetay
Copy link
Member

Thanks! And again, sorry for slow responses. I'm probably only going to be able to do reviews once per week at best.

BTW - question for you - there seems to have been a recent uptick in people creating pull requests for Sky Map. I'm very curious - why is this? What prompted you to want to to work on this? (I'll pose the same question to the other recent contributors).

@jaydeetay
Copy link
Member

OK, it's good that the 1000ms is now a named constant. However, this seems like a 'band aid' solution rather than a complete fix. I was wondering if you'd considered disabling the buttons on click, and then re-enabling them when the dialog closes. Is that not feasible?

@jaydeetay
Copy link
Member

See also: #242

@utkarsh530
Copy link
Contributor Author

@jaydeetay So I should proceed with that fix to disable button after clicking?
We are contributing to this project since this coincides with this year's GSoC 2019 proposal ideas.

@jaydeetay
Copy link
Member

Ah thanks, that explains it. There was a thread about that here #180 last year that went cold. I don't recall signing up to anything - I wouldn't have had the time to do a decent job unfortunately. I'm a little surprised that Sky Map is on the list for GSoC without my knowledge. Or perhaps I've just forgotten.

@barbeau
Copy link
Contributor

barbeau commented Mar 31, 2019

Here's the AOSSIE 2019 project:
https://aossie.gitlab.io/#ideasModal7

...and Gitter channel:
https://gitter.im/AOSSIE/Stardroid

Looks like it's proposing a hard fork, patterned after an iOS version that was developed.

@jaydeetay
Copy link
Member

Thanks Sean.

Regarding this PR, I do think it's a bit of a bandaid that we might want to revisit, but I'm happy to try it for now and revisit.

@jaydeetay jaydeetay merged commit 2f66210 into sky-map-team:master Apr 28, 2019
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.

Change date and Time opens twice in Time Travel on rapid click
3 participants