mirror of
https://github.com/moparisthebest/k-9
synced 2025-03-06 03:19:42 -05:00
Added the ability to completely wipe the localy cached messages of a syncced folder.
This commit is contained in:
parent
32ea04a5b3
commit
675651286b
@ -24,6 +24,10 @@
|
|||||||
android:id="@+id/folder_settings"
|
android:id="@+id/folder_settings"
|
||||||
android:title="@string/folder_settings_action"
|
android:title="@string/folder_settings_action"
|
||||||
/>
|
/>
|
||||||
|
<item
|
||||||
|
android:id="@+id/clear_local_folder"
|
||||||
|
android:title="@string/clear_local_folder_action"
|
||||||
|
/>
|
||||||
<item
|
<item
|
||||||
android:id="@+id/expunge"
|
android:id="@+id/expunge"
|
||||||
android:title="@string/expunge_action"
|
android:title="@string/expunge_action"
|
||||||
|
@ -114,6 +114,7 @@
|
|||||||
<string name="dump_settings_action">Dump settings</string>
|
<string name="dump_settings_action">Dump settings</string>
|
||||||
<string name="empty_trash_action">Empty Trash</string>
|
<string name="empty_trash_action">Empty Trash</string>
|
||||||
<string name="expunge_action">Expunge</string>
|
<string name="expunge_action">Expunge</string>
|
||||||
|
<string name="clear_local_folder_action">Clear local messages</string>
|
||||||
<string name="set_sort_action">Choose sort</string>
|
<string name="set_sort_action">Choose sort</string>
|
||||||
<string name="reverse_sort_action">Reverse sort</string>
|
<string name="reverse_sort_action">Reverse sort</string>
|
||||||
<string name="about_action">About</string>
|
<string name="about_action">About</string>
|
||||||
|
@ -31,6 +31,7 @@ import com.fsck.k9.helper.power.TracingPowerManager.TracingWakeLock;
|
|||||||
import com.fsck.k9.mail.Flag;
|
import com.fsck.k9.mail.Flag;
|
||||||
import com.fsck.k9.mail.Folder;
|
import com.fsck.k9.mail.Folder;
|
||||||
import com.fsck.k9.mail.Message;
|
import com.fsck.k9.mail.Message;
|
||||||
|
import com.fsck.k9.mail.store.LocalStore.LocalFolder;
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.service.MailService;
|
import com.fsck.k9.service.MailService;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -538,6 +539,43 @@ public class FolderList extends K9ListActivity
|
|||||||
MessagingController.getInstance(getApplication()).expunge(account, folderName, null);
|
MessagingController.getInstance(getApplication()).expunge(account, folderName, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void onClearFolder(Account account, String folderName)
|
||||||
|
{
|
||||||
|
// There has to be a cheaper way to get at the localFolder object than this
|
||||||
|
LocalFolder localFolder = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (account == null || folderName == null || !account.isAvailable(FolderList.this))
|
||||||
|
{
|
||||||
|
Log.i(K9.LOG_TAG, "not clear folder of unavailable account");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
localFolder = account.getLocalStore().getFolder(folderName);
|
||||||
|
localFolder.open(Folder.OpenMode.READ_WRITE);
|
||||||
|
if (localFolder != null)
|
||||||
|
{
|
||||||
|
localFolder.clearAllMessages();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.e(K9.LOG_TAG, "Exception while clearing folder", e);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (localFolder != null)
|
||||||
|
{
|
||||||
|
localFolder.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void sendMail(Account account)
|
private void sendMail(Account account)
|
||||||
{
|
{
|
||||||
MessagingController.getInstance(getApplication()).sendPendingMessages(account, mAdapter.mListener);
|
MessagingController.getInstance(getApplication()).sendPendingMessages(account, mAdapter.mListener);
|
||||||
@ -675,6 +713,10 @@ public class FolderList extends K9ListActivity
|
|||||||
onExpunge(mAccount, folder.name);
|
onExpunge(mAccount, folder.name);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.clear_local_folder:
|
||||||
|
onClearFolder(mAccount,folder.name);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onContextItemSelected(item);
|
return super.onContextItemSelected(item);
|
||||||
|
@ -3475,6 +3475,22 @@ public class LocalStore extends Store implements Serializable, LocalStoreMigrati
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void clearAllMessages() throws MessagingException
|
||||||
|
{
|
||||||
|
final String where = "folder_id = ?";
|
||||||
|
final String[] params = new String[]
|
||||||
|
{
|
||||||
|
Long.toString(mFolderId)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
clearMessagesWhere(where, params);
|
||||||
|
setPushState(null);
|
||||||
|
setLastPush(0);
|
||||||
|
setLastChecked(0);
|
||||||
|
}
|
||||||
|
|
||||||
private void resetUnreadAndFlaggedCounts()
|
private void resetUnreadAndFlaggedCounts()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Loading…
x
Reference in New Issue
Block a user