1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 13:12:25 -05:00

Removed onBackPressed() magic

This commit is contained in:
cketti 2011-11-10 05:34:34 +01:00
parent 85f556e6c9
commit 14ff4d006e
11 changed files with 36 additions and 151 deletions

View File

@ -1,7 +1,6 @@
package com.fsck.k9.activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
@ -125,12 +124,9 @@ public class EditIdentity extends K9Activity {
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
saveIdentity();
return true;
}
return super.onKeyDown(keyCode, event);
public void onBackPressed() {
saveIdentity();
super.onBackPressed();
}
@Override

View File

@ -356,38 +356,18 @@ public class FolderList extends K9ListActivity {
@Override
public void onBackPressed() {
// This will be called either automatically for you on 2.0
// or later, or by the code above on earlier versions of the
// platform.
if (K9.manageBack()) {
onAccounts();
} else {
// TODO - when we move to android 2.0, uncomment this instead.
// super.onBackPressed()
finish();
super.onBackPressed();
}
}
@Override public boolean onKeyDown(int keyCode, KeyEvent event) {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//Shortcuts that work no matter what is selected
if (
// TODO - when we move to android 2.0, uncomment this.
// android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR &&
keyCode == KeyEvent.KEYCODE_BACK
&& event.getRepeatCount() == 0
&& K9.manageBack()) {
// Take care of calling this method on earlier versions of
// the platform where it doesn't exist.
onBackPressed();
return true;
}
switch (keyCode) {
case KeyEvent.KEYCODE_Q:
//case KeyEvent.KEYCODE_BACK:
{
onAccounts();
return true;

View File

@ -119,11 +119,9 @@ public class ManageIdentities extends ChooseIdentity {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
saveIdentities();
}
return super.onKeyDown(keyCode, event);
public void onBackPressed() {
saveIdentities();
super.onBackPressed();
}
private void saveIdentities() {

View File

@ -29,7 +29,6 @@ import android.os.Parcelable;
import android.provider.OpenableColumns;
import android.text.util.Rfc822Tokenizer;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -1834,13 +1833,10 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
@Override
public void onBackPressed() {
// This will be called either automatically for you on 2.0
// or later, or by the code above on earlier versions of the
// platform.
if (mDraftNeedsSaving) {
showDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
} else {
finish();
super.onBackPressed();
}
}
@ -1868,24 +1864,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
return super.onCreateDialog(id);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (
// TODO - when we move to android 2.0, uncomment this.
// android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR &&
keyCode == KeyEvent.KEYCODE_BACK
&& event.getRepeatCount() == 0
&& K9.manageBack()) {
// Take care of calling this method on earlier versions of
// the platform where it doesn't exist.
onBackPressed();
return true;
}
return super.onKeyDown(keyCode, event);
}
/**
* Returns true if all attachments were able to be attached, otherwise returns false.
*/

View File

@ -898,9 +898,6 @@ public class MessageList
@Override
public void onBackPressed() {
// This will be called either automatically for you on 2.0
// or later, or by the code above on earlier versions of the
// platform.
if (K9.manageBack()) {
if (mQueryString == null) {
onShowFolderList();
@ -908,24 +905,12 @@ public class MessageList
onAccounts();
}
} else {
finish();
super.onBackPressed();
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (
// XXX TODO - when we go to android 2.0, uncomment this
// android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR &&
keyCode == KeyEvent.KEYCODE_BACK
&& event.getRepeatCount() == 0
) {
// Take care of calling this method on earlier versions of
// the platform where it doesn't exist.
onBackPressed();
return true;
}
// Shortcuts that work no matter what is selected
switch (keyCode) {

View File

@ -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 {
@ -42,27 +40,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;
@ -150,15 +127,6 @@ public class MessageView extends K9Activity implements OnClickListener {
@Override
public boolean onKeyDown(final int keyCode, final KeyEvent event) {
if (
// XXX TODO - when we go to android 2.0, uncomment this
// android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ECLAIR &&
keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
// Take care of calling this method on earlier versions of
// the platform where it doesn't exist.
onBackPressed();
return true;
}
switch (keyCode) {
case KeyEvent.KEYCODE_VOLUME_UP: {
if (K9.useVolumeKeysForNavigationEnabled()) {
@ -263,17 +231,12 @@ public class MessageView extends K9Activity implements OnClickListener {
@Override
public void onBackPressed() {
// This will be called either automatically for you on 2.0
// or later, or by the code above on earlier versions of the
// platform.
if (K9.manageBack()) {
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();
super.onBackPressed();
}
}

View File

@ -9,7 +9,6 @@ import android.os.Bundle;
import android.os.Vibrator;
import android.preference.*;
import android.util.Log;
import android.view.KeyEvent;
import java.util.Iterator;
import java.util.Map;
@ -809,11 +808,9 @@ public class AccountSettings extends K9PreferenceActivity {
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
saveSettings();
}
return super.onKeyDown(keyCode, event);
public void onBackPressed() {
saveSettings();
super.onBackPressed();
}
private void onCompositionSettings() {

View File

@ -3,7 +3,6 @@ package com.fsck.k9.activity.setup;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.CheckBox;
@ -121,11 +120,9 @@ public class AccountSetupComposition extends K9Activity {
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
saveSettings();
}
return super.onKeyDown(keyCode, event);
public void onBackPressed() {
saveSettings();
super.onBackPressed();
}
@Override

View File

@ -8,7 +8,6 @@ import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.util.Log;
import android.view.KeyEvent;
import com.fsck.k9.*;
import com.fsck.k9.activity.K9PreferenceActivity;
import com.fsck.k9.mail.Folder.FolderClass;
@ -151,16 +150,13 @@ public class FolderSettings extends K9PreferenceActivity {
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
try {
saveSettings();
} catch (MessagingException e) {
Log.e(K9.LOG_TAG, "Saving folder settings failed", e);
}
public void onBackPressed() {
try {
saveSettings();
} catch (MessagingException e) {
Log.e(K9.LOG_TAG, "Saving folder settings failed", e);
}
return super.onKeyDown(keyCode, event);
super.onBackPressed();
}
}

View File

@ -7,7 +7,6 @@ import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.preference.*;
import android.view.KeyEvent;
import com.fsck.k9.*;
import com.fsck.k9.activity.K9PreferenceActivity;
@ -160,10 +159,8 @@ public class FontSizeSettings extends K9PreferenceActivity {
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
saveSettings();
}
return super.onKeyDown(keyCode, event);
public void onBackPressed() {
saveSettings();
super.onBackPressed();
}
}

View File

@ -17,7 +17,6 @@ import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.view.KeyEvent;
import android.widget.Toast;
import com.fsck.k9.K9;
@ -401,16 +400,15 @@ public class Prefs extends K9PreferenceActivity {
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
saveSettings();
if (K9.manageBack()) {
Accounts.listAccounts(this);
finish();
return true;
}
public void onBackPressed() {
saveSettings();
if (K9.manageBack()) {
Accounts.listAccounts(this);
finish();
} else {
super.onBackPressed();
}
return super.onKeyDown(keyCode, event);
}
private void onFontSizeSettings() {