Create settings model.
Change-Id: Ia4cdb7f6328c29ced8e86de4e04d04ef5e61fb9f
diff --git a/src/com/android/mail/providers/Settings.java b/src/com/android/mail/providers/Settings.java
new file mode 100644
index 0000000..de7dfa7
--- /dev/null
+++ b/src/com/android/mail/providers/Settings.java
@@ -0,0 +1,95 @@
+/**
+ * Copyright (c) 2012, Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.mail.providers;
+
+import android.database.Cursor;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Model to hold Settings for an account.
+ */
+public class Settings implements Parcelable {
+ public String signature;
+ public int autoAdvance;
+ public int messageTextSize;
+ public int snapHeaders;
+ public int replyBehavior;
+ public boolean hideCheckboxes;
+ public boolean confirmDelete;
+ public boolean confirmArchive;
+ public boolean confirmSend;
+ public Folder defaultInbox;
+
+ public Settings(Parcel inParcel) {
+ signature = inParcel.readString();
+ autoAdvance = inParcel.readInt();
+ messageTextSize = inParcel.readInt();
+ snapHeaders = inParcel.readInt();
+ replyBehavior = inParcel.readInt();
+ hideCheckboxes = inParcel.readInt() != 0;
+ confirmDelete = inParcel.readInt() != 0;
+ confirmArchive = inParcel.readInt() != 0;
+ confirmSend = inParcel.readInt() != 0;
+ defaultInbox = new Folder(inParcel.readString());
+ }
+
+ public Settings(Cursor cursor) {
+ signature = cursor.getString(UIProvider.SETTINGS_SIGNATURE_COLUMN);
+ autoAdvance = cursor.getInt(UIProvider.SETTINGS_AUTO_ADVANCE_COLUMN);
+ messageTextSize = cursor.getInt(UIProvider.SETTINGS_MESSAGE_TEXT_SIZE_COLUMN);
+ snapHeaders = cursor.getInt(UIProvider.SETTINGS_SNAP_HEADERS_COLUMN);
+ replyBehavior = cursor.getInt(UIProvider.SETTINGS_REPLY_BEHAVIOR_COLUMN);
+ hideCheckboxes = cursor.getInt(UIProvider.SETTINGS_HIDE_CHECKBOXES_COLUMN) != 0;
+ confirmDelete = cursor.getInt(UIProvider.SETTINGS_CONFIRM_DELETE_COLUMN) != 0;
+ confirmArchive = cursor.getInt(UIProvider.SETTINGS_CONFIRM_ARCHIVE_COLUMN) != 0;
+ confirmSend = cursor.getInt(UIProvider.SETTINGS_CONFIRM_SEND_COLUMN) != 0;
+ defaultInbox = new Folder(cursor.getString(UIProvider.SETTINGS_DEFAULT_INBOX_COLUMN));
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(signature);
+ dest.writeInt(autoAdvance);
+ dest.writeInt(messageTextSize);
+ dest.writeInt(snapHeaders);
+ dest.writeInt(replyBehavior);
+ dest.writeInt(hideCheckboxes ? 1 : 0);
+ dest.writeInt(confirmDelete ? 1 : 0);
+ dest.writeInt(confirmArchive? 1 : 0);
+ dest.writeInt(confirmSend? 1 : 0);
+ dest.writeString(defaultInbox.serialize());
+ }
+
+ @SuppressWarnings("hiding")
+ public static final Creator<Settings> CREATOR = new Creator<Settings>() {
+ @Override
+ public Settings createFromParcel(Parcel source) {
+ return new Settings(source);
+ }
+
+ @Override
+ public Settings[] newArray(int size) {
+ return new Settings[size];
+ }
+ };
+}
diff --git a/src/com/android/mail/providers/UIProvider.java b/src/com/android/mail/providers/UIProvider.java
index 8908c5d..4687309 100644
--- a/src/com/android/mail/providers/UIProvider.java
+++ b/src/com/android/mail/providers/UIProvider.java
@@ -856,6 +856,17 @@
SettingsColumns.DEFAULT_INBOX
};
+ public static final int SETTINGS_SIGNATURE_COLUMN = 0;
+ public static final int SETTINGS_AUTO_ADVANCE_COLUMN = 1;
+ public static final int SETTINGS_MESSAGE_TEXT_SIZE_COLUMN = 2;
+ public static final int SETTINGS_SNAP_HEADERS_COLUMN = 3;
+ public static final int SETTINGS_REPLY_BEHAVIOR_COLUMN = 4;
+ public static final int SETTINGS_HIDE_CHECKBOXES_COLUMN = 5;
+ public static final int SETTINGS_CONFIRM_DELETE_COLUMN = 6;
+ public static final int SETTINGS_CONFIRM_ARCHIVE_COLUMN = 7;
+ public static final int SETTINGS_CONFIRM_SEND_COLUMN = 8;
+ public static final int SETTINGS_DEFAULT_INBOX_COLUMN = 9;
+
public static final class AutoAdvance {
public static final int UNSET = 0;
public static final int OLDER = 1;
@@ -914,28 +925,28 @@
public static final String REPLY_BEHAVIOR = "reply_behavior";
/**
- * Integer column containing the user's specified checkbox preference. The value
- * of 0 indicates that checkboxes are not hidden.
+ * Integer column containing the user's specified checkbox preference. A
+ * non zero value means to hide checkboxes.
*/
public static final String HIDE_CHECKBOXES = "hide_checkboxes";
/**
* Integer column containing the user's specified confirm delete preference value.
- * A value of 1 indicates that the user has indicated that a confirmation should
+ * A non zero value indicates that the user has indicated that a confirmation should
* be shown when a delete action is performed.
*/
public static final String CONFIRM_DELETE = "confirm_delete";
/**
* Integer column containing the user's specified confirm archive preference value.
- * A value of 1 indicates that the user has indicated that a confirmation should
+ * A non zero value indicates that the user has indicated that a confirmation should
* be shown when an archive action is performed.
*/
public static final String CONFIRM_ARCHIVE = "confirm_archive";
/**
* Integer column containing the user's specified confirm send preference value.
- * A value of 1 indicates that the user has indicated that a confirmation should
+ * A non zero value indicates that the user has indicated that a confirmation should
* be shown when a send action is performed.
*/
public static final String CONFIRM_SEND = "confirm_send";