1
0
mirror of https://github.com/moparisthebest/k-9 synced 2025-02-14 06:00:21 -05:00

Merge of remote branch 'origin/master' into ms-eas

This commit is contained in:
Kris Wong 2012-01-22 11:52:25 -05:00
commit e0436b13d0
9 changed files with 306 additions and 190 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="15004"
android:versionName="4.104" package="com.fsck.k9"
android:versionCode="15006"
android:versionName="4.106" package="com.fsck.k9"
>
<uses-sdk
android:minSdkVersion="7"

View File

@ -130,7 +130,7 @@
<arg line="push"/>
</exec>
<exec executable="git" failonerror="true">
<arg line="push tag ${version-name}"/>
<arg line="push origin tag ${version-name}"/>
</exec>
</target>
@ -142,7 +142,7 @@
<target name="upload" depends="clean,get-version,release">
<echo>Uploading to Google Code using Google::Code::Upload</echo>
<exec executable="mv" failonerror="true">
<arg value="${out.release.file}" />
<arg value="${out.final.file}" />
<arg value="bin/k9-${version-name}-release.apk" />
</exec>
<exec executable="googlecode_upload.pl" failonerror="true">

View File

@ -40,7 +40,7 @@
<string name="folder_progress">\u0020<xliff:g id="completed">%s</xliff:g>/<xliff:g id="total">%s</xliff:g></string>
<string name="status_next_poll">\u0020(Nova verif. às @ <xliff:g id="nexttime">%s</xliff:g>)</string>
<!-- NEW: <string name="status_syncing_off">\u0020(Syncing disabled)</string>-->
<string name="status_syncing_off">\u0020(Sincronização desabilitada)</string>
<!-- Actions will be used as buttons and in menu items -->
<string name="next_action">Próximo</string> <!-- Used as part of a multi-step process -->
@ -73,7 +73,7 @@
<string name="mark_all_as_read_action">Marcar todas as como lidas</string>
<string name="add_account_action">Incluir conta</string>
<string name="compose_action">Escrever</string>
<string name="search_action">Peaquisar</string>
<string name="search_action">Pesquisar</string>
<string name="search_results">Resultado da pesquisa</string>
<string name="preferences_action">Configurações</string>
<string name="open_action">Abrir</string>
@ -108,9 +108,9 @@
<string name="view_hide_details_action">Ver/esconder detalhes</string>
<string name="add_cc_bcc_action">Incluir Cc/Bcc</string>
<string name="edit_subject_action">Editar assunto</string>
<!-- NEW: <string name="read_receipt">Read receipt</string>-->
<!-- NEW: <string name="read_receipt_enabled">Read receipt will be requested</string>-->
<!-- NEW: <string name="read_receipt_disabled">Read receipt will not be requested</string>-->
<string name="read_receipt">Confirmação de leitura</string>
<string name="read_receipt_enabled">Confirmação de leitura será requisitada</string>
<string name="read_receipt_disabled">Confirmação de leitura não será requisitada</string>
<string name="add_attachment_action">Incluir anexo</string>
<string name="add_attachment_action_image">Incluir anexo (Imagem)</string>
<string name="add_attachment_action_video">Incluir anexo (Video)</string>
@ -127,7 +127,7 @@
<string name="folder_context_menu_title">Opções de pasta</string>
<string name="general_no_subject">(Sem assunto)</string> <!-- Shown in place of the subject when a message has no subject. Showing this in parentheses is customary. -->
<!-- NEW: <string name="general_no_date">No date</string>-->
<string name="general_no_date">Sem data</string>
<string name="general_no_sender">Sem remetente</string>
<string name="status_loading">Verificando</string>
<string name="status_loading_folder">(Verificar <xliff:g id="folder">%s</xliff:g><xliff:g id="progress">%s</xliff:g>)</string>
@ -201,7 +201,7 @@
<string name="accounts_welcome">
Bem-vindo à configuração do K-9 Mail. K-9 é um cliente de e-mail com código aberto para Android e é originalmente baseado no cliente de e-mail padrão do Android.
\n
\n\nK-9\'s recursor aprimorados incluídos:
\n\nK-9\'s recursos aprimorados incluídos:
\n * Puxar e-mail usando IMAP IDLE
\n * Melhor performance
\n * Reclassificação de mensagens
@ -253,19 +253,19 @@ Bem-vindo à configuração do K-9 Mail. K-9 é um cliente de e-mail com código
<string name="message_compose_bcc_hint">Bcc</string>
<string name="message_compose_subject_hint">Assunto</string>
<string name="message_compose_content_hint">Texto da mensagem</string>
<!-- NEW: <string name="message_compose_quote_header_separator">........ Original Message ........</string>-->
<!-- NEW: <string name="message_compose_quote_header_subject">Subject:</string>-->
<!-- NEW: <string name="message_compose_quote_header_send_date">Sent:</string>-->
<!-- NEW: <string name="message_compose_quote_header_from">From:</string>-->
<!-- NEW: <string name="message_compose_quote_header_to">To:</string>-->
<!-- NEW: <string name="message_compose_quote_header_cc">Cc:</string>-->
<string name="message_compose_quote_header_separator">........ Mensagem Original ........</string>
<string name="message_compose_quote_header_subject">Assunto:</string>
<string name="message_compose_quote_header_send_date">Enviado:</string>
<string name="message_compose_quote_header_from">De:</string>
<string name="message_compose_quote_header_to">Para:</string>
<string name="message_compose_quote_header_cc">Cc:</string>
<string name="message_compose_reply_header_fmt"><xliff:g id="sender">%s</xliff:g> escreveu:\n\n</string>
<string name="message_compose_quoted_text_label">Texto citado</string>
<string name="message_compose_error_no_recipients">Você deve incluir ao menos um destinatário.</string>
<!-- NEW: <string name="error_contact_address_not_found">No email address could be found.</string>-->
<string name="error_contact_address_not_found">Não foi possível encontrar o endereço de e-mail.</string>
<string name="message_compose_downloading_attachments_toast">Alguns anexos não foram incluídos. Eles poderão ser incluídos automaticamente antes desta mensagem ser enviada.</string>
<string name="message_compose_attachments_skipped_toast">Alguns anexos não podem ser encaminhados porque não foram inclusos na mensagem.</string>
<!-- NEW: <string name="message_compose_show_quoted_text_action">Quote message</string>-->
<string name="message_compose_show_quoted_text_action">Mensagem citada</string>
<string name="message_view_from_format">De: <xliff:g id="name">%s</xliff:g> &lt;<xliff:g id="email">%s</xliff:g>&gt;</string>
<string name="message_to_label">Para:</string>
@ -281,7 +281,7 @@ Bem-vindo à configuração do K-9 Mail. K-9 é um cliente de e-mail com código
<string name="message_view_status_attachment_saved">Anexo salvo no cartão de memória como <xliff:g id="filename">%s</xliff:g>.</string>
<string name="message_view_status_attachment_not_saved">Impossível salvar anexo no cartão de memória.</string>
<string name="message_view_show_pictures_instructions">Selecione \"Mostrar imagens\" para mostrar imagens incorporadas.</string>
<string name="message_view_show_pictures_action">Mostar imagens</string>
<string name="message_view_show_pictures_action">Mostrar imagens</string>
<string name="message_view_fetching_attachment_toast">Buscando anexo.</string>
<string name="message_view_no_viewer">Não foi possível encontrar um visualizador para <xliff:g id="mimetype">%s</xliff:g>.</string>
@ -318,8 +318,8 @@ Bem-vindo à configuração do K-9 Mail. K-9 é um cliente de e-mail com código
<string name="global_settings_touchable_label">Visualizar mensagens</string>
<string name="global_settings_touchable_summary">Itens mais espaçosos da lista com vizualização</string>
<string name="global_settings_preview_lines_label">Linhas de visualização</string>
<!-- NEW: <string name="global_settings_show_correspondent_names_label">Show correspondent names</string>-->
<!-- NEW: <string name="global_settings_show_correspondent_names_summary">Show correspondent names rather than their email addresses</string>-->
<string name="global_settings_show_correspondent_names_label">Mostrar nomes correspondentes</string>
<string name="global_settings_show_correspondent_names_summary">Mostrar nomes correspondentes ao invés de seus e-mails.</string>
<string name="global_settings_show_contact_name_label">Mostar nomes dos contatos</string>
<string name="global_settings_show_contact_name_summary">Quando disponível, utilizar nomes dos contatos para destinitário</string>
<string name="global_settings_registered_name_color_label">Colorir contatos</string>
@ -330,15 +330,15 @@ Bem-vindo à configuração do K-9 Mail. K-9 é um cliente de e-mail com código
<string name="global_settings_messageview_fixedwidth_summary">Use um tamanho fixo de fonte quando mostrar mensagens com texto simples</string>
<string name="global_settings_messageview_return_to_list_label">Retornar para lista após exclusão</string>
<string name="global_settings_messageview_return_to_list_summary">Retornar para lista de mensagem após exclusão de mensagens</string>
<!-- NEW: <string name="global_settings_messageview_show_next_label">Show next message after delete</string>-->
<!-- NEW: <string name="global_settings_messageview_show_next_summary">Show next message by default after message deletion</string>-->
<string name="global_settings_messageview_show_next_label">Mostrar próxima mensagem após exclusão</string>
<string name="global_settings_messageview_show_next_summary">Mostrar próxima mensagem por padrão após exclusão de mensagens</string>
<string name="global_settings_confirm_actions_title">Confirmar ações</string>
<string name="global_settings_confirm_actions_summary">Mostrar diálogo sempre quando for disparada uma ação</string>
<string name="global_settings_confirm_action_archive">Arquivo</string>
<string name="global_settings_confirm_action_delete">Excluir (apenas visualização)</string>
<string name="global_settings_confirm_action_spam">Spam</string>
<!-- NEW: <string name="global_settings_confirm_action_mark_all_as_read">Mark all as read</string>-->
<string name="global_settings_confirm_action_mark_all_as_read">Marcar todas como lidas</string>
<string name="global_settings_confirm_action_send">Enviar</string>
<string name="global_settings_privacy_mode_title">Notificações de bloqueio de tela</string>
@ -420,7 +420,7 @@ Bem-vindo à configuração do K-9 Mail. K-9 é um cliente de e-mail com código
<string name="account_setup_expunge_policy_on_poll">Quando verificado</string>
<string name="account_setup_expunge_policy_manual">Apenas manualmente</string>
<!-- NEW: <string name="account_setup_incoming_autodetect_namespace_label">Auto-detect IMAP namespace</string>-->
<string name="account_setup_incoming_autodetect_namespace_label">Autodetectar o namespace do IMAP</string>
<string name="account_setup_incoming_imap_path_prefix_label">Prefixo do diretório IMAP</string>
<string name="drafts_folder_label">Pasta de rascunhos</string>
@ -536,8 +536,8 @@ Bem-vindo à configuração do K-9 Mail. K-9 é um cliente de e-mail com código
<string name="account_settings_notify_self_summary">Mostar avisos para mensagens que eu envio</string>
<string name="account_settings_notification_opens_unread_label">Avisos abrem mensagens não lidas</string>
<string name="account_settings_notification_opens_unread_summary">Procurar por mensagens não lidas quando o aviso for aberto</string>
<!-- NEW: <string name="account_settings_notification_unread_count_label">Show unread count</string>-->
<!-- NEW: <string name="account_settings_notification_unread_count_summary">Show the number of unread messages in the notification bar.</string>-->
<string name="account_settings_notification_unread_count_label">Mostrar contagem de não lidas</string>
<string name="account_settings_notification_unread_count_summary">Mostrar o número de mensagens não lidas na barra de notificação.</string>
<string name="account_settings_hide_buttons_label">Navegação com botões de scroll</string>
<string name="account_settings_hide_buttons_never">Nunca</string>
@ -555,22 +555,22 @@ Bem-vindo à configuração do K-9 Mail. K-9 é um cliente de e-mail com código
<string name="account_settings_composition">Enviando e-mails</string>
<!-- NEW: <string name="account_settings_default_quoted_text_shown_label">Quote original message when replying</string>-->
<!-- NEW: <string name="account_settings_default_quoted_text_shown_summary">When replying to messages, the original message is in your reply.</string>-->
<string name="account_settings_default_quoted_text_shown_label">Citar a mensagem original ao responder</string>
<string name="account_settings_default_quoted_text_shown_summary">Ao responder mensagens, a mensagem original é colocada na sua resposta.</string>
<string name="account_settings_reply_after_quote_label">Resposta após texto da mensagem</string>
<string name="account_settings_reply_after_quote_summary">Quando respondendo mensagens, o texto original deverá aparecer acima da minha resposta.</string>
<!-- NEW: <string name="account_settings_message_format_label">Message Format</string>-->
<!-- NEW: <string name="account_settings_message_format_text">Plain Text (images and formatting will be removed)</string>-->
<!-- NEW: <string name="account_settings_message_format_html">HTML (images and formatting are preserved)</string>-->
<string name="account_settings_message_format_label">Formato da Mensagem</string>
<string name="account_settings_message_format_text">Texto (imagens e formatação serão removidas)</string>
<string name="account_settings_message_format_html">HTML (imagens e formatação serão preservadas)</string>
<!-- NEW: <string name="account_settings_message_read_receipt_label">Read receipt</string>-->
<!-- NEW: <string name="account_settings_message_read_receipt_summary">Always request a read receipt</string>-->
<string name="account_settings_message_read_receipt_label">Confirmação de leitura</string>
<string name="account_settings_message_read_receipt_summary">Sempre solicitar confirmação de leitura</string>
<!-- NEW: <string name="account_settings_quote_style_label">Reply quoting style</string>-->
<!-- NEW: <string name="account_settings_quote_style_prefix">Prefix (like Gmail, Pine)</string>-->
<!-- NEW: <string name="account_settings_quote_style_header">Header (like Outlook, Yahoo!, Hotmail)</string>-->
<string name="account_settings_quote_style_label">Estilo de citação ao responder</string>
<string name="account_settings_quote_style_prefix">Prefixo (como Gmail, Pine)</string>
<string name="account_settings_quote_style_header">Cabeçalho (como Outlook, Yahoo!, Hotmail)</string>
<string name="account_settings_general_title">Configurações gerais</string>
<string name="account_settings_display_prefs_title">Exibição</string>
@ -894,8 +894,8 @@ Bem-vindo à configuração do K-9 Mail. K-9 é um cliente de e-mail com código
<string name="gestures_title">Gestos</string>
<string name="gestures_summary">Aceitar controle de gestos</string>
<!-- NEW: <string name="compact_layouts_title">Compact layouts</string>-->
<!-- NEW: <string name="compact_layouts_summary">Adjust layouts to display more on each page</string>-->
<string name="compact_layouts_title">Layout compacto</string>
<string name="compact_layouts_summary">Ajusta o layout para mostrar mais em cada página</string>
<string name="volume_navigation_title">Tecla de volume para navegação</string>
<string name="volume_navigation_summary">Percorrer itens usando controle de volume</string>
@ -914,8 +914,8 @@ Bem-vindo à configuração do K-9 Mail. K-9 é um cliente de e-mail com código
<string name="count_search_title">Contador para resultados de pesquisa</string>
<string name="count_search_summary">Desligar visualização rápida</string>
<!-- NEW: <string name="hide_special_accounts_title">Hide special accounts</string>-->
<!-- NEW: <string name="hide_special_accounts_summary">Hide the unified inbox and all messages accounts</string>-->
<string name="hide_special_accounts_title">Esconder contas especiais</string>
<string name="hide_special_accounts_summary">Esconde a Caixa de Entrada Unificada e todas as contas de mensagens</string>
<string name="search_title"><xliff:g id="search_name">%s</xliff:g> <xliff:g id="modifier">%s</xliff:g></string>
<string name="flagged_modifier"> - Favorito</string>

