1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-02-17 07:30:16 -05:00

Remember last selected folder for copy and move operations and scroll this folder into view on subsequent folder selections (for move and copy operations).

Fixes issue 1538
This commit is contained in:
cketti 2010-07-04 23:29:57 +00:00
parent a5a1ae7d28
commit 42b0845522
4 changed files with 109 additions and 49 deletions

View File

@ -105,6 +105,14 @@ public class Account implements BaseAccount
private String mQuotePrefix;
private boolean mSyncRemoteDeletions;
/**
* Name of the folder that was last selected for a copy or move operation.
*
* Note: For now this value isn't persisted. So it will be reset when
* K-9 Mail is restarted.
*/
private String lastSelectedFolderName = null;
private List<Identity> identities;
public enum FolderMode
@ -568,23 +576,23 @@ public class Account implements BaseAccount
}
public void setChipColor(int color)
public synchronized void setChipColor(int color)
{
mChipColor = color;
}
public int getChipColor()
public synchronized int getChipColor()
{
return mChipColor;
}
public void setLedColor(int color)
public synchronized void setLedColor(int color)
{
mLedColor = color;
}
public int getLedColor()
public synchronized int getLedColor()
{
return mLedColor;
}
@ -1033,12 +1041,12 @@ public class Account implements BaseAccount
return mDescription;
}
public void setCompression(String networkType, boolean useCompression)
public synchronized void setCompression(String networkType, boolean useCompression)
{
compressionMap.put(networkType, useCompression);
}
public boolean useCompression(String networkType)
public synchronized boolean useCompression(String networkType)
{
Boolean useCompression = compressionMap.get(networkType);
if (useCompression == null)
@ -1225,72 +1233,72 @@ public class Account implements BaseAccount
return null;
}
public Searchable getSearchableFolders()
public synchronized Searchable getSearchableFolders()
{
return searchableFolders;
}
public void setSearchableFolders(Searchable searchableFolders)
public synchronized void setSearchableFolders(Searchable searchableFolders)
{
this.searchableFolders = searchableFolders;
}
public int getIdleRefreshMinutes()
public synchronized int getIdleRefreshMinutes()
{
return mIdleRefreshMinutes;
}
public void setIdleRefreshMinutes(int idleRefreshMinutes)
public synchronized void setIdleRefreshMinutes(int idleRefreshMinutes)
{
mIdleRefreshMinutes = idleRefreshMinutes;
}
public boolean isPushPollOnConnect()
public synchronized boolean isPushPollOnConnect()
{
return mPushPollOnConnect;
}
public void setPushPollOnConnect(boolean pushPollOnConnect)
public synchronized void setPushPollOnConnect(boolean pushPollOnConnect)
{
mPushPollOnConnect = pushPollOnConnect;
}
public boolean isSaveAllHeaders()
public synchronized boolean isSaveAllHeaders()
{
return mSaveAllHeaders;
}
public void setSaveAllHeaders(boolean saveAllHeaders)
public synchronized void setSaveAllHeaders(boolean saveAllHeaders)
{
mSaveAllHeaders = saveAllHeaders;
}
public boolean goToUnreadMessageSearch()
public synchronized boolean goToUnreadMessageSearch()
{
return goToUnreadMessageSearch;
}
public void setGoToUnreadMessageSearch(boolean goToUnreadMessageSearch)
public synchronized void setGoToUnreadMessageSearch(boolean goToUnreadMessageSearch)
{
this.goToUnreadMessageSearch = goToUnreadMessageSearch;
}
public boolean subscribedFoldersOnly()
public synchronized boolean subscribedFoldersOnly()
{
return subscribedFoldersOnly;
}
public void setSubscribedFoldersOnly(boolean subscribedFoldersOnly)
public synchronized void setSubscribedFoldersOnly(boolean subscribedFoldersOnly)
{
this.subscribedFoldersOnly = subscribedFoldersOnly;
}
public int getMaximumPolledMessageAge()
public synchronized int getMaximumPolledMessageAge()
{
return maximumPolledMessageAge;
}
public void setMaximumPolledMessageAge(int maximumPolledMessageAge)
public synchronized void setMaximumPolledMessageAge(int maximumPolledMessageAge)
{
this.maximumPolledMessageAge = maximumPolledMessageAge;
}
@ -1336,23 +1344,33 @@ public class Account implements BaseAccount
}
}
public String getQuotePrefix()
public synchronized String getQuotePrefix()
{
return mQuotePrefix;
}
public void setQuotePrefix(String quotePrefix)
public synchronized void setQuotePrefix(String quotePrefix)
{
mQuotePrefix = quotePrefix;
}
public boolean syncRemoteDeletions()
public synchronized boolean syncRemoteDeletions()
{
return mSyncRemoteDeletions;
}
public void setSyncRemoteDeletions(boolean syncRemoteDeletions)
public synchronized void setSyncRemoteDeletions(boolean syncRemoteDeletions)
{
mSyncRemoteDeletions = syncRemoteDeletions;
}
public synchronized String getLastSelectedFolderName()
{
return lastSelectedFolderName;
}
public synchronized void setLastSelectedFolderName(String folderName)
{
lastSelectedFolderName = folderName;
}
}

