Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef363007 authored by Andrew Chen's avatar Andrew Chen
Browse files

Merge branch 'master' of github.com:k9mail/k-9

* 'master' of github.com:k9mail/k-9:
  Work around cases where mail was last checked in the future.
  Add progress indicator during account move.
  Disable account move menu items when account is at an end of the list.
  Working version of moving accounts within the Accounts view.
  Fixes Issue 3177
  Removed some doc annotations from chrisk's fix for the service stopping issue (2777)
  Stop service(s) if not in use - Fixes Issue 2777
  optimize cketti's pop3 space-splitting code to not make lots of extra copies of responses.
  Updated Japanese translation. catch up with 20d2942a.
  Move Sender Address to end of Default Projection
  Expose SenderAddress through ContentProvider. Issue: 3665
parents 339c9f1e cbaa9f5b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -21,6 +21,10 @@
        android:title="@string/remove_account_action" />
    <item android:id="@+id/clear_pending"
        android:title="@string/clear_pending_action" />
    <item android:id="@+id/move_up"
        android:title="@string/manage_accounts_move_up_action" />
    <item android:id="@+id/move_down"
        android:title="@string/manage_accounts_move_down_action" />
    </menu>
    </item>
</menu>
+13 −6
Original line number Diff line number Diff line
@@ -109,6 +109,9 @@
    <string name="view_hide_details_action">詳細の表示/非表示</string>
    <string name="add_cc_bcc_action">Cc/Bcc追加</string>
    <string name="edit_subject_action">件名編集</string>
    <string name="read_receipt">開封確認</string>
    <string name="read_receipt_enabled">開封確認を要求します</string>
    <string name="read_receipt_disabled">開封確認を要求しません</string>
    <string name="add_attachment_action">添付追加</string>
    <string name="add_attachment_action_image">添付ファイル追加 (画像)</string>
    <string name="add_attachment_action_video">添付ファイル追加 (動画)</string>
@@ -267,6 +270,7 @@ K-9 Mail セットアップにようこそ。\nK-9 は標準のAndroidメール
    <string name="error_contact_address_not_found">メールアドレスが登録されていません</string>
    <string name="message_compose_downloading_attachments_toast">一部の添付ファイルをダウンロードしていません。このメールが送信される前に自動的にダウンロードされます。</string>
    <string name="message_compose_attachments_skipped_toast">ダウンロードしていないため、一部の添付ファイルを転送することはできません。</string>
    <string name="message_compose_show_quoted_text_action">元のメッセージを引用する</string>



@@ -559,6 +563,9 @@ K-9 Mail セットアップにようこそ。\nK-9 は標準のAndroidメール

    <string name="account_settings_composition">メール送信</string>

    <string name="account_settings_default_quoted_text_shown_label">返信時に元のメッセージを引用する</string>
    <string name="account_settings_default_quoted_text_shown_summary">返信するとき、元のメッセージをメールに挿入する</string>

    <string name="account_settings_reply_after_quote_label">引用テキストの後に返信を書く</string>
    <string name="account_settings_reply_after_quote_summary">返信するときに元のメッセージを返信の上に表示</string>

@@ -566,6 +573,9 @@ K-9 Mail セットアップにようこそ。\nK-9 は標準のAndroidメール
    <string name="account_settings_message_format_text">テキスト(画像や書式は取り除く)</string>
    <string name="account_settings_message_format_html">HTML (画像や書式を保持)</string>

    <string name="account_settings_message_read_receipt_label">開封確認</string>
    <string name="account_settings_message_read_receipt_summary">常に開封確認を要求する</string>

    <string name="account_settings_quote_style_label">返信の引用スタイル</string>
    <string name="account_settings_quote_style_prefix">引用記号 (Gmail, Pine形式)</string>
    <string name="account_settings_quote_style_header">ヘッダ (Outlook, Yahoo!, Hotmail形式)</string>
@@ -611,6 +621,8 @@ K-9 Mail セットアップにようこそ。\nK-9 は標準のAndroidメール
    <string name="account_settings_autodownload_message_size_512">512Kb</string>
    <string name="account_settings_autodownload_message_size_1024">1Mb</string>
    <string name="account_settings_autodownload_message_size_2048">2Mb</string>
    <string name="account_settings_autodownload_message_size_5120">5Mb</string>
    <string name="account_settings_autodownload_message_size_10240">10Mb</string>
    <string name="account_settings_autodownload_message_size_any">上限なし</string>

    <string name="account_settings_message_age_label">いつから同期するか</string>