View File

@ -84,6 +84,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private static final int DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED = 2;
private static final int DIALOG_CONTINUE_WITHOUT_PUBLIC_KEY = 3;
private static final long INVALID_DRAFT_ID = MessagingController.INVALID_MESSAGE_ID;
private static final String ACTION_COMPOSE = "com.fsck.k9.intent.action.COMPOSE";
private static final String ACTION_REPLY = "com.fsck.k9.intent.action.REPLY";
private static final String ACTION_REPLY_ALL = "com.fsck.k9.intent.action.REPLY_ALL";
@ -104,8 +106,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
"com.fsck.k9.activity.MessageCompose.QuotedTextShown";
private static final String STATE_KEY_SOURCE_MESSAGE_PROCED =
"com.fsck.k9.activity.MessageCompose.stateKeySourceMessageProced";
private static final String STATE_KEY_DRAFT_UID =
"com.fsck.k9.activity.MessageCompose.draftUid";
private static final String STATE_KEY_DRAFT_ID = "com.fsck.k9.activity.MessageCompose.draftId";
private static final String STATE_KEY_HTML_QUOTE = "com.fsck.k9.activity.MessageCompose.HTMLQuote";
private static final String STATE_IDENTITY_CHANGED =
"com.fsck.k9.activity.MessageCompose.identityChanged";
@ -139,7 +140,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
* Currently:
* - "Aw:" (german: abbreviation for "Antwort")
*/
private static final Pattern prefix = Pattern.compile("^AW[:\\s]\\s*", Pattern.CASE_INSENSITIVE);
private static final Pattern PREFIX = Pattern.compile("^AW[:\\s]\\s*", Pattern.CASE_INSENSITIVE);
/**
* The account used for message composition.
@ -225,13 +226,17 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private boolean mDraftNeedsSaving = false;
private boolean mPreventDraftSaving = false;
private boolean mIgnoreOnStop = false;
/**
* If this is {@code true} we don't save the message as a draft in {@link #onPause()}.
*/
private boolean mIgnoreOnPause = false;
/**
* The draft uid of this message. This is used when saving drafts so that the same draft is
* overwritten instead of being created anew. This property is null until the first save.
* The database ID of this message's draft. This is used when saving drafts so the message in
* the database is updated instead of being created anew. This property is INVALID_DRAFT_ID
* until the first save.
*/
private String mDraftUid;
private long mDraftId = INVALID_DRAFT_ID;
private Handler mHandler = new Handler() {
@Override
@ -293,11 +298,12 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
* @param account
*/
public static void actionCompose(Context context, Account account) {
if (account == null) {
account = Preferences.getPreferences(context).getDefaultAccount();
}
String accountUuid = (account == null) ?
Preferences.getPreferences(context).getDefaultAccount().getUuid() :
account.getUuid();
Intent i = new Intent(context, MessageCompose.class);
i.putExtra(EXTRA_ACCOUNT, account.getUuid());
i.putExtra(EXTRA_ACCOUNT, accountUuid);
i.setAction(ACTION_COMPOSE);
context.startActivity(i);
}
@ -441,26 +447,34 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
});
TextWatcher watcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start,
int before, int after) { }
@Override
public void beforeTextChanged(CharSequence s, int start, int before, int after) {
/* do nothing */
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
mDraftNeedsSaving = true;
}
public void afterTextChanged(android.text.Editable s) { }
@Override
public void afterTextChanged(android.text.Editable s) { /* do nothing */ }
};
// For watching changes to the To:, Cc:, and Bcc: fields for auto-encryption on a matching
// address.
TextWatcher recipientWatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start, int before, int after) { }
@Override
public void beforeTextChanged(CharSequence s, int start, int before, int after) {
/* do nothing */
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
mDraftNeedsSaving = true;
}
@Override
public void afterTextChanged(android.text.Editable s) {
final CryptoProvider crypto = mAccount.getCryptoProvider();
if (mAutoEncrypt && crypto.isAvailable(getApplicationContext())) {
@ -477,16 +491,19 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
};
TextWatcher sigwatcher = new TextWatcher() {
public void beforeTextChanged(CharSequence s, int start,
int before, int after) { }
@Override
public void beforeTextChanged(CharSequence s, int start, int before, int after) {
/* do nothing */
}
public void onTextChanged(CharSequence s, int start,
int before, int count) {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
mDraftNeedsSaving = true;
mSignatureChanged = true;
}
public void afterTextChanged(android.text.Editable s) { }
@Override
public void afterTextChanged(android.text.Editable s) { /* do nothing */ }
};
mToView.addTextChangedListener(recipientWatcher);
@ -851,7 +868,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
@Override
public void onResume() {
super.onResume();
mIgnoreOnStop = false;
mIgnoreOnPause = false;
MessagingController.getInstance(getApplication()).addListener(mListener);
}
@ -861,12 +878,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
MessagingController.getInstance(getApplication()).removeListener(mListener);
// Save email as draft when activity is changed (go to home screen, call received) or screen locked
// don't do this if only changing orientations
if ((getChangingConfigurations() & ActivityInfo.CONFIG_ORIENTATION) == 0) {
// don't do this if selecting signature or if "Encrypt" is checked or if adding an attachment
if (!mPreventDraftSaving && !mEncryptCheckbox.isChecked() && !mIgnoreOnStop) {
saveIfNeeded();
finish();
}
if (!mIgnoreOnPause && (getChangingConfigurations() & ActivityInfo.CONFIG_ORIENTATION) == 0) {
saveIfNeeded();
}
}
@ -892,7 +905,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
outState.putBoolean(STATE_KEY_BCC_SHOWN, mBccWrapper.getVisibility() == View.VISIBLE);
outState.putSerializable(STATE_KEY_QUOTED_TEXT_MODE, mQuotedTextMode);
outState.putBoolean(STATE_KEY_SOURCE_MESSAGE_PROCED, mSourceMessageProcessed);
outState.putString(STATE_KEY_DRAFT_UID, mDraftUid);
outState.putLong(STATE_KEY_DRAFT_ID, mDraftId);
outState.putSerializable(STATE_IDENTITY, mIdentity);
outState.putBoolean(STATE_IDENTITY_CHANGED, mIdentityChanged);
outState.putSerializable(STATE_PGP_DATA, mPgpData);
@ -929,7 +942,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
mQuotedHTML.loadDataWithBaseURL("http://", mQuotedHtmlContent.getQuotedContent(), "text/html", "utf-8", null);
}
}
mDraftUid = savedInstanceState.getString(STATE_KEY_DRAFT_UID);
mDraftId = savedInstanceState.getLong(STATE_KEY_DRAFT_ID);
mIdentity = (Identity)savedInstanceState.getSerializable(STATE_IDENTITY);
mIdentityChanged = savedInstanceState.getBoolean(STATE_IDENTITY_CHANGED);
mPgpData = (PgpData) savedInstanceState.getSerializable(STATE_PGP_DATA);
@ -952,6 +965,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
}
@Override
public void onFocusChange(View view, boolean focused) {
if (!focused) {
updateTitle();
@ -1319,9 +1333,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
/**
* Get the list of IdentityFields that should be integer values. These values are sanity
* checked for integer-ness during decoding.
* @return
* Get the list of IdentityFields that should be integer values.
*
* <p>
* These values are sanity checked for integer-ness during decoding.
* </p>
*
* @return The list of integer {@link IdentityField}s.
*/
public static IdentityField[] getIntegerFields() {
return new IdentityField[] { LENGTH, OFFSET, FOOTER_OFFSET, PLAIN_LENGTH, PLAIN_OFFSET };
@ -1332,19 +1350,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
// use that to determine which version we're in.
private static final String IDENTITY_VERSION_1 = "!";
/**
* Build the identity header string. This string contains metadata about a draft message to be
* used upon loading a draft for composition. This should be generated at the time of saving a
* draft.<br>
* <br>
* This is a URL-encoded key/value pair string. The list of possible values are in {@link IdentityField}.
* @param body {@link TextBody} to analyze for body length and offset.
* @return Identity string.
*/
private String buildIdentityHeader(final TextBody body) {
return buildIdentityHeader(body, null);
}
/**
* Build the identity header string. This string contains metadata about a draft message to be
* used upon loading a draft for composition. This should be generated at the time of saving a
@ -1416,8 +1421,11 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
/**
* Parse an identity string. Handles both legacy and new (!) style identities.
*
* @param identityString
* @return
* The encoded identity string that was saved in a drafts header.
*
* @return A map containing the value for each {@link IdentityField} in the identity string.
*/
private Map<IdentityField, String> parseIdentityHeader(final String identityString) {
Map<IdentityField, String> identity = new HashMap<IdentityField, String>();
@ -1488,7 +1496,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
private String appendSignature(String text) {
private String appendSignature(String originalText) {
String text = originalText;
if (mIdentity.getSignatureUse()) {
String signature = mSignatureView.getText().toString();
@ -1524,7 +1533,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private void saveIfNeeded() {
if (!mDraftNeedsSaving || mPreventDraftSaving || mPgpData.hasEncryptionKeys() ||
mEncryptCheckbox.isChecked()) {
mEncryptCheckbox.isChecked() || isDraftsFolderDisabled()) {
return;
}
@ -1608,9 +1617,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
private void onDiscard() {
if (mDraftUid != null) {
MessagingController.getInstance(getApplication()).deleteDraft(mAccount, mDraftUid);
mDraftUid = null;
if (mDraftId != INVALID_DRAFT_ID) {
MessagingController.getInstance(getApplication()).deleteDraft(mAccount, mDraftId);
mDraftId = INVALID_DRAFT_ID;
}
mHandler.sendEmptyMessage(MSG_DISCARDED_DRAFT);
mDraftNeedsSaving = false;
@ -1661,6 +1670,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
/**
* Kick off a picker for the specified MIME type and let Android take over.
*
* @param mime_type
* The MIME type we want our attachment to have.
*/
private void onAddAttachment2(final String mime_type) {
if (mAccount.getCryptoProvider().isAvailable(this)) {
@ -1669,7 +1681,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType(mime_type);
mIgnoreOnStop = true;
mIgnoreOnPause = true;
startActivityForResult(Intent.createChooser(i, null), ACTIVITY_REQUEST_PICK_ATTACHMENT);
}
@ -1705,11 +1717,12 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
name = uri.getLastPathSegment();
}
if ((contentType == null) || (contentType.indexOf('*') != -1)) {
contentType = contentResolver.getType(uri);
String usableContentType = contentType;
if ((usableContentType == null) || (usableContentType.indexOf('*') != -1)) {
usableContentType = contentResolver.getType(uri);
}
if (contentType == null) {
contentType = MimeUtility.getMimeTypeByExtension(name);
if (usableContentType == null) {
usableContentType = MimeUtility.getMimeTypeByExtension(name);
}
if (size <= 0) {
@ -1728,7 +1741,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
Attachment attachment = new Attachment();
attachment.uri = uri;
attachment.contentType = contentType;
attachment.contentType = usableContentType;
attachment.name = name;
attachment.size = size;
@ -1792,7 +1805,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
public void doLaunchContactPicker(int resultId) {
mIgnoreOnStop = true;
mIgnoreOnPause = true;
startActivityForResult(mContacts.contactPickerIntent(), resultId);
}
@ -1816,12 +1829,12 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
// test whether there is something to save
if (mDraftNeedsSaving || (mDraftUid != null)) {
final String previousDraftUid = mDraftUid;
if (mDraftNeedsSaving || (mDraftId != INVALID_DRAFT_ID)) {
final long previousDraftId = mDraftId;
final Account previousAccount = mAccount;
// make current message appear as new
mDraftUid = null;
mDraftId = INVALID_DRAFT_ID;
// actual account switch
mAccount = account;
@ -1831,13 +1844,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
saveMessage();
if (previousDraftUid != null) {
if (previousDraftId != INVALID_DRAFT_ID) {
if (K9.DEBUG) {
Log.v(K9.LOG_TAG, "Account switch, deleting draft from previous account: "
+ previousDraftUid);
+ previousDraftId);
}
MessagingController.getInstance(getApplication()).deleteDraft(previousAccount,
previousDraftUid);
previousDraftId);
}
} else {
mAccount = account;
@ -1877,6 +1890,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.attachment_delete:
@ -1987,7 +2001,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private void onChooseIdentity() {
// keep things simple: trigger account choice only if there are more
// than 1 account
mIgnoreOnStop = true;
mIgnoreOnPause = true;
if (Preferences.getPreferences(this).getAvailableAccounts().size() > 1) {
final Intent intent = new Intent(this, ChooseAccount.class);
intent.putExtra(ChooseAccount.EXTRA_ACCOUNT, mAccount.getUuid());
@ -2008,6 +2022,11 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.message_compose_option, menu);
// Disable the 'Save' menu option if Drafts folder is set to -NONE-
if (isDraftsFolderDisabled()) {
menu.findItem(R.id.save).setEnabled(false);
}
/*
* Show the menu items "Add attachment (Image)" and "Add attachment (Video)"
* if the work-around for the Gallery bug is enabled (see Issue 1186).
@ -2033,13 +2052,18 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
public void onBackPressed() {
if (mEncryptCheckbox.isChecked()) {
showDialog(DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED);
} else if (mDraftNeedsSaving) {
showDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
} else {
} else if (!mDraftNeedsSaving || isDraftsFolderDisabled()) {
Toast.makeText(MessageCompose.this, getString(R.string.message_discarded_toast), Toast.LENGTH_LONG).show();
super.onBackPressed();
} else {
showDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
}
}
private boolean isDraftsFolderDisabled() {
return mAccount.getDraftsFolderName().equals(K9.FOLDER_NONE);
}
@Override
public Dialog onCreateDialog(int id) {
switch (id) {
@ -2048,12 +2072,14 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
.setTitle(R.string.save_or_discard_draft_message_dlg_title)
.setMessage(R.string.save_or_discard_draft_message_instructions_fmt)
.setPositiveButton(R.string.save_draft_action, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
onSave();
}
})
.setNegativeButton(R.string.discard_action, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE);
onDiscard();
@ -2065,6 +2091,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
.setTitle(R.string.refuse_to_save_draft_marked_encrypted_dlg_title)
.setMessage(R.string.refuse_to_save_draft_marked_encrypted_instructions_fmt)
.setNeutralButton(R.string.okay_action, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED);
}
@ -2075,6 +2102,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
.setTitle(R.string.continue_without_public_key_dlg_title)
.setMessage(R.string.continue_without_public_key_instructions_fmt)
.setPositiveButton(R.string.continue_action, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_CONTINUE_WITHOUT_PUBLIC_KEY);
mContinueWithoutPublicKey = true;
@ -2082,6 +2110,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
})
.setNegativeButton(R.string.back_action, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
dismissDialog(DIALOG_CONTINUE_WITHOUT_PUBLIC_KEY);
mContinueWithoutPublicKey = false;
@ -2093,7 +2122,18 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
/**
* Returns true if all attachments were able to be attached, otherwise returns false.
* Add all attachments of an existing message as if they were added by hand.
*
* @param part
* The message part to check for being an attachment. This method will recurse if it's
* a multipart part.
* @param depth
* The recursion depth. Currently unused.
*
* @return {@code true} if all attachments were able to be attached, {@code false} otherwise.
*
* @throws MessagingException
* In case of an error
*/
private boolean loadAttachments(Part part, int depth) throws MessagingException {
if (part.getBody() instanceof Multipart) {
@ -2105,24 +2145,25 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
}
return ret;
} else {
String contentType = MimeUtility.unfoldAndDecode(part.getContentType());
String name = MimeUtility.getHeaderParameter(contentType, "name");
if (name != null) {
Body body = part.getBody();
if (body != null && body instanceof LocalAttachmentBody) {
final Uri uri = ((LocalAttachmentBody) body).getContentUri();
mHandler.post(new Runnable() {
public void run() {
addAttachment(uri);
}
});
} else {
return false;
}
}
return true;
}
String contentType = MimeUtility.unfoldAndDecode(part.getContentType());
String name = MimeUtility.getHeaderParameter(contentType, "name");
if (name != null) {
Body body = part.getBody();
if (body != null && body instanceof LocalAttachmentBody) {
final Uri uri = ((LocalAttachmentBody) body).getContentUri();
mHandler.post(new Runnable() {
@Override
public void run() {
addAttachment(uri);
}
});
} else {
return false;
}
}
return true;
}
/**
@ -2135,7 +2176,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
try {
if (ACTION_REPLY.equals(action) || ACTION_REPLY_ALL.equals(action)) {
if (message.getSubject() != null) {
final String subject = prefix.matcher(message.getSubject()).replaceFirst("");
final String subject = PREFIX.matcher(message.getSubject()).replaceFirst("");
if (!subject.toLowerCase(Locale.US).startsWith("re:")) {
mSubjectView.setText("Re: " + subject);
@ -2253,7 +2294,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
} else if (ACTION_EDIT_DRAFT.equals(action)) {
String showQuotedTextMode = "NONE";
mDraftUid = message.getUid();
mDraftId = MessagingController.getInstance(getApplication()).getId(message);
mSubjectView.setText(message.getSubject());
addAddresses(mToView, message.getRecipients(RecipientType.TO));
if (message.getRecipients(RecipientType.CC).length > 0) {
@ -2496,9 +2537,13 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
/**
* Build and populate the UI with the quoted message.
*
* @param showQuotedText
* {@code true} if the quoted text should be shown, {@code false} otherwise.
*
* @throws MessagingException
*/
private void populateUIWithQuotedMessage(boolean shown) throws MessagingException {
private void populateUIWithQuotedMessage(boolean showQuotedText) throws MessagingException {
if (mMessageFormat == MessageFormat.AUTO) {
mMessageFormat = MimeUtility.findFirstPartByMimeType(mSourceMessage, "text/html") == null
? MessageFormat.TEXT
@ -2603,7 +2648,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
mQuotedText.setText(quoteOriginalTextMessage(mSourceMessage, content, mQuoteStyle));
}
if (shown) {
if (showQuotedText) {
showOrHideQuotedText(QuotedTextMode.SHOW);
} else {
showOrHideQuotedText(QuotedTextMode.HIDE);
@ -2811,6 +2856,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
mSourceMessage = message;
runOnUiThread(new Runnable() {
@Override
public void run() {
// We check to see if we've previously processed the source message since this
// could be called when switching from HTML to text replies. If that happens, we
@ -2843,14 +2889,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
@Override
public void messageUidChanged(Account account, String folder, String oldUid, String newUid) {
//TODO: is this really necessary here? mDraftUid is update after the call to MessagingController.saveDraft()
// Track UID changes of the draft message
if (account.equals(mAccount) &&
folder.equals(mAccount.getDraftsFolderName()) &&
oldUid.equals(mDraftUid)) {
mDraftUid = newUid;
}
// Track UID changes of the source message
if (mMessageReference != null) {
final Account sourceAccount = Preferences.getPreferences(MessageCompose.this).getAccount(mMessageReference.accountUuid);
@ -2872,6 +2910,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
/**
* When we are launched with an intent that includes a mailto: URI, we can actually
* gather quite a few of our message fields from it.
*
* @param mailtoUri
* The mailto: URI we use to initialize the message fields.
*/
private void initializeFromMailto(Uri mailtoUri) {
String schemaSpecific = mailtoUri.getSchemeSpecificPart();
@ -2946,9 +2987,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
MessagingController.getInstance(getApplication()).sendMessage(mAccount, message, null);
if (mDraftUid != null) {
MessagingController.getInstance(getApplication()).deleteDraft(mAccount, mDraftUid);
mDraftUid = null;
if (mDraftId != INVALID_DRAFT_ID) {
MessagingController.getInstance(getApplication()).deleteDraft(mAccount, mDraftId);
mDraftId = INVALID_DRAFT_ID;
}
return null;
@ -2972,9 +3013,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
/*
* Save a draft
*/
if (mDraftUid != null) {
message.setUid(mDraftUid);
} else if (ACTION_EDIT_DRAFT.equals(getIntent().getAction())) {
if (ACTION_EDIT_DRAFT.equals(getIntent().getAction())) {
/*
* We're saving a previously saved draft, so update the new message's uid
* to the old message's uid.
@ -2985,8 +3024,8 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
}
final MessagingController messagingController = MessagingController.getInstance(getApplication());
Message draftMessage = messagingController.saveDraft(mAccount, message);
mDraftUid = draftMessage.getUid();
Message draftMessage = messagingController.saveDraft(mAccount, message, mDraftId);
mDraftId = messagingController.getId(draftMessage);
mHandler.sendEmptyMessage(MSG_SAVED_DRAFT);
return null;

View File

@ -804,9 +804,17 @@ public class MessageList
sortDateAscending = mController.isSortAscending(SORT_TYPE.SORT_DATE);
mController.addListener(mAdapter.mListener);
Account[] accountsWithNotification;
if (mAccount != null) {
mController.notifyAccountCancel(this, mAccount);
MessagingController.getInstance(getApplication()).notifyAccountCancel(this, mAccount);
accountsWithNotification = new Account[] { mAccount };
} else {
Preferences preferences = Preferences.getPreferences(this);
accountsWithNotification = preferences.getAccounts();
}
for (Account accountWithNotification : accountsWithNotification) {
mController.notifyAccountCancel(this, accountWithNotification);
}
if (mAdapter.messages.isEmpty()) {

View File

@ -79,6 +79,7 @@ import com.fsck.k9.mail.store.LocalStore.PendingCommand;
* removed from the queue once the activity is no longer active.
*/
public class MessagingController implements Runnable {
public static final long INVALID_MESSAGE_ID = -1;
/**
* Immutable empty {@link String} array
@ -3455,12 +3456,13 @@ public class MessagingController implements Runnable {
});
}
public void deleteDraft(final Account account, String uid) {
public void deleteDraft(final Account account, long id) {
LocalFolder localFolder = null;
try {
LocalStore localStore = account.getLocalStore();
localFolder = localStore.getFolder(account.getDraftsFolderName());
localFolder.open(OpenMode.READ_WRITE);
String uid = localFolder.getMessageUidById(id);
Message message = localFolder.getMessage(uid);
if (message != null) {
deleteMessages(new Message[] { message }, null);
@ -4212,12 +4214,18 @@ public class MessagingController implements Runnable {
* @param message Message to save.
* @return Message representing the entry in the local store.
*/
public Message saveDraft(final Account account, final Message message) {
public Message saveDraft(final Account account, final Message message, long existingDraftId) {
Message localMessage = null;
try {
LocalStore localStore = account.getLocalStore();
LocalFolder localFolder = localStore.getFolder(account.getDraftsFolderName());
localFolder.open(OpenMode.READ_WRITE);
if (existingDraftId != INVALID_MESSAGE_ID) {
String uid = localFolder.getMessageUidById(existingDraftId);
message.setUid(uid);
}
// Save the message to the store.
localFolder.appendMessages(new Message[] {
message
@ -4242,6 +4250,18 @@ public class MessagingController implements Runnable {
return localMessage;
}
public long getId(Message message) {
long id;
if (message instanceof LocalMessage) {
id = ((LocalMessage) message).getId();
} else {
Log.w(K9.LOG_TAG, "MessagingController.getId() called without a LocalMessage");
id = INVALID_MESSAGE_ID;
}
return id;
}
public boolean modeMismatch(Account.FolderMode aMode, Folder.FolderClass fMode) {
if (aMode == Account.FolderMode.NONE
|| (aMode == Account.FolderMode.FIRST_CLASS &&

View File

@ -992,7 +992,8 @@ public class ImapStore extends Store {
return true;
} catch (IOException ioe) {
throw ioExceptionHandler(mConnection, ioe);
} catch (MessagingException me) {
} catch (ImapException ie) {
// We got a response, but it was not "OK"
return false;
}
}
@ -1020,7 +1021,8 @@ public class ImapStore extends Store {
encodeString(encodeFolderName(getPrefixedName()))));
mExists = true;
return true;
} catch (MessagingException me) {
} catch (ImapException ie) {
// We got a response, but it was not "OK"
return false;
} catch (IOException ioe) {
throw ioExceptionHandler(connection, ioe);
@ -1050,7 +1052,8 @@ public class ImapStore extends Store {
connection.executeSimpleCommand(String.format("CREATE %s",
encodeString(encodeFolderName(getPrefixedName()))));
return true;
} catch (MessagingException me) {
} catch (ImapException ie) {
// We got a response, but it was not "OK"
return false;
} catch (IOException ioe) {
throw ioExceptionHandler(mConnection, ioe);
@ -1363,8 +1366,8 @@ public class ImapStore extends Store {
if (fp.contains(FetchProfile.Item.ENVELOPE)) {
fetchFields.add("INTERNALDATE");
fetchFields.add("RFC822.SIZE");
fetchFields.add("BODY.PEEK[HEADER.FIELDS (date subject from content-type to cc reply-to "
+ K9.IDENTITY_HEADER + ")]");
fetchFields.add("BODY.PEEK[HEADER.FIELDS (date subject from content-type to cc " +
"reply-to message-id " + K9.IDENTITY_HEADER + ")]");
}
if (fp.contains(FetchProfile.Item.STRUCTURE)) {
fetchFields.add("BODYSTRUCTURE");

View File

@ -1822,6 +1822,39 @@ public class LocalStore extends Store implements Serializable {
});
}
public String getMessageUidById(final long id) throws MessagingException {
try {
return database.execute(false, new DbCallback<String>() {
@Override
public String doDbWork(final SQLiteDatabase db) throws WrappedException, UnavailableStorageException {
try {
open(OpenMode.READ_WRITE);
Cursor cursor = null;
try {
cursor = db.rawQuery(
"SELECT uid FROM messages " +
"WHERE id = ? AND folder_id = ?",
new String[] {
Long.toString(id), Long.toString(mFolderId)
});
if (!cursor.moveToNext()) {
return null;
}
return cursor.getString(0);
} finally {
Utility.closeQuietly(cursor);
}
} catch (MessagingException e) {
throw new WrappedException(e);
}
}
});
} catch (WrappedException e) {
throw(MessagingException) e.getCause();
}
}
@Override
public Message getMessage(final String uid) throws MessagingException {
try {
@ -2043,9 +2076,9 @@ public class LocalStore extends Store implements Serializable {
/**
* The method differs slightly from the contract; If an incoming message already has a uid
* assigned and it matches the uid of an existing message then this message will replace the
* old message. It is implemented as a delete/insert. This functionality is used in saving
* of drafts and re-synchronization of updated server messages.
* assigned and it matches the uid of an existing message then this message will replace
* the old message. This functionality is used in saving of drafts and re-synchronization
* of updated server messages.
*
* NOTE that although this method is located in the LocalStore class, it is not guaranteed
* that the messages supplied as parameters are actually {@link LocalMessage} instances (in
@ -2066,6 +2099,7 @@ public class LocalStore extends Store implements Serializable {
throw new Error("LocalStore can only store Messages that extend MimeMessage");
}
long oldMessageId = -1;
String uid = message.getUid();
if (uid == null || copy) {
uid = K9.LOCAL_UID_PREFIX + UUID.randomUUID().toString();
@ -2073,20 +2107,20 @@ public class LocalStore extends Store implements Serializable {
message.setUid(uid);
}
} else {
Message oldMessage = getMessage(uid);
if (oldMessage != null && !oldMessage.isSet(Flag.SEEN)) {
setUnreadMessageCount(getUnreadMessageCount() - 1);
LocalMessage oldMessage = (LocalMessage) getMessage(uid);
if (oldMessage != null) {
oldMessageId = oldMessage.getId();
if (!oldMessage.isSet(Flag.SEEN)) {
setUnreadMessageCount(getUnreadMessageCount() - 1);
}
if (oldMessage.isSet(Flag.FLAGGED)) {
setFlaggedMessageCount(getFlaggedMessageCount() - 1);
}
}
if (oldMessage != null && oldMessage.isSet(Flag.FLAGGED)) {
setFlaggedMessageCount(getFlaggedMessageCount() - 1);
}
/*
* The message may already exist in this Folder, so delete it first.
*/
deleteAttachments(message.getUid());
db.execSQL("DELETE FROM messages WHERE folder_id = ? AND uid = ?",
new Object[]
{ mFolderId, message.getUid() });
}
ArrayList<Part> viewables = new ArrayList<Part>();
@ -2156,7 +2190,13 @@ public class LocalStore extends Store implements Serializable {
cv.put("message_id", messageId);
}
long messageUid;
messageUid = db.insert("messages", "uid", cv);
if (oldMessageId == -1) {
messageUid = db.insert("messages", "uid", cv);
} else {
db.update("messages", cv, "id = ?", new String[] { Long.toString(oldMessageId) });
messageUid = oldMessageId;
}
for (Part attachment : attachments) {
saveAttachment(messageUid, attachment, copy);
}

View File

@ -214,7 +214,6 @@ public class SettingsImporter {
if (accountUuids != null && accountUuids.size() > 0) {
if (imported.accounts != null) {
List<String> newUuids = new ArrayList<String>();
for (String accountUuid : accountUuids) {
if (imported.accounts.containsKey(accountUuid)) {
ImportedAccount account = imported.accounts.get(accountUuid);
@ -224,16 +223,33 @@ public class SettingsImporter {
AccountDescriptionPair importResult = importAccount(context,
editor, imported.contentVersion, account, overwrite);
String newUuid = importResult.imported.uuid;
if (!importResult.overwritten) {
newUuids.add(newUuid);
}
if (editor.commit()) {
if (K9.DEBUG) {
Log.v(K9.LOG_TAG, "Committed settings for account \"" +
importResult.imported.name +
"\" to the settings database.");
}
// Add UUID of the account we just imported to the list of
// account UUIDs
if (!importResult.overwritten) {
editor = storage.edit();
String newUuid = importResult.imported.uuid;
String oldAccountUuids = storage.getString("accountUuids", "");
String newAccountUuids = (oldAccountUuids.length() > 0) ?
oldAccountUuids + "," + newUuid : newUuid;
putString(editor, "accountUuids", newAccountUuids);
if (!editor.commit()) {
throw new SettingsImportExportException("Failed to set account UUID list");
}
}
// Reload accounts
preferences.loadAccounts();
importedAccounts.add(importResult);
} else {
if (K9.DEBUG) {
@ -262,16 +278,6 @@ public class SettingsImporter {
SharedPreferences.Editor editor = storage.edit();
if (newUuids.size() > 0) {
String oldAccountUuids = storage.getString("accountUuids", "");
String appendUuids = Utility.combine(newUuids.toArray(new String[0]), ',');
String prefix = "";
if (oldAccountUuids.length() > 0) {
prefix = oldAccountUuids + ",";
}
putString(editor, "accountUuids", prefix + appendUuids);
}
String defaultAccountUuid = storage.getString("defaultAccountUuid", null);
if (defaultAccountUuid == null) {
putString(editor, "defaultAccountUuid", accountUuids.get(0));