1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-02 00:25:10 -04:00

Merge branch 'master' into pull-128

This commit is contained in:
ashley willis 2012-04-08 21:59:20 -05:00
commit 81c9fdcb13
17 changed files with 84 additions and 54 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -103,7 +103,6 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="library" scope="PROVIDED" name="Android 2.3.1 Platform" level="application" />
</component>
</module>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@ -1,9 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/android:list"
<ListView
android:id="@+id/android:list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
android:layout_height="fill_parent"/>
</LinearLayout>

View File

@ -32,8 +32,9 @@
/>
<item
android:id="@+id/read_receipt"
android:alphabeticShortcut="r"
android:title="@string/read_receipt"
android:alphabeticShortcut="r"
android:title="@string/read_receipt"
android:icon="@drawable/ic_menu_reply_receipt"
/>
<item
android:id="@+id/add_attachment_image"

View File

@ -13,6 +13,10 @@ import com.fsck.k9.R;
import com.fsck.k9.helper.ContactItem;
public class EmailAddressList extends K9ListActivity implements OnItemClickListener {
public static final String EXTRA_CONTACT_ITEM = "contact";
public static final String EXTRA_EMAIL_ADDRESS = "emailAddress";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -20,17 +24,19 @@ public class EmailAddressList extends K9ListActivity implements OnItemClickListe
setContentView(R.layout.email_address_list);
Intent i = getIntent();
ContactItem contact = (ContactItem) i.getSerializableExtra("contact");
ContactItem contact = (ContactItem) i.getSerializableExtra(EXTRA_CONTACT_ITEM);
if (contact == null) {
finish();
return;
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.email_address_list_item, contact.getEmailAddresses());
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.email_address_list_item, contact.emailAddresses);
ListView listView = getListView();
listView.setOnItemClickListener(this);
listView.setAdapter(adapter);
setTitle(contact.getDisplayName());
setTitle(contact.displayName);
}
@Override
@ -40,7 +46,7 @@ public class EmailAddressList extends K9ListActivity implements OnItemClickListe
Toast.makeText(EmailAddressList.this, item, Toast.LENGTH_LONG).show();
Intent intent = new Intent();
intent.putExtra("EMAIL_ADDRESS", item);
intent.putExtra(EXTRA_EMAIL_ADDRESS, item);
setResult(RESULT_OK, intent);
finish();
}

View File