@@ -1019,13 +1031,8 @@ K-9 Mail セットアップにようこそ。\nK-9 は標準のAndroidメール
    <string name="dialog_confirm_spam_title">迷惑メールフォルダへの移動の確認</string>
    <plurals name="dialog_confirm_spam_message">
        <item quantity="one">本当にこのメッセージを迷惑メールフォルダに移動しますか?</item>
        <item quantity="other">本当にこのメッセージを迷惑メールフォルダに移動しますか?</item>
        <item quantity="other">本当にこれら<xliff:g id="message_count">%1$d</xliff:g>のメッセージを迷惑メールフォルダに移動しますか?</item>
<!--
  Translators:

  Please review how to handle pluralization for your language at (1) and ajust
  the <item> elements accordingly

  Possible values for 'quantity': zero, one, two, few, many, other

  (1) http://developer.android.com/guide/topics/resources/string-resource.html#Plurals
+3 −0
Original line number Diff line number Diff line
@@ -1073,4 +1073,7 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
    <string name="attachment_save_title">Save attachment</string>
    <string name="attachment_save_desc">No file browser found. Where would you like to save this attachment?</string>

    <string name="manage_accounts_move_up_action">Move up</string>
    <string name="manage_accounts_move_down_action">Move down</string>
    
</resources>
+79 −9
Original line number Diff line number Diff line
@@ -21,7 +21,9 @@ import com.fsck.k9.view.ColorChip;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
@@ -377,19 +379,29 @@ public class Account implements BaseAccount {
        mCryptoAutoSignature = prefs.getBoolean(mUuid + ".cryptoAutoSignature", false);
    }
    

    protected synchronized void delete(Preferences preferences) {
        String[] uuids = preferences.getPreferences().getString("accountUuids", "").split(",");
    private String combineUuids(String[] uuids) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0, length = uuids.length; i < length; i++) {
            if (!uuids[i].equals(mUuid)) {
            if (sb.length() > 0) {
                sb.append(',');
            }
            sb.append(uuids[i]);
        }
        }
        String accountUuids = sb.toString();
        return accountUuids;
    }
    
    protected synchronized void delete(Preferences preferences) {
        String[] uuids = preferences.getPreferences().getString("accountUuids", "").split(",");
        String[] newUuids = new String[uuids.length - 1];
        int i = 0;
        for (String uuid : uuids) {
            if (uuid.equals(mUuid) == false) {
                newUuids[i++] = uuid;
            }
        }
        
        String accountUuids = combineUuids(newUuids);
        SharedPreferences.Editor editor = preferences.getPreferences().edit();
        editor.putString("accountUuids", accountUuids);

@@ -455,6 +467,64 @@ public class Account implements BaseAccount {
        editor.commit();
    }

    public static int findNewAccountNumber(List<Integer> accountNumbers) {
        int newAccountNumber = -1;
        Collections.sort(accountNumbers);
        for (int accountNumber : accountNumbers) {
            if (accountNumber > newAccountNumber + 1) {
                break;
            }
            newAccountNumber = accountNumber;
        }
        newAccountNumber++;
        return newAccountNumber;
    }

    public static List<Integer> getExistingAccountNumbers(Preferences preferences) {
        Account[] accounts = preferences.getAccounts();
        List<Integer> accountNumbers = new LinkedList<Integer>();
        for (int i = 0; i < accounts.length; i++) {
            accountNumbers.add(accounts[i].getAccountNumber());
        }
        return accountNumbers;
    }
    public static int generateAccountNumber(Preferences preferences) {
        List<Integer> accountNumbers = getExistingAccountNumbers(preferences);
        return findNewAccountNumber(accountNumbers);
    }
    
    public void move(Preferences preferences, boolean moveUp) {
        String[] uuids = preferences.getPreferences().getString("accountUuids", "").split(",");
        SharedPreferences.Editor editor = preferences.getPreferences().edit();
        String[] newUuids = new String[uuids.length];
        if (moveUp) {
            for (int i = 0; i < uuids.length; i++) {
                if (i > 0 && uuids[i].equals(mUuid)) {
                    newUuids[i] = newUuids[i-1];
                    newUuids[i-1] = mUuid;   
                }
                else {
                    newUuids[i] = uuids[i];
                }
            }
        }
        else {
            for (int i = uuids.length - 1; i >= 0; i--) {
                if (i < uuids.length - 1 && uuids[i].equals(mUuid)) {
                    newUuids[i] = newUuids[i+1];
                    newUuids[i+1] = mUuid;   
                }
                else {
                    newUuids[i] = uuids[i];
                }
            }
        }
        String accountUuids = combineUuids(newUuids);
        editor.putString("accountUuids", accountUuids);
        editor.commit();
        preferences.refreshAccounts();
    }
    
    public synchronized void save(Preferences preferences) {
        SharedPreferences.Editor editor = preferences.getPreferences().edit();

+38 −32
Original line number Diff line number Diff line
@@ -3,7 +3,11 @@ package com.fsck.k9;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Config;
@@ -29,7 +33,8 @@ public class Preferences {


    private Storage mStorage;
    private List<Account> accounts;
    private Map<String, Account> accounts = null;
    private List<Account> accountsInOrder = null;
    private Account newAccount;
    private Context mContext;

@@ -45,16 +50,35 @@ public class Preferences {
    }

    private synchronized void loadAccounts() {
        accounts = new HashMap<String, Account>();
        refreshAccounts();
    }

    public synchronized void refreshAccounts() {
        Map<String, Account> newAccountMap = new HashMap<String, Account>();
        accountsInOrder = new LinkedList<Account>();
        String accountUuids = getPreferences().getString("accountUuids", null);
        if ((accountUuids != null) && (accountUuids.length() != 0)) {
            String[] uuids = accountUuids.split(",");
            accounts = new ArrayList<Account>(uuids.length);
            for (String uuid : uuids) {
                accounts.add(new Account(this, uuid));
            }
                Account account = accounts.get(uuid);
                if (account != null) {
                    newAccountMap.put(uuid, account);
                    accountsInOrder.add(account);
                } else {
            accounts = new ArrayList<Account>();
                    Account newAccount = new Account(this, uuid);
                    newAccountMap.put(uuid, newAccount);
                    accountsInOrder.add(newAccount);
                }
            }
        }
        if ((newAccount != null) && newAccount.getAccountNumber() != -1) {
            newAccountMap.put(newAccount.getUuid(), newAccount);
            accountsInOrder.add(newAccount);
            newAccount = null;
        }

        accounts = newAccountMap;
    }

    /**
@@ -67,12 +91,7 @@ public class Preferences {
            loadAccounts();
        }

        if ((newAccount != null) && newAccount.getAccountNumber() != -1) {
            accounts.add(newAccount);
            newAccount = null;
        }

        return accounts.toArray(EMPTY_ACCOUNT_ARRAY);
        return accountsInOrder.toArray(EMPTY_ACCOUNT_ARRAY);
    }

    /**
@@ -81,16 +100,9 @@ public class Preferences {
     * @return all accounts with {@link Account#isAvailable(Context)}
     */
    public synchronized Collection<Account> getAvailableAccounts() {
        if (accounts == null) {
            loadAccounts();
        }

        if ((newAccount != null) && newAccount.getAccountNumber() != -1) {
            accounts.add(newAccount);
            newAccount = null;
        }
        Account[] allAccounts = getAccounts();
        Collection<Account> retval = new ArrayList<Account>(accounts.size());
        for (Account account : accounts) {
        for (Account account : allAccounts) {
            if (account.isAvailable(mContext)) {
                retval.add(account);
            }
@@ -103,28 +115,22 @@ public class Preferences {
        if (accounts == null) {
            loadAccounts();
        }
        Account account = accounts.get(uuid);

        for (Account account : accounts) {
            if (account.getUuid().equals(uuid)) {
        return account;
    }
        }

        if ((newAccount != null) && newAccount.getUuid().equals(uuid)) {
            return newAccount;
        }

        return null;
    }

    public synchronized Account newAccount() {
        newAccount = new Account(K9.app);
        accounts.put(newAccount.getUuid(), newAccount);
        accountsInOrder.add(newAccount);

        return newAccount;
    }

    public synchronized void deleteAccount(Account account) {
        accounts.remove(account);
        accounts.remove(account.getUuid());
        accountsInOrder.remove(account);
        account.delete(this);

        if (newAccount == account) {
Loading