finish() may be called from reset() which sets app to null. This issues
hits for example when clicking on wiki-link of an app which doesn't
currenty exist in client index, throws:
E/AndroidRuntime(17630): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.fdroid.fdroid/org.fdroid.fdroid.AppDetails}: java.lang.NullPointerException
E/AndroidRuntime(17630): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
E/AndroidRuntime(17630): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
E/AndroidRuntime(17630): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime(17630): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
E/AndroidRuntime(17630): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(17630): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(17630): at android.app.ActivityThread.main(ActivityThread.java:3691)
E/AndroidRuntime(17630): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(17630): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(17630): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
E/AndroidRuntime(17630): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
E/AndroidRuntime(17630): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(17630): Caused by: java.lang.NullPointerException
E/AndroidRuntime(17630): at org.fdroid.fdroid.AppDetails.finish(AppDetails.java:1012)
E/AndroidRuntime(17630): at org.fdroid.fdroid.AppDetails.reset(AppDetails.java:353)
E/AndroidRuntime(17630): at org.fdroid.fdroid.AppDetails.onCreate(AppDetails.java:243)
E/AndroidRuntime(17630): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(17630): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
Rather large rewrite, basically doing:
* Always show incompatible apps
* Don't fetch incompatible apks if the new setting is off
* Start using result codes when returning from PreferencesActivity
* Only change compact layout stuff when really needed
* No need to use StringBuilders in some cases
* No need to keep setting status and license to "" when in compact