View File

@ -23,6 +23,7 @@ import java.util.Comparator;
public class ChooseFolder extends K9ListActivity
{
String mFolder;
String mSelectFolder;
Account mAccount;
MessageReference mMessageReference;
ArrayAdapter<String> adapter;
@ -34,6 +35,7 @@ public class ChooseFolder extends K9ListActivity
public static final String EXTRA_ACCOUNT = "com.fsck.k9.ChooseFolder_account";
public static final String EXTRA_CUR_FOLDER = "com.fsck.k9.ChooseFolder_curfolder";
public static final String EXTRA_SEL_FOLDER = "com.fsck.k9.ChooseFolder_selfolder";
public static final String EXTRA_NEW_FOLDER = "com.fsck.k9.ChooseFolder_newfolder";
public static final String EXTRA_MESSAGE = "com.fsck.k9.ChooseFolder_message";
public static final String EXTRA_SHOW_CURRENT = "com.fsck.k9.ChooseFolder_showcurrent";
@ -55,6 +57,7 @@ public class ChooseFolder extends K9ListActivity
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
mMessageReference = (MessageReference)intent.getSerializableExtra(EXTRA_MESSAGE);
mFolder = intent.getStringExtra(EXTRA_CUR_FOLDER);
mSelectFolder = intent.getStringExtra(EXTRA_SEL_FOLDER);
if (intent.getStringExtra(EXTRA_SHOW_CURRENT) != null)
{
hideCurrentFolder = false;
@ -84,6 +87,7 @@ public class ChooseFolder extends K9ListActivity
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Intent intent = new Intent();
intent.putExtra(EXTRA_ACCOUNT, mAccount.getUuid());
intent.putExtra(EXTRA_CUR_FOLDER, mFolder);
String destFolderName = (String)((TextView)view).getText();
if (heldInbox != null && getString(R.string.special_mailbox_name_inbox).equals(destFolderName))
@ -119,9 +123,7 @@ public class ChooseFolder extends K9ListActivity
adapter.notifyDataSetChanged();
break;
case MSG_SET_SELECTED_FOLDER:
// TODO: I want this to highlight the chosen folder, but this doesn't work.
// getListView().setSelection(msg.arg1);
// getListView().setItemChecked(msg.arg1, true);
getListView().setSelection(msg.arg1);
break;
}
}
@ -275,18 +277,32 @@ public class ChooseFolder extends K9ListActivity
adapter.add(name);
}
if ((name.equals(mFolder) || (K9.INBOX.equalsIgnoreCase(mFolder) && K9.INBOX.equalsIgnoreCase(name))))
if (mSelectFolder != null)
{
/*
* Never select EXTRA_CUR_FOLDER (mFolder) if EXTRA_SEL_FOLDER
* (mSelectedFolder) was provided.
*/
if (name.equals(mSelectFolder))
{
selectedFolder = position;
}
}
else if (name.equals(mFolder) ||
(K9.INBOX.equalsIgnoreCase(mFolder) && K9.INBOX.equalsIgnoreCase(name)))
{
selectedFolder = position;
}
position++;
}
mHandler.dataChanged();
if (selectedFolder != -1)
{
mHandler.setSelectedFolder(selectedFolder);
}
mHandler.dataChanged();
}
};
}

View File

