summaryrefslogtreecommitdiffstats
path: root/emailcommon/src
diff options
context:
space:
mode:
authorTony Mantler <nicoya@google.com>2013-08-14 11:05:19 -0700
committerTony Mantler <nicoya@google.com>2013-08-16 14:08:54 -0700
commitc6953b77552d4cb71776cf0537dc226029381628 (patch)
tree6aecb38c5c7cdfdaad3f045f570b7d73ee4070da /emailcommon/src
parent2127d4dd096408ae3a31278f90b2d90c17a41d97 (diff)
downloadandroid_packages_apps_Email-c6953b77552d4cb71776cf0537dc226029381628.tar.gz
android_packages_apps_Email-c6953b77552d4cb71776cf0537dc226029381628.tar.bz2
android_packages_apps_Email-c6953b77552d4cb71776cf0537dc226029381628.zip
Reimplement QuickResponse support
b/8622751 Change-Id: Id079efcf34dce15b5f5057f937582c0e198d3d50
Diffstat (limited to 'emailcommon/src')
-rwxr-xr-xemailcommon/src/com/android/emailcommon/provider/EmailContent.java10
-rw-r--r--emailcommon/src/com/android/emailcommon/provider/QuickResponse.java185
2 files changed, 2 insertions, 193 deletions
diff --git a/emailcommon/src/com/android/emailcommon/provider/EmailContent.java b/emailcommon/src/com/android/emailcommon/provider/EmailContent.java
index 300e62e1a..284bf2bb6 100755
--- a/emailcommon/src/com/android/emailcommon/provider/EmailContent.java
+++ b/emailcommon/src/com/android/emailcommon/provider/EmailContent.java
@@ -1589,16 +1589,6 @@ public abstract class EmailContent {
static final String ACCOUNT_KEY = "accountKey";
}
- public static final int QUICK_RESPONSE_COLUMN_ID = 0;
- public static final int QUICK_RESPONSE_COLUMN_TEXT = 1;
- public static final int QUICK_RESPONSE_COLUMN_ACCOUNT = 2;
-
- public static final String [] QUICK_RESPONSE_PROJECTION = new String [] {
- QuickResponseColumns.ID,
- QuickResponseColumns.TEXT,
- QuickResponseColumns.ACCOUNT_KEY
- };
-
public interface MailboxColumns {
public static final String ID = "_id";
// The display name of this mailbox [INDEX]
diff --git a/emailcommon/src/com/android/emailcommon/provider/QuickResponse.java b/emailcommon/src/com/android/emailcommon/provider/QuickResponse.java
index 63b3d3184..2b68457ad 100644
--- a/emailcommon/src/com/android/emailcommon/provider/QuickResponse.java
+++ b/emailcommon/src/com/android/emailcommon/provider/QuickResponse.java
@@ -17,23 +17,16 @@
package com.android.emailcommon.provider;
-import android.content.ContentUris;
-import android.content.ContentValues;
-import android.content.Context;
-import android.database.Cursor;
import android.net.Uri;
-import android.os.Parcel;
-import android.os.Parcelable;
import com.android.emailcommon.provider.EmailContent.QuickResponseColumns;
-import com.google.common.base.Objects;
/**
* A user-modifiable message that may be quickly inserted into the body while user is composing
* a message. Tied to a specific account.
*/
-public final class QuickResponse extends EmailContent
- implements QuickResponseColumns, Parcelable {
+public abstract class QuickResponse extends EmailContent
+ implements QuickResponseColumns {
public static final String TABLE_NAME = "QuickResponse";
public static Uri CONTENT_URI;
public static Uri ACCOUNT_ID_URI;
@@ -42,178 +35,4 @@ public final class QuickResponse extends EmailContent
CONTENT_URI = Uri.parse(EmailContent.CONTENT_URI + "/quickresponse");
ACCOUNT_ID_URI = Uri.parse(EmailContent.CONTENT_URI + "/quickresponse/account");
}
-
- private String mText;
- private long mAccountKey;
-
- private static final int CONTENT_ID_COLUMN = 0;
- private static final int CONTENT_QUICK_RESPONSE_COLUMN = 1;
- private static final int CONTENT_ACCOUNT_KEY_COLUMN = 2;
- public static final String[] CONTENT_PROJECTION = new String[] {
- RECORD_ID,
- QuickResponseColumns.TEXT,
- QuickResponseColumns.ACCOUNT_KEY
- };
-
- /**
- * Creates an empty QuickResponse. Restore should be called after.
- */
- private QuickResponse() {
- // empty
- }
-
- /**
- * Constructor used by CREATOR for parceling.
- */
- private QuickResponse(Parcel in) {
- mBaseUri = CONTENT_URI;
- mId = in.readLong();
- mText = in.readString();
- mAccountKey = in.readLong();
- }
-
- /**
- * Creates QuickResponse associated with a particular account using the given string.
- */
- public QuickResponse(long accountKey, String quickResponse) {
- mBaseUri = CONTENT_URI;
- mAccountKey = accountKey;
- mText = quickResponse;
- }
-
- /**
- * @see com.android.emailcommon.provider.EmailContent#restore(android.database.Cursor)
- */
- @Override
- public void restore(Cursor cursor) {
- mBaseUri = CONTENT_URI;
- mId = cursor.getLong(CONTENT_ID_COLUMN);
- mText = cursor.getString(CONTENT_QUICK_RESPONSE_COLUMN);
- mAccountKey = cursor.getLong(CONTENT_ACCOUNT_KEY_COLUMN);
- }
-
- /**
- * @see com.android.emailcommon.provider.EmailContent#toContentValues()
- */
- @Override
- public ContentValues toContentValues() {
- ContentValues values = new ContentValues();
-
- values.put(QuickResponseColumns.TEXT, mText);
- values.put(QuickResponseColumns.ACCOUNT_KEY, mAccountKey);
-
- return values;
- }
-
- @Override
- public String toString() {
- return mText;
- }
-
- /**
- * Given an array of QuickResponses, returns the an array of the String values
- * corresponding to each QuickResponse.
- */
- public static String[] getQuickResponseStrings(QuickResponse[] quickResponses) {
- int count = quickResponses.length;
- String[] quickResponseStrings = new String[count];
- for (int i = 0; i < count; i++) {
- quickResponseStrings[i] = quickResponses[i].toString();
- }
-
- return quickResponseStrings;
- }
-
- /**
- * @param context
- * @param accountId
- * @return array of QuickResponses for the account with id accountId
- */
- public static QuickResponse[] restoreQuickResponsesWithAccountId(Context context,
- long accountId) {
- Uri uri = ContentUris.withAppendedId(ACCOUNT_ID_URI, accountId);
- Cursor c = context.getContentResolver().query(uri, CONTENT_PROJECTION,
- null, null, null);
-
- try {
- int count = c.getCount();
- QuickResponse[] quickResponses = new QuickResponse[count];
- for (int i = 0; i < count; ++i) {
- c.moveToNext();
- QuickResponse quickResponse = new QuickResponse();
- quickResponse.restore(c);
- quickResponses[i] = quickResponse;
- }
- return quickResponses;
- } finally {
- c.close();
- }
- }
-
- /**
- * Returns the base URI for this QuickResponse
- */
- public Uri getBaseUri() {
- return mBaseUri;
- }
-
- /**
- * Returns the unique id for this QuickResponse
- */
- public long getId() {
- return mId;
- }
-
- @Override
- public boolean equals(Object objectThat) {
- if (this == objectThat) return true;
- if (!(objectThat instanceof QuickResponse)) return false;
-
- QuickResponse that = (QuickResponse) objectThat;
- return
- mText.equals(that.mText) &&
- mId == that.mId &&
- mAccountKey == that.mAccountKey;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(mId, mText, mAccountKey);
- }
-
- /**
- * Implements Parcelable. Not used.
- */
- @Override
- public int describeContents() {
- return 0;
- }
-
- /**
- * Implements Parcelable.
- */
- @Override
- public void writeToParcel(Parcel dest, int flags) {
- // mBaseUri is not parceled
- dest.writeLong(mId);
- dest.writeString(mText);
- dest.writeLong(mAccountKey);
- }
-
- /**
- * Implements Parcelable
- */
- public static final Parcelable.Creator<QuickResponse> CREATOR
- = new Parcelable.Creator<QuickResponse>() {
- @Override
- public QuickResponse createFromParcel(Parcel in) {
- return new QuickResponse(in);
- }
-
- @Override
- public QuickResponse[] newArray(int size) {
- return new QuickResponse[size];
- }
- };
-
} \ No newline at end of file