mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-23 16:18:50 -05:00
Don't call super.onBackPressed()
MessageView contained code that would call super.onBackPressed() if the parent class had such a method (checked using reflection). But the bytecode verifier prevented loading of MessageView because it contained a (static) call to super.onBackPressed(). For this to work the method had to be called using reflection. I removed this code entirely since we don't do it in MessageList and FolderList either. And all the time it worked just fine. With that change we can re-enable support for Android 1.5-2.0.1 devices.
This commit is contained in:
parent
d0bc28bff7
commit
a69f05c5f4
@ -5,7 +5,7 @@
|
||||
android:versionName="3.913" package="com.fsck.k9"
|
||||
>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="7"
|
||||
android:minSdkVersion="3"
|
||||
android:targetSdkVersion="7"
|
||||
/>
|
||||
<supports-screens
|
||||
|
@ -27,8 +27,6 @@ import com.fsck.k9.view.SingleMessageView;
|
||||
import com.fsck.k9.view.AttachmentView.AttachmentFileDownloadCallback;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
|
||||
public class MessageView extends K9Activity implements OnClickListener {
|
||||
@ -41,27 +39,6 @@ public class MessageView extends K9Activity implements OnClickListener {
|
||||
private static final int ACTIVITY_CHOOSE_FOLDER_COPY = 2;
|
||||
private static final int ACTIVITY_CHOOSE_DIRECTORY = 3;
|
||||
|
||||
/**
|
||||
* Whether parent class have the onBackPressed() method (with no argument)
|
||||
*/
|
||||
private static final boolean HAS_SUPER_ON_BACK_METHOD;
|
||||
static {
|
||||
boolean hasOnBackMethod;
|
||||
try {
|
||||
final Class <? super MessageView > superClass = MessageView.class.getSuperclass();
|
||||
final Method method = superClass.getMethod("onBackPressed", new Class[] {});
|
||||
hasOnBackMethod = (method.getModifiers() & Modifier.PUBLIC) == Modifier.PUBLIC;
|
||||
} catch (final SecurityException e) {
|
||||
if (K9.DEBUG) {
|
||||
Log.v(K9.LOG_TAG, "Security exception while checking for 'onBackPressed' method", e);
|
||||
}
|
||||
hasOnBackMethod = false;
|
||||
} catch (final NoSuchMethodException e) {
|
||||
hasOnBackMethod = false;
|
||||
}
|
||||
HAS_SUPER_ON_BACK_METHOD = hasOnBackMethod;
|
||||
}
|
||||
|
||||
private SingleMessageView mMessageView;
|
||||
|
||||
private PgpData mPgpData;
|
||||
@ -269,8 +246,6 @@ public class MessageView extends K9Activity implements OnClickListener {
|
||||
String folder = (mMessage != null) ? mMessage.getFolder().getName() : null;
|
||||
MessageList.actionHandleFolder(this, mAccount, folder);
|
||||
finish();
|
||||
} else if (HAS_SUPER_ON_BACK_METHOD) {
|
||||
super.onBackPressed();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user