@ -922,9 +922,12 @@ public class MessageList
return;
}
final Account account = holder.message.getFolder().getAccount();
Intent intent = new Intent(this, ChooseFolder.class);
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, holder.message.getFolder().getAccount().getUuid());
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, account.getUuid());
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, holder.folder.name);
intent.putExtra(ChooseFolder.EXTRA_SEL_FOLDER, account.getLastSelectedFolderName());
intent.putExtra(ChooseFolder.EXTRA_MESSAGE, holder.message.makeMessageReference());
startActivityForResult(intent, ACTIVITY_CHOOSE_FOLDER_MOVE);
}
@ -943,9 +946,12 @@ public class MessageList
return;
}
final Account account = holder.message.getFolder().getAccount();
Intent intent = new Intent(this, ChooseFolder.class);
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, holder.message.getFolder().getAccount().getUuid());
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, account.getUuid());
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, holder.folder.name);
intent.putExtra(ChooseFolder.EXTRA_SEL_FOLDER, account.getLastSelectedFolderName());
intent.putExtra(ChooseFolder.EXTRA_MESSAGE, holder.message.makeMessageReference());
startActivityForResult(intent, ACTIVITY_CHOOSE_FOLDER_COPY);
}
@ -964,13 +970,16 @@ public class MessageList
if (data == null)
return;
String destFolderName = data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER);
final String destFolderName = data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER);
final MessageReference ref = (MessageReference)data.getSerializableExtra(ChooseFolder.EXTRA_MESSAGE);
final MessageInfoHolder m = mAdapter.getMessage(ref);
MessageReference ref = (MessageReference)data.getSerializableExtra(ChooseFolder.EXTRA_MESSAGE);
MessageInfoHolder m = mAdapter.getMessage(ref);
if (destFolderName != null && m != null)
if ((destFolderName != null) && (m != null))
{
final Account account = m.message.getFolder().getAccount();
account.setLastSelectedFolderName(destFolderName);
switch (requestCode)
{
case ACTIVITY_CHOOSE_FOLDER_MOVE:
@ -985,16 +994,24 @@ public class MessageList
break;
}
case ACTIVITY_CHOOSE_FOLDER_MOVE_BATCH:
{
String destFolderName = data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER);
onMoveChosenBatch(destFolderName);
break;
}
case ACTIVITY_CHOOSE_FOLDER_COPY_BATCH:
{
String destFolderName = data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER);
onCopyChosenBatch(destFolderName);
break;
final String destFolderName = data.getStringExtra(ChooseFolder.EXTRA_NEW_FOLDER);
final String accountUuid = data.getStringExtra(ChooseFolder.EXTRA_ACCOUNT);
final Account account = Preferences.getPreferences(this).getAccount(accountUuid);
account.setLastSelectedFolderName(destFolderName);
switch (requestCode)
{
case ACTIVITY_CHOOSE_FOLDER_MOVE_BATCH:
onMoveChosenBatch(destFolderName);
break;
case ACTIVITY_CHOOSE_FOLDER_COPY_BATCH:
onCopyChosenBatch(destFolderName);
break;
}
}
}
}
@ -2860,9 +2877,12 @@ public class MessageList
}
}
}
Intent intent = new Intent(this, ChooseFolder.class);
final Folder folder = mCurrentFolder.folder;
final Intent intent = new Intent(this, ChooseFolder.class);
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount.getUuid());
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, mCurrentFolder.folder.getName());
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, folder.getName());
intent.putExtra(ChooseFolder.EXTRA_SEL_FOLDER, folder.getAccount().getLastSelectedFolderName());
startActivityForResult(intent, ACTIVITY_CHOOSE_FOLDER_MOVE_BATCH);
}
private void onMoveChosenBatch(String folderName)
@ -2914,9 +2934,12 @@ public class MessageList
}
}
}
Intent intent = new Intent(this, ChooseFolder.class);
final Folder folder = mCurrentFolder.folder;
final Intent intent = new Intent(this, ChooseFolder.class);
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount.getUuid());
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, mCurrentFolder.folder.getName());
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, folder.getName());
intent.putExtra(ChooseFolder.EXTRA_SEL_FOLDER, folder.getAccount().getLastSelectedFolderName());
startActivityForResult(intent, ACTIVITY_CHOOSE_FOLDER_COPY_BATCH);
}
private void onCopyChosenBatch(String folderName)

View File

@ -1001,6 +1001,7 @@ public class MessageView extends K9Activity implements OnClickListener
Intent intent = new Intent(this, ChooseFolder.class);
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount.getUuid());
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, mMessageReference.folderName);
intent.putExtra(ChooseFolder.EXTRA_SEL_FOLDER, mAccount.getLastSelectedFolderName());
intent.putExtra(ChooseFolder.EXTRA_MESSAGE, mMessageReference);
startActivityForResult(intent, ACTIVITY_CHOOSE_FOLDER_MOVE);
}
@ -1020,6 +1021,7 @@ public class MessageView extends K9Activity implements OnClickListener
Intent intent = new Intent(this, ChooseFolder.class);
intent.putExtra(ChooseFolder.EXTRA_ACCOUNT, mAccount.getUuid());
intent.putExtra(ChooseFolder.EXTRA_CUR_FOLDER, mMessageReference.folderName);
intent.putExtra(ChooseFolder.EXTRA_SEL_FOLDER, mAccount.getLastSelectedFolderName());
intent.putExtra(ChooseFolder.EXTRA_MESSAGE, mMessageReference);
startActivityForResult(intent, ACTIVITY_CHOOSE_FOLDER_COPY);
}
@ -1080,6 +1082,7 @@ public class MessageView extends K9Activity implements OnClickListener
if (mMessageReference.equals(ref))
{
mAccount.setLastSelectedFolderName(destFolderName);
switch (requestCode)
{