@ -26,7 +26,6 @@ import android.content.pm.ActivityInfo;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Parcelable;
@ -136,8 +135,6 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
private static final int MSG_DISCARDED_DRAFT = 6;
private static final int ACTIVITY_REQUEST_PICK_ATTACHMENT = 1;
private static final int ACTIVITY_CHOOSE_IDENTITY = 2;
private static final int ACTIVITY_CHOOSE_ACCOUNT = 3;
private static final int CONTACT_PICKER_TO = 4;
private static final int CONTACT_PICKER_CC = 5;
private static final int CONTACT_PICKER_BCC = 6;
@ -1797,14 +1794,14 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
case CONTACT_PICKER_TO:
case CONTACT_PICKER_CC:
case CONTACT_PICKER_BCC:
ContactItem contact = mContacts.getEmailFromContactPicker(data);
ContactItem contact = mContacts.extractInfoFromContactPickerIntent(data);
if (contact == null) {
Toast.makeText(this, getString(R.string.error_contact_address_not_found), Toast.LENGTH_LONG).show();
return;
}
if (contact.getEmailAddresses().size() > 1) {
if (contact.emailAddresses.size() > 1) {
Intent i = new Intent(this, EmailAddressList.class);
i.putExtra("contact", contact);
i.putExtra(EmailAddressList.EXTRA_CONTACT_ITEM, contact);
if (requestCode == CONTACT_PICKER_TO) {
startActivityForResult(i, CONTACT_PICKER_TO2);
@ -1816,14 +1813,14 @@ public class MessageCompose extends K9Activity implements OnClickListener, OnFoc
return;
}
if (K9.DEBUG) {
ArrayList<String> emails = contact.getEmailAddresses();
List<String> emails = contact.emailAddresses;
for (int i = 0; i < emails.size(); i++) {
Log.v(K9.LOG_TAG, "email[" + i + "]: " + emails.get(i));
}
}
String email = contact.getEmailAddresses().get(0);
String email = contact.emailAddresses.get(0);
if (requestCode == CONTACT_PICKER_TO) {
addAddress(mToView, new Address(email, ""));
} else if (requestCode == CONTACT_PICKER_CC) {

View File

@ -1,24 +1,17 @@
package com.fsck.k9.helper;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class ContactItem implements Serializable {
private static final long serialVersionUID = 4893328130147843375L;
private String displayName = null;
private ArrayList<String> emailAddresses = null;
public final String displayName;
public final List<String> emailAddresses;
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
public ContactItem(String displayName, List<String> emailAddresses) {
this.displayName = displayName;
}
public ArrayList<String> getEmailAddresses() {
return emailAddresses;
}
public void setEmailAddresses(ArrayList<String> emailAddresses) {
this.emailAddresses = emailAddresses;
this.emailAddresses = Collections.unmodifiableList(emailAddresses);
}
}

View File

@ -175,13 +175,15 @@ public abstract class Contacts {
public abstract Intent contactPickerIntent();
/**
* Given a contact picker intent, returns the primary email address of that
* contact.
* Given a contact picker intent, returns a {@code ContactItem} instance for that contact.
*
* @param intent The {@link Intent} returned by this contact picker.
* @return The primary email address of the picked contact.
* @param intent
* The {@link Intent} returned by the contact picker.
*
* @return A {@link ContactItem} instance describing the picked contact. Or {@code null} if the
* contact doesn't have any email addresses.
*/
public abstract ContactItem getEmailFromContactPicker(final Intent intent);
public abstract ContactItem extractInfoFromContactPickerIntent(final Intent intent);
/**
* Does the device actually have a Contacts application suitable for

View File

@ -193,45 +193,48 @@ public class ContactsSdk5 extends com.fsck.k9.helper.Contacts {
}
@Override
public ContactItem getEmailFromContactPicker(final Intent data) {
public ContactItem extractInfoFromContactPickerIntent(final Intent data) {
Cursor cursor = null;
Cursor cursor2 = null;
ContactItem item = new ContactItem();
ArrayList<String> email = new ArrayList<String>();
try {
Uri result = data.getData();
String displayName = null;
cursor = mContentResolver.query(result, null, null, null, null);
if (cursor.moveToFirst()) {
displayName = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.DISPLAY_NAME));
}
// Get the contact id from the Uri
String id = result.getLastPathSegment();
cursor2 = mContentResolver.query(Email.CONTENT_URI,
null, Email.CONTACT_ID + "=?", new String[] { id },
null);
if (cursor2 != null) {
int emailIdx = cursor2.getColumnIndex(Email.DATA);
cursor = mContentResolver.query(Email.CONTENT_URI, PROJECTION,
Email.CONTACT_ID + "=?", new String[] { id }, null);
while (cursor2.moveToNext()) {
email.add(cursor2.getString(emailIdx));
if (cursor != null) {
while (cursor.moveToNext()) {
String address = cursor.getString(EMAIL_INDEX);
if (address != null) {
email.add(address);
}
if (displayName == null) {
displayName = cursor.getString(NAME_INDEX);
}
}
// Return 'null' if no email addresses have been found
if (email.size() == 0) {
return null;
}
item.setDisplayName(displayName);
item.setEmailAddresses(email);
return item;
// Use the first email address found as display name
if (displayName == null) {
displayName = email.get(0);
}
return new ContactItem(displayName, email);
}
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Failed to get email data", e);
} finally {
Utility.closeQuietly(cursor);
Utility.closeQuietly(cursor2);
}
return null;

View File

@ -2794,6 +2794,8 @@ public class LocalStore extends Store implements Serializable {
text = text.replaceAll("(?m)^On .*wrote.?$", "");
// Remove a more generic quote header from the preview
text = text.replaceAll("(?m)^.*\\w+:$", "");
// Remove horizontal rules.
text = text.replaceAll("\\s*([-=_]{30,}+)\\s*", " ");
// URLs in the preview should just be shown as "..." - They're not
// clickable and they usually overwhelm the preview
@ -2802,6 +2804,9 @@ public class LocalStore extends Store implements Serializable {
text = text.replaceAll("(\\r|\\n)+", " ");
// Collapse whitespace in the preview
text = text.replaceAll("\\s+", " ");
// Remove any whitespace at the beginning and end of the string.
text = text.trim();
if (text.length() <= 512) {
return text;
} else {

View File

@ -25,6 +25,11 @@ public class AccountSettings {
Map<String, TreeMap<Integer, SettingsDescription>> s =
new LinkedHashMap<String, TreeMap<Integer, SettingsDescription>>();
/**
* When adding new settings here, be sure to increment {@link Settings.VERSION}
* and use that for whatever you add here.
*/
s.put("archiveFolderName", Settings.versions(
new V(1, new StringSetting("Archive"))
));

View File

@ -20,6 +20,11 @@ public class FolderSettings {
Map<String, TreeMap<Integer, SettingsDescription>> s =
new LinkedHashMap<String, TreeMap<Integer, SettingsDescription>>();
/**
* When adding new settings here, be sure to increment {@link Settings.VERSION}
* and use that for whatever you add here.
*/
s.put("displayMode", Settings.versions(
new V(1, new EnumSetting(FolderClass.class, FolderClass.NO_CLASS))
));

View File

@ -26,6 +26,11 @@ public class GlobalSettings {
Map<String, TreeMap<Integer, SettingsDescription>> s =
new LinkedHashMap<String, TreeMap<Integer, SettingsDescription>>();
/**
* When adding new settings here, be sure to increment {@link Settings.VERSION}
* and use that for whatever you add here.
*/
s.put("animations", Settings.versions(
new V(1, new BooleanSetting(false))
));

View File

@ -22,6 +22,11 @@ public class IdentitySettings {
Map<String, TreeMap<Integer, SettingsDescription>> s =
new LinkedHashMap<String, TreeMap<Integer, SettingsDescription>>();
/**
* When adding new settings here, be sure to increment {@link Settings.VERSION}
* and use that for whatever you add here.
*/
s.put("signature", Settings.versions(
new V(1, new SignatureSetting())
));