mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Rather than manually managing the back button, try to give android better back button hinting
fix our notification -> intent behavior
This commit is contained in:
parent
e2edcd6d66
commit
22e1a3f574
@ -31,14 +31,18 @@
|
|||||||
android:label="@string/remote_control_label"
|
android:label="@string/remote_control_label"
|
||||||
android:description="@string/remote_control_desc"/>
|
android:description="@string/remote_control_desc"/>
|
||||||
<uses-permission android:name="com.fsck.k9.permission.REMOTE_CONTROL"/>
|
<uses-permission android:name="com.fsck.k9.permission.REMOTE_CONTROL"/>
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name" android:name="K9"
|
<application
|
||||||
|
android:icon="@drawable/icon"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:name="K9"
|
||||||
|
android:allowTaskReparenting="false"
|
||||||
>
|
>
|
||||||
<meta-data android:name="android.app.default_searchable"
|
<meta-data android:name="android.app.default_searchable"
|
||||||
android:value=".activity.Search" />
|
android:value=".activity.Search" />
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.fsck.k9.activity.Accounts"
|
android:name="com.fsck.k9.activity.Accounts"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleInstance"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
@ -135,7 +139,9 @@
|
|||||||
android:label="@string/debug_title">
|
android:label="@string/debug_title">
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.fsck.k9.activity.FolderList">
|
android:name="com.fsck.k9.activity.FolderList"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
>
|
||||||
<!--
|
<!--
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
@ -148,7 +154,10 @@
|
|||||||
-->
|
-->
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.fsck.k9.activity.MessageList">
|
android:name="com.fsck.k9.activity.MessageList"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
|
||||||
|
>
|
||||||
<!--
|
<!--
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
@ -37,6 +37,7 @@ import android.os.PowerManager.WakeLock;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.fsck.k9.activity.FolderList;
|
||||||
import com.fsck.k9.activity.MessageList;
|
import com.fsck.k9.activity.MessageList;
|
||||||
import com.fsck.k9.mail.Address;
|
import com.fsck.k9.mail.Address;
|
||||||
import com.fsck.k9.mail.FetchProfile;
|
import com.fsck.k9.mail.FetchProfile;
|
||||||
@ -4198,7 +4199,7 @@ public class MessagingController implements Runnable
|
|||||||
Notification notif = new Notification(R.drawable.stat_notify_email_generic, messageNotice, System.currentTimeMillis());
|
Notification notif = new Notification(R.drawable.stat_notify_email_generic, messageNotice, System.currentTimeMillis());
|
||||||
notif.number = unreadMessageCount;
|
notif.number = unreadMessageCount;
|
||||||
|
|
||||||
Intent i = MessageList.actionHandleFolderIntent(context, account, account.getAutoExpandFolderName());
|
Intent i = FolderList.actionHandleAccountIntent(context, account, account.getAutoExpandFolderName());
|
||||||
PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);
|
PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);
|
||||||
|
|
||||||
// 279 Unread (someone@gmail.com)
|
// 279 Unread (someone@gmail.com)
|
||||||
|
@ -41,32 +41,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
|||||||
private AccountsAdapter mAdapter;
|
private AccountsAdapter mAdapter;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
|
||||||
{
|
|
||||||
if (
|
|
||||||
// TODO - once we upgrade to 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.onKeyDown(keyCode, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
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.
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
class AccountsHandler extends Handler
|
class AccountsHandler extends Handler
|
||||||
{
|
{
|
||||||
private void setViewTitle()
|
private void setViewTitle()
|
||||||
@ -439,7 +413,6 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
|
|||||||
{
|
{
|
||||||
MessageList.actionHandleFolder(this, account, account.getAutoExpandFolderName());
|
MessageList.actionHandleFolder(this, account, account.getAutoExpandFolderName());
|
||||||
}
|
}
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view)
|
public void onClick(View view)
|
||||||
|
@ -245,27 +245,17 @@ public class FolderList extends K9ListActivity
|
|||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
|
|
||||||
String initialFolder;
|
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
onNewIntent(getIntent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNewIntent (Intent intent) {
|
||||||
String savedFolderName = null;
|
String savedFolderName = null;
|
||||||
Intent intent = getIntent();
|
String initialFolder;
|
||||||
mAccount = (Account)intent.getSerializableExtra(EXTRA_ACCOUNT);
|
mAccount = (Account)intent.getSerializableExtra(EXTRA_ACCOUNT);
|
||||||
|
|
||||||
if (savedInstanceState == null)
|
|
||||||
{
|
|
||||||
initialFolder = intent.getStringExtra(EXTRA_INITIAL_FOLDER);
|
initialFolder = intent.getStringExtra(EXTRA_INITIAL_FOLDER);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
initialFolder = null;
|
|
||||||
savedFolderName = savedInstanceState.getString(STATE_CURRENT_FOLDER);
|
|
||||||
if (savedFolderName != null)
|
|
||||||
{
|
|
||||||
mSelectedContextFolder = mAdapter.getFolder(savedFolderName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
initialFolder != null
|
initialFolder != null
|
||||||
&& !K9.FOLDER_NONE.equals(initialFolder))
|
&& !K9.FOLDER_NONE.equals(initialFolder))
|
||||||
@ -374,32 +364,9 @@ public class FolderList extends K9ListActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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.
|
|
||||||
onAccounts();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean onKeyDown(int keyCode, KeyEvent event)
|
@Override public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
//Shortcuts that work no matter what is selected
|
//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)
|
|
||||||
{
|
|
||||||
// Take care of calling this method on earlier versions of
|
|
||||||
// the platform where it doesn't exist.
|
|
||||||
onBackPressed();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
{
|
{
|
||||||
case KeyEvent.KEYCODE_Q:
|
case KeyEvent.KEYCODE_Q:
|
||||||
@ -527,7 +494,6 @@ public class FolderList extends K9ListActivity
|
|||||||
private void onOpenFolder(String folder)
|
private void onOpenFolder(String folder)
|
||||||
{
|
{
|
||||||
MessageList.actionHandleFolder(this, mAccount, folder);
|
MessageList.actionHandleFolder(this, mAccount, folder);
|
||||||
finish();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onCompact(Account account)
|
private void onCompact(Account account)
|
||||||
|
@ -363,14 +363,38 @@ public class MessageList
|
|||||||
|
|
||||||
mBatchDoneButton.setOnClickListener(this);
|
mBatchDoneButton.setOnClickListener(this);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
// Gesture detection
|
||||||
|
gestureDetector = new GestureDetector(new MyGestureDetector());
|
||||||
|
gestureListener = new View.OnTouchListener()
|
||||||
|
{
|
||||||
|
public boolean onTouch(View v, MotionEvent event)
|
||||||
|
{
|
||||||
|
if (gestureDetector.onTouchEvent(event))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
mListView.setOnTouchListener(gestureListener);
|
||||||
|
|
||||||
|
if (savedInstanceState != null)
|
||||||
|
{
|
||||||
|
mFolderName = savedInstanceState.getString(STATE_CURRENT_FOLDER);
|
||||||
|
mQueryString = savedInstanceState.getString(STATE_QUERY);
|
||||||
|
mSelectedCount = savedInstanceState.getInt(STATE_KEY_SELECTED_COUNT);
|
||||||
|
onRestoreListState(savedInstanceState);
|
||||||
|
}
|
||||||
|
onNewIntent(getIntent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onNewIntent(Intent intent) {
|
||||||
mAccount = (Account)intent.getSerializableExtra(EXTRA_ACCOUNT);
|
mAccount = (Account)intent.getSerializableExtra(EXTRA_ACCOUNT);
|
||||||
|
|
||||||
// Take the initial folder into account only if we are *not* restoring the
|
// Take the initial folder into account only if we are *not* restoring the
|
||||||
// activity already
|
// activity already
|
||||||
|
|
||||||
if (savedInstanceState == null)
|
|
||||||
{
|
|
||||||
mFolderName = intent.getStringExtra(EXTRA_FOLDER);
|
mFolderName = intent.getStringExtra(EXTRA_FOLDER);
|
||||||
mQueryString = intent.getStringExtra(EXTRA_QUERY);
|
mQueryString = intent.getStringExtra(EXTRA_QUERY);
|
||||||
|
|
||||||
@ -380,13 +404,6 @@ public class MessageList
|
|||||||
{
|
{
|
||||||
mFolderName = mAccount.getAutoExpandFolderName();
|
mFolderName = mAccount.getAutoExpandFolderName();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFolderName = savedInstanceState.getString(STATE_CURRENT_FOLDER);
|
|
||||||
mQueryString = savedInstanceState.getString(STATE_QUERY);
|
|
||||||
mSelectedCount = savedInstanceState.getInt(STATE_KEY_SELECTED_COUNT);
|
|
||||||
}
|
|
||||||
|
|
||||||
mAdapter = new MessageListAdapter();
|
mAdapter = new MessageListAdapter();
|
||||||
|
|
||||||
@ -407,26 +424,6 @@ public class MessageList
|
|||||||
|
|
||||||
mListView.setAdapter(mAdapter);
|
mListView.setAdapter(mAdapter);
|
||||||
|
|
||||||
if (savedInstanceState != null)
|
|
||||||
{
|
|
||||||
onRestoreListState(savedInstanceState);
|
|
||||||
}
|
|
||||||
// Gesture detection
|
|
||||||
gestureDetector = new GestureDetector(new MyGestureDetector());
|
|
||||||
gestureListener = new View.OnTouchListener()
|
|
||||||
{
|
|
||||||
public boolean onTouch(View v, MotionEvent event)
|
|
||||||
{
|
|
||||||
if (gestureDetector.onTouchEvent(event))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
mListView.setOnTouchListener(gestureListener);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,29 +515,9 @@ public class MessageList
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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.
|
|
||||||
onShowFolderList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
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
|
//Shortcuts that work no matter what is selected
|
||||||
|
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
|
@ -103,14 +103,6 @@ public class MessageView extends K9Activity
|
|||||||
private Listener mListener = new Listener();
|
private Listener mListener = new Listener();
|
||||||
private MessageViewHandler mHandler = new MessageViewHandler();
|
private MessageViewHandler mHandler = new MessageViewHandler();
|
||||||
|
|
||||||
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.
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean dispatchKeyEvent(KeyEvent event)
|
public boolean dispatchKeyEvent(KeyEvent event)
|
||||||
@ -130,16 +122,6 @@ public class MessageView extends K9Activity
|
|||||||
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event)
|
public boolean onKeyDown(int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
if (
|
|
||||||
// TODO: when we get to 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();
|
|
||||||
}
|
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
{
|
{
|
||||||
case KeyEvent.KEYCODE_DEL:
|
case KeyEvent.KEYCODE_DEL:
|
||||||
|
Loading…
Reference in New Issue
Block a user