mit-cml/appinventor-sources — pull request #97 by danielamiao (2014-04-29 17:23:49+00:00)
Title: fixes a bug where PROJECTS and DESIGNER constants are switched

Original email sent to appinventor dev:

In Ode.java (appengine/src/com/google/appinventor/client/Ode.java):
-Line 149-150 sets DESIGNER to 0 and PROJECTS to 1
-Line 268 calls updateFileMenuButtons(PROJECTS) in switchToProjectsView()
-Line 279 calls updateFileMenuButtons(DESIGNER) in switchToDesignerView()

In TopToolbar.java (appengine/src/com/google/appinventor/client/TopToolbar.java):
-Line 737 implements updateFileMenuButtons function, where the comments clearly say DESIGNER is 1, while PROJECTS to 0
-This is opposite of how this function is called from Ode.java as described above

It appears this bug is not causing a problem in the current AI2 instance because:
-Line 292 of TopToolbar.java calls updateFileMenuButtons(0) explicitly after calling switchToProjectsView(), this line *should be* unnecessary but is currently preventing the bug from showing up.
-Similarly, line 371 of Ode.java calls updateFileMenuButtons(1) explicitly to display the Designer View. If the call had been updateFileMenuButtons(DESIGNER), the bug should be evident.

In addition to the above, I found the following issues where this should probably be fixed DesignToolbar.java (appengine/src/com/google/appinventor/client/DesignToolbar.java):
-Line 159 calls updateFileMenuButtons(0), which sets it to a "projects" view, I think this should be updateFileMenuButtons(DESIGNER), where DESIGNER is a constant set to 1.
-Line 269, 273, 291 and 308 all call updateFileMenuButtons(1) directly with the 1 hardcoded, which is probably not a good idea either.

I tried simply reversing the constant values DESIGNER and PROJECTS in Ode.java in my own fork, and I think that's a good fix so far. However, I wanted to run this by you so you can review it, in case I'm wrong. Feel free to correct me or make other suggestions.