Previously, everybody had to remember the preference name and the
default value. If it was ever changed, this would have to be updated
everywhere. Now, the Preferences class is responsible for talking to the
SharedPreferences functionality of ANdroid.
I've started with just the compactlayout preference, because
that is what I required for this fix.
Currently, removing the cache does the job much better. The only thing
clearing the cache doesn't do which "reset" did is removing the databases. But
we don't want to do that anyway.
If someone wants to do that, they can just deactivate or remove a repo, and it
will get wiped from the database.
The current method is quite ugly, mainly because enabling and disabling repos
uses SQL and the list item click function does not tell us whether a repo is
being enabled or disabled. For now it works, but there's room for improvement.
Both in the old and new tab managers, when entering or programmatically
selecting the third tab (id 2) the notification with id 1 (updates
notification) will be cancelled i.e. deleted.
I moved the Utils.hasApi to the protected method in Compatibility.
It was misleading having it in Utils, because it is not as simple as
putting a "if(Utils.hasApi(11)) callApi_11_method()" there.
The problem isn't when the method is executed during runtime, it is when
the class is loaded into the VM using the classloader. At that point, it
tries to verify that indeed every method you call from your class
exists, so the conditional check doesn't work, hence VerifyError's and
breakage.
The appropriate way to do it is the same way as the Android support
library does it. The goal is to have an interface which only one
implementation is every loaded at runtime. Any implementations for
versions that your device doesn't support will never get loaded, so no
VerifyErrors. If you have the support library installed in your
Android SDK, check out
extras/android/support/v4/src/java/android/support/v4/view/MenuItemCompat.java
to see how the pattern works.