Fix for issue 705: Sync button does not work on Honeycomb. #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I updated the commit to use Build.VERSION.SDK instead of Build.VERSION.SDK_INT.
This should fix the compatibility problem with API level 3.
Could you confirm if this works on Android 1.5?
The underlying reason for the issue is that in Honeycomb the menu items
are generated whenever the action bar is shown instead of when the user
presses the menu key on the device; as a consequence, the StudyOptions
activity will get first a disabled Sync button in the action bar (while
the deck is loading) and this will not be enabled when the deck finally
loads (or disabled when the deck is closed).
To fix this, we need to call Activity.invalidateOptionsMenu() any time
something happens that causes the options menu options to change.
However, this method is only available is API Level 11 and above. To fix
this (and future problems of this sort). I introduced a new Compat
interface which is meant to contain functions which need to be
implemented differently on different API levels.
There are a number of implementations of this interface (currently on
CompatV3 and CompatV11) which may do different things on the different
platforms: for example, there is no need to invalidate the options menu
items on any platform before Honeycomb, so
Compat.invalidOptionsMenu(Activity) is simply an empty function in
CompatV3.