diff --git a/k9mail/src/main/java/com/fsck/k9/activity/Accounts.java b/k9mail/src/main/java/com/fsck/k9/activity/Accounts.java index 840689146..9477cb135 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/Accounts.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/Accounts.java @@ -1283,7 +1283,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { new String[] {"Android-PullToRefresh", "https://github.com/chrisbanes/Android-PullToRefresh"}, new String[] {"ckChangeLog", "https://github.com/cketti/ckChangeLog"}, new String[] {"HoloColorPicker", "https://github.com/LarsWerkman/HoloColorPicker"}, - new String[] {"Glide", "https://github.com/bumptech/glide"} + new String[] {"Glide", "https://github.com/bumptech/glide"}, + new String[] {"TokenAutoComplete", "https://github.com/splitwise/TokenAutoComplete/"}, }; private void onAbout() { diff --git a/k9mail/src/main/java/com/fsck/k9/activity/CryptoSettingsDialog.java b/k9mail/src/main/java/com/fsck/k9/activity/CryptoSettingsDialog.java index 2768e1b69..38cb73d1a 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/CryptoSettingsDialog.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/CryptoSettingsDialog.java @@ -14,16 +14,16 @@ import android.view.View; import com.fsck.k9.R; import com.fsck.k9.activity.RecipientPresenter.CryptoMode; -import com.fsck.k9.view.CryptoStatusSelector; -import com.fsck.k9.view.CryptoStatusSelector.CryptoStatusSelectedListener; +import com.fsck.k9.view.CryptoModeSelector; +import com.fsck.k9.view.CryptoModeSelector.CryptoStatusSelectedListener; import com.fsck.k9.view.LinearViewAnimator; public class CryptoSettingsDialog extends DialogFragment implements CryptoStatusSelectedListener { - public static final String ARG_CURRENT_MODE = "current_override"; + private static final String ARG_CURRENT_MODE = "current_override"; - private CryptoStatusSelector cryptoStatusSelector; + private CryptoModeSelector cryptoModeSelector; private LinearViewAnimator cryptoStatusText; private CryptoMode currentMode; @@ -42,10 +42,10 @@ public class CryptoSettingsDialog extends DialogFragment implements CryptoStatus public Dialog onCreateDialog(Bundle savedInstanceState) { @SuppressLint("InflateParams") View view = LayoutInflater.from(getActivity()).inflate(R.layout.crypto_settings_dialog, null); - cryptoStatusSelector = (CryptoStatusSelector) view.findViewById(R.id.crypto_status_selector); + cryptoModeSelector = (CryptoModeSelector) view.findViewById(R.id.crypto_status_selector); cryptoStatusText = (LinearViewAnimator) view.findViewById(R.id.crypto_status_text); - cryptoStatusSelector.setCryptoStatusListener(this); + cryptoModeSelector.setCryptoStatusListener(this); Bundle arguments = savedInstanceState != null ? savedInstanceState : getArguments(); currentMode = CryptoMode.valueOf(arguments.getString(ARG_CURRENT_MODE)); @@ -53,7 +53,7 @@ public class CryptoSettingsDialog extends DialogFragment implements CryptoStatus AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(view); - builder.setPositiveButton("Proceed", new OnClickListener() { + builder.setPositiveButton(R.string.crypto_settings_ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); @@ -66,15 +66,15 @@ public class CryptoSettingsDialog extends DialogFragment implements CryptoStatus void updateView(boolean animate) { switch (currentMode) { case DISABLE: - cryptoStatusSelector.setCryptoStatus(0); + cryptoModeSelector.setCryptoStatus(0); cryptoStatusText.setDisplayedChild(0, animate); break; case SIGN_ONLY: - cryptoStatusSelector.setCryptoStatus(1); + cryptoModeSelector.setCryptoStatus(1); cryptoStatusText.setDisplayedChild(1, animate); break; case OPPORTUNISTIC: - cryptoStatusSelector.setCryptoStatus(2); + cryptoModeSelector.setCryptoStatus(2); cryptoStatusText.setDisplayedChild(2, animate); break; } @@ -103,8 +103,16 @@ public class CryptoSettingsDialog extends DialogFragment implements CryptoStatus // is this supposed to happen? return; } + boolean activityIsCryptoModeChangedListener = activity instanceof OnCryptoModeChangedListener; + if (!activityIsCryptoModeChangedListener) { + throw new AssertionError("This dialog must be called by an OnCryptoModeChangedListener!"); + } - ((MessageCompose) activity).onCryptoModeChanged(currentMode); + ((OnCryptoModeChangedListener) activity).onCryptoModeChanged(currentMode); + } + + interface OnCryptoModeChangedListener { + void onCryptoModeChanged(CryptoMode cryptoMode); } } diff --git a/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java b/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java index 9e0169175..c25bd3bd7 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/MessageCompose.java @@ -72,6 +72,7 @@ import com.fsck.k9.Identity; import com.fsck.k9.K9; import com.fsck.k9.Preferences; import com.fsck.k9.R; +import com.fsck.k9.activity.CryptoSettingsDialog.OnCryptoModeChangedListener; import com.fsck.k9.activity.RecipientPresenter.CryptoMode; import com.fsck.k9.activity.loader.AttachmentContentLoader; import com.fsck.k9.activity.loader.AttachmentInfoLoader; @@ -116,7 +117,7 @@ import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpServiceConnection; public class MessageCompose extends K9Activity implements OnClickListener, - CancelListener, OnFocusChangeListener { + CancelListener, OnFocusChangeListener, OnCryptoModeChangedListener { private static final int DIALOG_SAVE_OR_DISCARD_DRAFT_MESSAGE = 1; private static final int DIALOG_REFUSE_TO_SAVE_DRAFT_MARKED_ENCRYPTED = 2; @@ -174,6 +175,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, private static final int ACTIVITY_REQUEST_PICK_ATTACHMENT = 1; private static final int REQUEST_CODE_SIGN_ENCRYPT = 12; + private static final int REQUEST_MASK_RECIPIENT_PRESENTER = (1<<8); /** * Regular expression to remove the first localized "Re:" prefix in subjects. @@ -246,8 +248,9 @@ public class MessageCompose extends K9Activity implements OnClickListener, } } - public void onCryptoModeChanged(CryptoMode type) { - recipientPresenter.onCryptoModeChanged(type); + @Override + public void onCryptoModeChanged(CryptoMode cryptoMode) { + recipientPresenter.onCryptoModeChanged(cryptoMode); } enum Action { @@ -550,13 +553,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, mChooseIdentityButton = (TextView) findViewById(R.id.identity); mChooseIdentityButton.setOnClickListener(this); - /* - if (mAccount.getIdentities().size() == 1 && - Preferences.getPreferences(this).getAvailableAccounts().size() == 1) { - mChooseIdentityButton.setVisibility(View.GONE); - } - */ - RecipientView recipientView = new RecipientView(this); recipientPresenter = new RecipientPresenter(this, recipientView, mAccount); @@ -698,7 +694,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, if (mAction != Action.EDIT_DRAFT) { String alwaysBccString = mAccount.getAlwaysBcc(); if (!TextUtils.isEmpty(alwaysBccString)) { - recipientPresenter.addBccAddresses(new Address(alwaysBccString, "")); + recipientPresenter.addBccAddresses(Address.parse(alwaysBccString)); } } } @@ -713,7 +709,7 @@ public class MessageCompose extends K9Activity implements OnClickListener, mMessageContentView.requestFocus(); } else { // Explicitly set focus to "To:" input field (see issue 2998) - recipientView.toFieldRequestFocus(); + recipientView.requestFocusOnToFied(); } if (mAction == Action.FORWARD) { @@ -766,7 +762,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, } else { mEncryptLayout.setVisibility(View.GONE); } - mEncryptLayout.setVisibility(View.GONE); // Set font size of input controls int fontSize = mFontSizes.getMessageComposeInput(); @@ -1539,22 +1534,11 @@ public class MessageCompose extends K9Activity implements OnClickListener, } } - private static final int REQUEST_MASK_RECIPIENT_PRESENTER = (1<<8); - public void showContactPicker(int requestCode) { requestCode |= REQUEST_MASK_RECIPIENT_PRESENTER; startActivityForResult(mContacts.contactPickerIntent(), requestCode); } - private Boolean hasContactPicker; - - public boolean hasContactPicker() { - if (hasContactPicker == null) { - hasContactPicker = !(getPackageManager().queryIntentActivities(mContacts.contactPickerIntent(), 0).isEmpty()); - } - return hasContactPicker; - } - @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { // if a CryptoSystem activity is returning, then mPreventDraftSaving was set to true diff --git a/k9mail/src/main/java/com/fsck/k9/activity/RecipientAdapter.java b/k9mail/src/main/java/com/fsck/k9/activity/RecipientAdapter.java index 4f96e7cf5..8a524ee1b 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/RecipientAdapter.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/RecipientAdapter.java @@ -24,9 +24,8 @@ import com.fsck.k9.view.RecipientSelectView.RecipientCryptoStatus; public class RecipientAdapter extends BaseAdapter implements Filterable { - List recipients; - boolean showCryptoStatus = true; - Context context; + private final Context context; + private List recipients; public RecipientAdapter(Context context) { super(); @@ -83,12 +82,6 @@ public class RecipientAdapter extends BaseAdapter implements Filterable { setContactPhotoOrPlaceholder(context, holder.photo, recipient); - if (!showCryptoStatus) { - holder.cryptoStatus.setVisibility(View.GONE); - return; - } - holder.cryptoStatus.setVisibility(View.VISIBLE); - Integer cryptoStatusRes = null, cryptoStatusColor = null; RecipientCryptoStatus cryptoStatus = recipient.getCryptoStatus(); switch (cryptoStatus) { @@ -122,6 +115,7 @@ public class RecipientAdapter extends BaseAdapter implements Filterable { public static void setContactPhotoOrPlaceholder(Context context, ImageView imageView, Recipient recipient) { imageView.setImageDrawable(null); + // TODO don't use two different mechanisms for loading! if (recipient.photoThumbnailUri != null) { Glide.with(context).load(recipient.photoThumbnailUri).into(imageView); } else { @@ -150,10 +144,11 @@ public class RecipientAdapter extends BaseAdapter implements Filterable { }; } - static class RecipientTokenHolder { - TextView name, email; - ImageView photo; - ImageView cryptoStatus; + private static class RecipientTokenHolder { + public final TextView name; + public final TextView email; + public final ImageView photo; + public final ImageView cryptoStatus; public RecipientTokenHolder(View view) { name = (TextView) view.findViewById(R.id.text1); diff --git a/k9mail/src/main/java/com/fsck/k9/activity/RecipientLoader.java b/k9mail/src/main/java/com/fsck/k9/activity/RecipientLoader.java index d153cf561..634b4c5cd 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/RecipientLoader.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/RecipientLoader.java @@ -5,14 +5,10 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import android.annotation.TargetApi; import android.content.AsyncTaskLoader; import android.content.Context; import android.database.Cursor; import android.net.Uri; -import android.os.Build.VERSION_CODES; -import android.os.CancellationSignal; -import android.os.OperationCanceledException; import android.provider.ContactsContract; import com.fsck.k9.mail.Address; @@ -20,7 +16,6 @@ import com.fsck.k9.view.RecipientSelectView.Recipient; import com.fsck.k9.view.RecipientSelectView.RecipientCryptoStatus; -@TargetApi(VERSION_CODES.JELLY_BEAN) // TODO get rid of this, affects cancellation behavior! public class RecipientLoader extends AsyncTaskLoader> { /** Indexes of the fields in the projection. This must match the order in @@ -57,7 +52,6 @@ public class RecipientLoader extends AsyncTaskLoader> { private List cachedRecipients; private ForceLoadContentObserver observerContact, observerKey; - private CancellationSignal mCancellationSignal; public RecipientLoader(Context context, String cryptoProvider, String query) { super(context); @@ -85,43 +79,28 @@ public class RecipientLoader extends AsyncTaskLoader> { @Override public List loadInBackground() { + ArrayList recipients = new ArrayList(); + HashMap recipientMap = new HashMap(); - synchronized (this) { - if (isLoadInBackgroundCanceled()) { - throw new OperationCanceledException(); - } - mCancellationSignal = new CancellationSignal(); + if (addresses != null) { + fillContactDataFromAddresses(addresses, recipients, recipientMap); + } else if (contactUri != null) { + fillContactDataFromContactUri(contactUri, recipients, recipientMap); + } else if (query != null) { + fillContactDataFromQuery(query, recipients, recipientMap); + } else { + throw new IllegalStateException("loader must be initialized with query or list of addresses!"); } - try { - - ArrayList recipients = new ArrayList(); - HashMap recipientMap = new HashMap(); - - if (addresses != null) { - fillContactDataFromAddresses(addresses, recipients, recipientMap); - } else if (contactUri != null) { - fillContactDataFromContactUri(contactUri, recipients, recipientMap); - } else if (query != null) { - fillContactDataFromQuery(query, recipients, recipientMap); - } else { - throw new IllegalStateException("loader must be initialized with query or list of addresses!"); - } - - if (recipients.isEmpty()) { - return recipients; - } - - if (cryptoProvider != null) { - fillCryptoStatusData(recipientMap); - } + if (recipients.isEmpty()) { return recipients; - - } finally { - synchronized (this) { - mCancellationSignal = null; - } } + + if (cryptoProvider != null) { + fillCryptoStatusData(recipientMap); + } + + return recipients; } private void fillContactDataFromAddresses(Address[] addresses, ArrayList recipients, @@ -160,8 +139,7 @@ public class RecipientLoader extends AsyncTaskLoader> { Uri queryUri = Uri.withAppendedPath(ContactsContract.CommonDataKinds.Email.CONTENT_FILTER_URI, Uri.encode(query)); - Cursor cursor = getContext().getContentResolver().query( - queryUri, PROJECTION, null, null, SORT_ORDER, mCancellationSignal); + Cursor cursor = getContext().getContentResolver().query(queryUri, PROJECTION, null, null, SORT_ORDER); if (cursor == null) { return; @@ -178,9 +156,7 @@ public class RecipientLoader extends AsyncTaskLoader> { private void fillContactDataFromCursor(Cursor cursor, ArrayList recipients, HashMap recipientMap) { - - cursor.moveToFirst(); - while (!cursor.isAfterLast()) { + while (cursor.moveToNext()) { String name = cursor.getString(INDEX_NAME); String email = cursor.getString(INDEX_EMAIL); @@ -189,7 +165,6 @@ public class RecipientLoader extends AsyncTaskLoader> { // already exists? just skip then if (recipientMap.containsKey(email)) { // TODO merge? do something else? what do we do? - cursor.moveToNext(); continue; } @@ -200,8 +175,6 @@ public class RecipientLoader extends AsyncTaskLoader> { recipientMap.put(email, recipient); recipients.add(recipient); - - cursor.moveToNext(); } cursor.close(); @@ -213,7 +186,7 @@ public class RecipientLoader extends AsyncTaskLoader> { Uri queryUri = Uri.parse("content://" + cryptoProvider + ".provider.exported/email_status"); Cursor cursor = getContext().getContentResolver().query( - queryUri, PROJECTION_CRYPTO_STATUS, null, recipientAddresses, null, mCancellationSignal); + queryUri, PROJECTION_CRYPTO_STATUS, null, recipientAddresses, null); // fill all values with "unavailable", even if the query fails for (Recipient recipient : recipientMap.values()) { @@ -224,8 +197,7 @@ public class RecipientLoader extends AsyncTaskLoader> { return; } - cursor.moveToFirst(); - while (!cursor.isAfterLast()) { + while (cursor.moveToNext()) { String email = cursor.getString(0); int status = cursor.getInt(1); @@ -242,8 +214,6 @@ public class RecipientLoader extends AsyncTaskLoader> { } } } - - cursor.moveToNext(); } cursor.close(); @@ -286,15 +256,4 @@ public class RecipientLoader extends AsyncTaskLoader> { } } - @Override - public void cancelLoadInBackground() { - super.cancelLoadInBackground(); - - synchronized (this) { - if (mCancellationSignal != null) { - mCancellationSignal.cancel(); - } - } - } - } diff --git a/k9mail/src/main/java/com/fsck/k9/activity/RecipientPresenter.java b/k9mail/src/main/java/com/fsck/k9/activity/RecipientPresenter.java index 7e9166671..1293afa44 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/RecipientPresenter.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/RecipientPresenter.java @@ -17,6 +17,7 @@ import com.fsck.k9.Identity; import com.fsck.k9.R; import com.fsck.k9.activity.MessageCompose.CaseInsensitiveParamWrapper; import com.fsck.k9.activity.RecipientView.CryptoStatusType; +import com.fsck.k9.helper.Contacts; import com.fsck.k9.view.RecipientSelectView.Recipient; import com.fsck.k9.helper.Utility; import com.fsck.k9.mail.Address; @@ -228,7 +229,7 @@ public class RecipientPresenter { } public void onPrepareOptionsMenu(Menu menu) { - boolean noContactPickerAvailable = !recipientView.hasContactPicker(); + boolean noContactPickerAvailable = !hasContactPicker(); if (noContactPickerAvailable) { menu.findItem(R.id.add_from_contacts).setVisible(false); } @@ -371,6 +372,7 @@ public class RecipientPresenter { Recipient[] recipientArray = result.toArray(new Recipient[result.size()]); recipientView.addRecipients(recipientType, recipientArray); stopLoading(); + abandon(); } }.startLoading(); } @@ -387,6 +389,7 @@ public class RecipientPresenter { Recipient recipient = result.get(0); recipientView.addRecipients(recipientType, recipient); stopLoading(); + abandon(); } }.startLoading(); } @@ -455,8 +458,8 @@ public class RecipientPresenter { recipientView.showCryptoDialog(currentCryptoMode); } - public void onCryptoModeChanged(CryptoMode type) { - currentCryptoMode = type; + public void onCryptoModeChanged(CryptoMode cryptoMode) { + currentCryptoMode = cryptoMode; updateCryptoDisplayStatus(); } @@ -464,4 +467,21 @@ public class RecipientPresenter { OPPORTUNISTIC, DISABLE, SIGN_ONLY } + private Boolean hasContactPicker; + /** + * Does the device actually have a Contacts application suitable for + * picking a contact. As hard as it is to believe, some vendors ship + * without it. + * + * @return True, if the device supports picking contacts. False, otherwise. + */ + public boolean hasContactPicker() { + if (hasContactPicker == null) { + Contacts contacts = Contacts.getInstance(context); + hasContactPicker = !(context.getPackageManager().queryIntentActivities( + contacts.contactPickerIntent(), 0).isEmpty()); + } + return hasContactPicker; + } + } diff --git a/k9mail/src/main/java/com/fsck/k9/activity/RecipientView.java b/k9mail/src/main/java/com/fsck/k9/activity/RecipientView.java index eeb4c0dbc..4ba8ef001 100644 --- a/k9mail/src/main/java/com/fsck/k9/activity/RecipientView.java +++ b/k9mail/src/main/java/com/fsck/k9/activity/RecipientView.java @@ -119,7 +119,7 @@ public class RecipientView implements OnFocusChangeListener, OnClickListener { bccView.setCryptoProvider(openPgpProvider); } - public void toFieldRequestFocus() { + public void requestFocusOnToFied() { toView.requestFocus(); } @@ -238,17 +238,6 @@ public class RecipientView implements OnFocusChangeListener, OnClickListener { } } - /** - * Does the device actually have a Contacts application suitable for - * picking a contact. As hard as it is to believe, some vendors ship - * without it. - * - * @return True, if the device supports picking contacts. False, otherwise. - */ - public boolean hasContactPicker() { - return activity.hasContactPicker(); - } - public void showContactPicker(int requestCode) { // this is an extra indirection to keep the view here clear activity.showContactPicker(requestCode); diff --git a/k9mail/src/main/java/com/fsck/k9/message/MessageBuilder.java b/k9mail/src/main/java/com/fsck/k9/message/MessageBuilder.java index 73d6a6509..fe973be25 100644 --- a/k9mail/src/main/java/com/fsck/k9/message/MessageBuilder.java +++ b/k9mail/src/main/java/com/fsck/k9/message/MessageBuilder.java @@ -338,26 +338,11 @@ public class MessageBuilder { return this; } - public MessageBuilder setTo(Address[] to) { - this.to = to; - return this; - } - - public MessageBuilder setCc(Address[] cc) { - this.cc = cc; - return this; - } - public MessageBuilder setCc(List
cc) { this.cc = cc.toArray(new Address[cc.size()]); return this; } - public MessageBuilder setBcc(Address[] bcc) { - this.bcc = bcc; - return this; - } - public MessageBuilder setBcc(List
bcc) { this.bcc = bcc.toArray(new Address[bcc.size()]); return this; diff --git a/k9mail/src/main/java/com/fsck/k9/view/CryptoStatusSelector.java b/k9mail/src/main/java/com/fsck/k9/view/CryptoModeSelector.java similarity index 70% rename from k9mail/src/main/java/com/fsck/k9/view/CryptoStatusSelector.java rename to k9mail/src/main/java/com/fsck/k9/view/CryptoModeSelector.java index 9fed083ca..cc42da555 100644 --- a/k9mail/src/main/java/com/fsck/k9/view/CryptoStatusSelector.java +++ b/k9mail/src/main/java/com/fsck/k9/view/CryptoModeSelector.java @@ -14,10 +14,16 @@ import android.widget.SeekBar.OnSeekBarChangeListener; import com.fsck.k9.R; -public class CryptoStatusSelector extends FrameLayout implements OnSeekBarChangeListener { +public class CryptoModeSelector extends FrameLayout implements OnSeekBarChangeListener { + public static final int CROSSFADE_THRESH_3_LOW = 125; + public static final int CROSSFADE_THRESH_2_LOW = 50; + public static final int CROSSFADE_THRESH_2_HIGH = 150; + public static final float CROSSFADE_DIVISOR_2 = 50.0f; + public static final float CROSSFADE_DIVISOR_3 = 75.0f; private SeekBar seekbar; - private ImageView icon1, icon2, icon3; + private ImageView modeIcon2; + private ImageView modeIcon3; private ObjectAnimator currentSeekbarAnim; @@ -26,12 +32,12 @@ public class CryptoStatusSelector extends FrameLayout implements OnSeekBarChange private CryptoStatusSelectedListener cryptoStatusListener; private static final ArgbEvaluator ARGB_EVALUATOR = new ArgbEvaluator(); - public CryptoStatusSelector(Context context, AttributeSet attrs) { + public CryptoModeSelector(Context context, AttributeSet attrs) { super(context, attrs); init(); } - public CryptoStatusSelector(Context context, AttributeSet attrs, int defStyleAttr) { + public CryptoModeSelector(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(); } @@ -39,14 +45,15 @@ public class CryptoStatusSelector extends FrameLayout implements OnSeekBarChange public void init() { inflate(getContext(), R.layout.crypto_settings_slider, this); seekbar = (SeekBar) findViewById(R.id.seek_bar); - icon1 = (ImageView) findViewById(R.id.icon_1); - icon2 = (ImageView) findViewById(R.id.icon_2); - icon3 = (ImageView) findViewById(R.id.icon_3); + modeIcon2 = (ImageView) findViewById(R.id.icon_2); + modeIcon3 = (ImageView) findViewById(R.id.icon_3); seekbar.setOnSeekBarChangeListener(this); onProgressChanged(seekbar, seekbar.getProgress(), false); - icon1.setColorFilter(getResources().getColor(R.color.openpgp_grey), PorterDuff.Mode.SRC_ATOP); + // this one is set static for now, since it is static grey and not crossfaded + ImageView modeIcon1 = (ImageView) findViewById(R.id.icon_1); + modeIcon1.setColorFilter(getResources().getColor(R.color.openpgp_grey), PorterDuff.Mode.SRC_ATOP); } @Override @@ -54,8 +61,8 @@ public class CryptoStatusSelector extends FrameLayout implements OnSeekBarChange int grey = getResources().getColor(R.color.openpgp_grey); float crossfadeValue2, crossfadeValue3; - if (progress > 50 && progress < 150) { - crossfadeValue2 = (progress-50) / 50.0f; + if (progress > CROSSFADE_THRESH_2_LOW && progress < CROSSFADE_THRESH_2_HIGH) { + crossfadeValue2 = (progress -CROSSFADE_THRESH_2_LOW) / CROSSFADE_DIVISOR_2; if (crossfadeValue2 > 1.0f) { crossfadeValue2 = 2.0f -crossfadeValue2; } @@ -63,8 +70,8 @@ public class CryptoStatusSelector extends FrameLayout implements OnSeekBarChange crossfadeValue2 = 0.0f; } - if (progress > 125) { - crossfadeValue3 = (progress-125) / 75.0f; + if (progress > CROSSFADE_THRESH_3_LOW) { + crossfadeValue3 = (progress -CROSSFADE_THRESH_3_LOW) / CROSSFADE_DIVISOR_3; } else { crossfadeValue3 = 0.0f; } @@ -72,10 +79,10 @@ public class CryptoStatusSelector extends FrameLayout implements OnSeekBarChange int crossfadedColor; crossfadedColor = crossfadeColor(grey, getResources().getColor(R.color.openpgp_red), crossfadeValue2); - icon2.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP); + modeIcon2.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP); crossfadedColor = crossfadeColor(grey, getResources().getColor(R.color.openpgp_green), crossfadeValue3); - icon3.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP); + modeIcon3.setColorFilter(crossfadedColor, PorterDuff.Mode.SRC_ATOP); } @Override diff --git a/k9mail/src/main/java/com/fsck/k9/view/LinearViewAnimator.java b/k9mail/src/main/java/com/fsck/k9/view/LinearViewAnimator.java index ba1abfb0f..76695e298 100644 --- a/k9mail/src/main/java/com/fsck/k9/view/LinearViewAnimator.java +++ b/k9mail/src/main/java/com/fsck/k9/view/LinearViewAnimator.java @@ -16,11 +16,11 @@ import com.fsck.k9.R; */ public class LinearViewAnimator extends ViewAnimator { - Animation mUpInAnimation; - Animation mUpOutAnimation; + private Animation upInAnimation; + private Animation upOutAnimation; - Animation mDownInAnimation; - Animation mDownOutAnimation; + private Animation downInAnimation; + private Animation downOutAnimation; public LinearViewAnimator(Context context) { super(context); @@ -31,6 +31,7 @@ public class LinearViewAnimator extends ViewAnimator { init(context, attrs); } + @SuppressWarnings("UnusedParameters") public LinearViewAnimator(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs); init(context, attrs); @@ -67,7 +68,7 @@ public class LinearViewAnimator extends ViewAnimator { } public void setUpOutAnimation(Animation animation) { - mUpOutAnimation = animation; + upOutAnimation = animation; } public void setUpInAnimation(Context context, int resourceID) { @@ -75,7 +76,7 @@ public class LinearViewAnimator extends ViewAnimator { } public void setUpInAnimation(Animation animation) { - mUpInAnimation = animation; + upInAnimation = animation; } public void setDownOutAnimation(Context context, int resourceID) { @@ -83,7 +84,7 @@ public class LinearViewAnimator extends ViewAnimator { } public void setDownOutAnimation(Animation animation) { - mDownOutAnimation = animation; + downOutAnimation = animation; } public void setDownInAnimation(Context context, int resourceID) { @@ -91,7 +92,7 @@ public class LinearViewAnimator extends ViewAnimator { } public void setDownInAnimation(Animation animation) { - mDownInAnimation = animation; + downInAnimation = animation; } @Override @@ -108,11 +109,11 @@ public class LinearViewAnimator extends ViewAnimator { setInAnimation(null); setOutAnimation(null); } else if (displayedChild < whichChild) { - setInAnimation(mDownInAnimation); - setOutAnimation(mDownOutAnimation); + setInAnimation(downInAnimation); + setOutAnimation(downOutAnimation); } else { - setInAnimation(mUpInAnimation); - setOutAnimation(mUpOutAnimation); + setInAnimation(upInAnimation); + setOutAnimation(upOutAnimation); } super.setDisplayedChild(whichChild); } diff --git a/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java b/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java index d831920d1..92789e573 100644 --- a/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java +++ b/k9mail/src/main/java/com/fsck/k9/view/RecipientSelectView.java @@ -93,14 +93,23 @@ public class RecipientSelectView extends TokenCompleteTextView implem View cryptoStatusGreen = view.findViewById(R.id.contact_crypto_status_green); boolean hasCryptoProvider = cryptoProvider != null; - // display unavailable status only if a crypto provider is even available - cryptoStatusRed.setVisibility( - hasCryptoProvider && recipient.cryptoStatus == RecipientCryptoStatus.UNAVAILABLE - ? View.VISIBLE : View.GONE); - cryptoStatusOrange.setVisibility( - recipient.cryptoStatus == RecipientCryptoStatus.AVAILABLE_UNTRUSTED ? View.VISIBLE : View.GONE); - cryptoStatusGreen.setVisibility( - recipient.cryptoStatus == RecipientCryptoStatus.AVAILABLE_TRUSTED ? View.VISIBLE : View.GONE); + if (!hasCryptoProvider) { + cryptoStatusRed.setVisibility(View.GONE); + cryptoStatusOrange.setVisibility(View.GONE); + cryptoStatusGreen.setVisibility(View.GONE); + } else if (recipient.cryptoStatus == RecipientCryptoStatus.UNAVAILABLE) { + cryptoStatusRed.setVisibility(View.VISIBLE); + cryptoStatusOrange.setVisibility(View.GONE); + cryptoStatusGreen.setVisibility(View.GONE); + } else if (recipient.cryptoStatus == RecipientCryptoStatus.AVAILABLE_UNTRUSTED) { + cryptoStatusRed.setVisibility(View.GONE); + cryptoStatusOrange.setVisibility(View.VISIBLE); + cryptoStatusGreen.setVisibility(View.GONE); + } else if (recipient.cryptoStatus == RecipientCryptoStatus.AVAILABLE_TRUSTED) { + cryptoStatusRed.setVisibility(View.GONE); + cryptoStatusOrange.setVisibility(View.GONE); + cryptoStatusGreen.setVisibility(View.VISIBLE); + } return view; } diff --git a/k9mail/src/main/res/layout/crypto_settings_dialog.xml b/k9mail/src/main/res/layout/crypto_settings_dialog.xml index e52fa69c5..73a142fa0 100644 --- a/k9mail/src/main/res/layout/crypto_settings_dialog.xml +++ b/k9mail/src/main/res/layout/crypto_settings_dialog.xml @@ -43,7 +43,7 @@ - diff --git a/k9mail/src/main/res/layout/message_compose.xml b/k9mail/src/main/res/layout/message_compose.xml index 0c501436e..0b227bb36 100644 --- a/k9mail/src/main/res/layout/message_compose.xml +++ b/k9mail/src/main/res/layout/message_compose.xml @@ -17,368 +17,48 @@ android:layout_height="wrap_content" android:orientation="vertical" > + + + android:layout_width="match_parent" + android:layout_marginLeft="12dip" + android:layout_marginRight="12dip" + android:gravity="center_vertical" + android:orientation="horizontal" + android:minHeight="50dp"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/k9mail/src/main/res/values/strings.xml b/k9mail/src/main/res/values/strings.xml index 900f51270..0801f0275 100644 --- a/k9mail/src/main/res/values/strings.xml +++ b/k9mail/src/main/res/values/strings.xml @@ -162,7 +162,6 @@ Please submit bug reports, contribute new features and ask questions at Switch to light theme Mark unread - Add Cc/Bcc Read receipt Will request read receipt Will not request read receipt @@ -1159,4 +1158,10 @@ Please submit bug reports, contribute new features and ask questions at Click \'Download complete message\' to allow decryption. Add from Contacts + Proceed + Cc + Bcc + To + From +