diff --git a/samples/VoicemailProviderDemo/AndroidManifest.xml b/samples/VoicemailProviderDemo/AndroidManifest.xml index e1a34047d..558dbf786 100644 --- a/samples/VoicemailProviderDemo/AndroidManifest.xml +++ b/samples/VoicemailProviderDemo/AndroidManifest.xml @@ -26,7 +26,7 @@ - + diff --git a/samples/VoicemailProviderDemo/src/com/example/android/provider/VoicemailContract.java b/samples/VoicemailProviderDemo/src/com/example/android/provider/VoicemailContract.java deleted file mode 100644 index 3fe6cc897..000000000 --- a/samples/VoicemailProviderDemo/src/com/example/android/provider/VoicemailContract.java +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * 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.example.android.provider; - -// This is a COPY of the voicemail provider contract file checked in at -// framework/base/core/java/android/provider. The API is currently hidden so -// it is not available through the SDK and hence is not available to the sample -// code. -// TODO: get rid of this copy once the voicemail provider API is opened ups. - -import android.content.Intent; -import android.database.ContentObserver; -import android.net.Uri; -import android.provider.BaseColumns; -import android.provider.CallLog.Calls; - -/** - * The contract between the voicemail provider and applications. Contains - * definitions for the supported URIs and columns. - * - *

Voicemails are inserted by what is called as a "voicemail source" - * application, which is responsible for syncing voicemail data between a remote - * server and the local voicemail content provider. "voicemail source" - * application should use the source specific {@link #CONTENT_URI_SOURCE} URI - * to insert and retrieve voicemails. - * - *

In addition to the {@link ContentObserver} notifications the voicemail - * provider also generates broadcast intents to notify change for applications - * that are not active and therefore cannot listen to ContentObserver - * notifications. Broadcast intents with following actions are generated: - *

    - *
  • {@link #ACTION_NEW_VOICEMAIL} is generated for each new voicemail - * inserted. - *
  • - *
  • {@link Intent#ACTION_PROVIDER_CHANGED} is generated for any change - * made into the database, including new voicemail. - *
  • - *
- * @hide - */ -// TODO: unhide when the API is approved by android-api-council -public class VoicemailContract { - /** Not instantiable. */ - private VoicemailContract() { - } - - /** The authority used by the voicemail provider. */ - public static final String AUTHORITY = "com.android.voicemail"; - /** - * URI to insert/retrieve all voicemails. - * @deprecated - */ - public static final Uri CONTENT_URI = - Uri.parse("content://" + AUTHORITY + "/voicemail"); - /** - * URI to insert/retrieve voicemails by a given voicemail source. - * @deprecated - */ - public static final Uri CONTENT_URI_SOURCE = - Uri.parse("content://" + AUTHORITY + "/voicemail/source/"); - /** - * Parameter key used in the URI to specify the voicemail source package name. - *

This field must be set in all requests that originate from a voicemail source. - */ - public static final String PARAM_KEY_SOURCE_PACKAGE = "source_package"; - - // TODO: Move ACTION_NEW_VOICEMAIL to the Intent class. - /** Broadcast intent when a new voicemail record is inserted. */ - public static final String ACTION_NEW_VOICEMAIL = "android.intent.action.NEW_VOICEMAIL"; - /** - * Extra included in {@value Intent#ACTION_PROVIDER_CHANGED} and - * {@value #ACTION_NEW_VOICEMAIL} broadcast intents to indicate if the receiving - * package made this change. - */ - public static final String EXTRA_SELF_CHANGE = "com.android.voicemail.extra.SELF_CHANGE"; - - /** - * The mime type for a collection of voicemails. - * @deprecated */ - public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemails"; - - /** Defines fields exposed through the /voicemail path of this content provider. */ - public static final class Voicemails implements BaseColumns { - /** Not instantiable. */ - private Voicemails() { - } - - /** URI to insert/retrieve voicemails by a given voicemail source. */ - public static final Uri CONTENT_URI = - Uri.parse("content://" + AUTHORITY + "/voicemail"); - /** URI to insert/retrieve voicemails by a given voicemail source. */ - public static final Uri CONTENT_URI_SOURCE = - Uri.parse("content://" + AUTHORITY + "/voicemail/source/"); - - /** The mime type for a collection of voicemails. */ - public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemails"; - - /** - * Phone number of the voicemail sender. - *

Type: TEXT

- */ - public static final String NUMBER = Calls.NUMBER; - /** - * The date the voicemail was sent, in milliseconds since the epoch - *

Type: INTEGER (long)

- */ - public static final String DATE = Calls.DATE; - /** - * The duration of the voicemail in seconds. - *

Type: INTEGER (long)

- */ - public static final String DURATION = Calls.DURATION; - /** - * Whether this is a new voicemail (i.e. has not been heard). - *

Type: INTEGER (boolean)

- */ - public static final String NEW = Calls.NEW; - /** - * The mail box state of the voicemail. - *

Possible values: {@link #STATE_INBOX}, {@link #STATE_DELETED}, - * {@link #STATE_UNDELETED}. - *

Type: INTEGER

- */ - public static final String STATE = "state"; - /** Value of {@link #STATE} when the voicemail is in inbox. */ - public static int STATE_INBOX = 0; - /** Value of {@link #STATE} when the voicemail has been marked as deleted. */ - public static int STATE_DELETED = 1; - /** Value of {@link #STATE} when the voicemail has marked as undeleted. */ - public static int STATE_UNDELETED = 2; - /** - * Package name of the source application that inserted the voicemail. - *

Type: TEXT

- */ - public static final String SOURCE_PACKAGE = "source_package"; - /** - * Application-specific data available to the source application that - * inserted the voicemail. This is typically used to store the source - * specific message id to identify this voicemail on the remote - * voicemail server. - *

Type: TEXT

- *

Note that this is NOT the voicemail media content data. - */ - public static final String SOURCE_DATA = "source_data"; - /** - * Whether the media content for this voicemail is available for - * consumption. - *

Type: INTEGER (boolean)

- */ - public static final String HAS_CONTENT = "has_content"; - /** - * MIME type of the media content for the voicemail. - *

Type: TEXT

- */ - public static final String MIME_TYPE = "mime_type"; - /** - * Path to the media content file. Internal only field. - * @hide - */ - public static final String _DATA = "_data"; - - /** - * A convenience method to build voicemail URI specific to a source package by appending - * {@link VoicemailContract#PARAM_KEY_SOURCE_PACKAGE} param to the base URI. - */ - public static Uri buildSourceUri(String packageName) { - return Voicemails.CONTENT_URI.buildUpon() - .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build(); - } - } - - /** Defines fields exposed through the /status path of this content provider. */ - public static final class Status implements BaseColumns { - /** URI to insert/retrieve status of voicemail source. */ - public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/status"); - /** The mime type for a collection of voicemail source statuses. */ - public static final String DIR_TYPE = "vnd.android.cursor.dir/voicemail.source.status"; - /** The mime type for a collection of voicemails. */ - public static final String ITEM_TYPE = "vnd.android.cursor.item/voicemail.source.status"; - - /** Not instantiable. */ - private Status() { - } - /** - * The package name of the voicemail source. There can only be a one entry per source. - *

Type: TEXT

- */ - public static final String SOURCE_PACKAGE = "source_package"; - /** - * The URI to call to invoke source specific voicemail settings screen. On a user request - * to setup voicemail an intent with action VIEW with this URI will be fired by the system. - *

Type: TEXT

- */ - public static final String SETTINGS_URI = "settings_uri"; - /** - * The URI to call when the user requests to directly access the voicemail from the remote - * server. In case of an IVR voicemail system this is typically set to the the voicemail - * number specified using a tel:/ URI. - *

Type: TEXT

- */ - public static final String VOICEMAIL_ACCESS_URI = "voicemail_access_uri"; - /** - * The configuration state of the voicemail source. - *

Possible values: - * {@link #CONFIGURATION_STATE_OK}, - * {@link #CONFIGURATION_STATE_NOT_CONFIGURED}, - * {@link #CONFIGURATION_STATE_CAN_BE_CONFIGURED} - *

Type: INTEGER

- */ - public static final String CONFIGURATION_STATE = "configuration_state"; - public static final int CONFIGURATION_STATE_OK = 0; - public static final int CONFIGURATION_STATE_NOT_CONFIGURED = 1; - /** - * This state must be used when the source has verified that the current user can be - * upgraded to visual voicemail and would like to show a set up invitation message. - */ - public static final int CONFIGURATION_STATE_CAN_BE_CONFIGURED = 2; - /** - * The data channel state of the voicemail source. This the channel through which the source - * pulls voicemail data from a remote server. - *

Possible values: - * {@link #DATA_CHANNEL_STATE_OK}, - * {@link #DATA_CHANNEL_STATE_NO_CONNECTION} - *

- *

Type: INTEGER

- */ - public static final String DATA_CHANNEL_STATE = "data_channel_state"; - public static final int DATA_CHANNEL_STATE_OK = 0; - public static final int DATA_CHANNEL_STATE_NO_CONNECTION = 1; - /** - * The notification channel state of the voicemail source. This is the channel through which - * the source gets notified of new voicemails on the remote server. - *

Possible values: - * {@link #NOTIFICATION_CHANNEL_STATE_OK}, - * {@link #NOTIFICATION_CHANNEL_STATE_NO_CONNECTION}, - * {@link #NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING} - *

- *

Type: INTEGER

- */ - public static final String NOTIFICATION_CHANNEL_STATE = "notification_channel_state"; - public static final int NOTIFICATION_CHANNEL_STATE_OK = 0; - public static final int NOTIFICATION_CHANNEL_STATE_NO_CONNECTION = 1; - /** - * Use this state when the notification can only tell that there are pending messages on - * the server but no details of the sender/time etc are known. - */ - public static final int NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING = 2; - - /** - * A convenience method to build status URI specific to a source package by appending - * {@link VoicemailContract#PARAM_KEY_SOURCE_PACKAGE} param to the base URI. - */ - public static Uri buildSourceUri(String packageName) { - return Status.CONTENT_URI.buildUpon() - .appendQueryParameter(PARAM_KEY_SOURCE_PACKAGE, packageName).build(); - } - } -} diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java index c2a34aee0..121840af1 100644 --- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java +++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/AddVoicemailActivity.java @@ -16,6 +16,16 @@ package com.example.android.voicemail; +import com.example.android.voicemail.common.core.Voicemail; +import com.example.android.voicemail.common.core.VoicemailImpl; +import com.example.android.voicemail.common.core.VoicemailProviderHelper; +import com.example.android.voicemail.common.core.VoicemailProviderHelpers; +import com.example.android.voicemail.common.inject.InjectView; +import com.example.android.voicemail.common.inject.Injector; +import com.example.android.voicemail.common.logging.Logger; +import com.example.android.voicemail.common.ui.DialogHelperImpl; +import com.example.android.voicemail.common.utils.CloseUtils; + import android.app.Activity; import android.app.Dialog; import android.content.Intent; @@ -28,16 +38,6 @@ import android.view.View; import android.widget.Button; import android.widget.TextView; -import com.example.android.voicemail.common.core.Voicemail; -import com.example.android.voicemail.common.core.VoicemailImpl; -import com.example.android.voicemail.common.core.VoicemailProviderHelper; -import com.example.android.voicemail.common.core.VoicemailProviderHelpers; -import com.example.android.voicemail.common.inject.InjectView; -import com.example.android.voicemail.common.inject.Injector; -import com.example.android.voicemail.common.logging.Logger; -import com.example.android.voicemail.common.ui.DialogHelperImpl; -import com.example.android.voicemail.common.utils.CloseUtils; - import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -131,7 +131,6 @@ public class AddVoicemailActivity extends Activity { return VoicemailImpl.createForInsertion(time, sender) .setDuration(duration) .setSourcePackage(sourcePackageName) - .setMailbox(Voicemail.Mailbox.INBOX) .build(); } diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java index 17f03c7b3..dc451cb34 100644 --- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java +++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/Voicemail.java @@ -16,8 +16,6 @@ package com.example.android.voicemail.common.core; -import com.example.android.provider.VoicemailContract; - import android.net.Uri; /** @@ -26,41 +24,6 @@ import android.net.Uri; * The presence of a field is indicated by a corresponding 'has' method. */ public interface Voicemail { - /** - * Which mailbox the message is sitting in. - *

- * Note that inbox and deleted are alone insufficient, because we may have a provider that is - * not able to undelete (re-upload) a message. Thus we need a state to represent the (common) - * case where the user has deleted a message (which results in the message being removed from - * the server) and then restored the message (where we are unable to re-upload the message to - * the server). That's what the undeleted state is for. - *

- * The presence of an undeleted mailbox prevents the voicemail source from having to keep a list - * of all such deleted-then-restored message ids, without which it would be unable to tell the - * difference between a message that has been deleted-then-restored by the user and a message - * which has been deleted on the server and should now be removed (for example one removed via - * an IVR). - */ - public enum Mailbox { - /** After being fetched from the server, a message usually starts in the inbox. */ - INBOX(VoicemailContract.Voicemails.STATE_INBOX), - /** Indicates that a message has been deleted. */ - DELETED(VoicemailContract.Voicemails.STATE_DELETED), - /** Restored from having been deleted, distinct from being in the inbox. */ - UNDELETED(VoicemailContract.Voicemails.STATE_UNDELETED); - - private final int mValue; - - private Mailbox(int value) { - mValue = value; - } - - /** Returns the DB value of this mailbox state. */ - public int getValue() { - return mValue; - } - } - /** * The identifier of the voicemail in the content provider. *

@@ -116,11 +79,6 @@ public interface Voicemail { public boolean hasUri(); - /** Tells us which mailbox the message is sitting in, returns null if this is not set. */ - public Voicemail.Mailbox getMailbox(); - - public boolean hasMailbox(); - /** * Tells us if the voicemail message has been marked as read. *

diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java index b3eab917d..5f2e0cd21 100644 --- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java +++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailFilterFactory.java @@ -20,9 +20,7 @@ import static com.example.android.voicemail.common.utils.DbQueryUtils.concatenat import static com.example.android.voicemail.common.utils.DbQueryUtils.concatenateClausesWithOr; import static com.example.android.voicemail.common.utils.DbQueryUtils.getEqualityClause; -import com.example.android.voicemail.common.core.Voicemail.Mailbox; -import com.example.android.provider.VoicemailContract.Voicemails; - +import android.provider.VoicemailContract.Voicemails; import android.text.TextUtils; import java.util.ArrayList; @@ -31,8 +29,8 @@ import java.util.List; /** * Factory class to create {@link VoicemailFilter} objects for various filtering needs. *

- * Factory methods like {@link #createWithMailbox(Mailbox)}, {@link #createWithReadStatus(boolean)} - * and {@link #createWithMatchingFields(Voicemail)} can be used to create a voicemail filter that + * Factory methods like {@link #createWithReadStatus(boolean)} and + * {@link #createWithMatchingFields(Voicemail)} can be used to create a voicemail filter that * matches the value of the specific field. *

* It is possible to combine multiple filters with OR or AND operation using the methods @@ -44,13 +42,6 @@ import java.util.List; * content provider database and is therefore less recommended. */ public class VoicemailFilterFactory { - /** Predefined filter for inbox only messages. */ - public static final VoicemailFilter INBOX_MESSAGES_FILTER = createWithOrOf( - createWithMailbox(Mailbox.INBOX), createWithMailbox(Mailbox.UNDELETED)); - /** Predefined filter for trashed messages. */ - public static final VoicemailFilter TRASHED_MESSAGES_FILTER = - createWithMailbox(Mailbox.DELETED); - /** * Creates a voicemail filter with the specified where clause. Use this method only if you know * and want to directly use the column names of the content provider. For most of the usages @@ -78,12 +69,6 @@ public class VoicemailFilterFactory { getWhereClauseForMatchingFields(fieldMatch)); } - /** Creates a voicemail filter with the specified mailbox state. */ - public static VoicemailFilter createWithMailbox(Mailbox mailbox) { - return createWithMatchingFields( - VoicemailImpl.createEmptyBuilder().setMailbox(mailbox).build()); - } - /** Creates a voicemail filter with the specified read status. */ public static VoicemailFilter createWithReadStatus(boolean isRead) { return createWithMatchingFields( @@ -111,11 +96,7 @@ public class VoicemailFilterFactory { private static String getWhereClauseForMatchingFields(Voicemail fieldMatch) { List clauses = new ArrayList(); if (fieldMatch.hasRead()) { - clauses.add(getEqualityClause(Voicemails.NEW, fieldMatch.isRead() ? "1" : "0")); - } - if (fieldMatch.hasMailbox()) { - clauses.add(getEqualityClause(Voicemails.STATE, - Integer.toString(fieldMatch.getMailbox().getValue()))); + clauses.add(getEqualityClause(Voicemails.IS_READ, fieldMatch.isRead() ? "1" : "0")); } if (fieldMatch.hasNumber()) { clauses.add(getEqualityClause(Voicemails.NUMBER, fieldMatch.getNumber())); diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java index 9e08b6838..491302bc3 100644 --- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java +++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailImpl.java @@ -29,7 +29,6 @@ public final class VoicemailImpl implements Voicemail { private final String mSource; private final String mProviderData; private final Uri mUri; - private final Voicemail.Mailbox mMailbox; private final Boolean mIsRead; private final boolean mHasContent; @@ -44,7 +43,6 @@ public final class VoicemailImpl implements Voicemail { String source, String providerData, Uri uri, - Voicemail.Mailbox mailbox, Boolean isRead, boolean hasContent) { mId = id; @@ -54,7 +52,6 @@ public final class VoicemailImpl implements Voicemail { mSource = source; mProviderData = providerData; mUri = uri; - mMailbox = mailbox; mIsRead = isRead; mHasContent = hasContent; } @@ -100,7 +97,6 @@ public final class VoicemailImpl implements Voicemail { private String mBuilderSourcePackage; private String mBuilderSourceData; private Uri mBuilderUri; - private Voicemail.Mailbox mBuilderMailbox; private Boolean mBuilderIsRead; private boolean mBuilderHasContent; @@ -143,11 +139,6 @@ public final class VoicemailImpl implements Voicemail { return this; } - public Builder setMailbox(Voicemail.Mailbox mailbox) { - mBuilderMailbox = mailbox; - return this; - } - public Builder setIsRead(boolean isRead) { mBuilderIsRead = isRead; return this; @@ -161,7 +152,7 @@ public final class VoicemailImpl implements Voicemail { public VoicemailImpl build() { return new VoicemailImpl(mBuilderTimestamp, mBuilderNumber, mBuilderId, mBuilderDuration, - mBuilderSourcePackage, mBuilderSourceData, mBuilderUri, mBuilderMailbox, + mBuilderSourcePackage, mBuilderSourceData, mBuilderUri, mBuilderIsRead, mBuilderHasContent); } @@ -237,16 +228,6 @@ public final class VoicemailImpl implements Voicemail { return mUri != null; } - @Override - public Mailbox getMailbox() { - return mMailbox; - } - - @Override - public boolean hasMailbox() { - return mMailbox != null; - } - @Override public boolean isRead() { return hasRead() ? mIsRead : false; @@ -266,7 +247,7 @@ public final class VoicemailImpl implements Voicemail { public String toString() { return "VoicemailImpl [mTimestamp=" + mTimestamp + ", mNumber=" + mNumber + ", mId=" + mId + ", mDuration=" + mDuration + ", mSource=" + mSource + ", mProviderData=" - + mProviderData + ", mUri=" + mUri + ", mMailbox=" + mMailbox + ", mIsRead=" - + mIsRead + ", mHasContent=" + mHasContent + "]"; + + mProviderData + ", mUri=" + mUri + ", mIsRead=" + mIsRead + ", mHasContent=" + + mHasContent + "]"; } } diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java index d3ff51469..9cb6a3b29 100644 --- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java +++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelper.java @@ -16,7 +16,7 @@ package com.example.android.voicemail.common.core; -import com.example.android.provider.VoicemailContract; +import android.provider.VoicemailContract; import android.net.Uri; diff --git a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java index 2d8d9bc1a..18404627d 100644 --- a/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java +++ b/samples/VoicemailProviderDemo/src/com/example/android/voicemail/common/core/VoicemailProviderHelpers.java @@ -16,7 +16,6 @@ package com.example.android.voicemail.common.core; -import com.example.android.provider.VoicemailContract.Voicemails; import com.example.android.voicemail.common.logging.Logger; import com.example.android.voicemail.common.utils.CloseUtils; import com.example.android.voicemail.common.utils.DbQueryUtils; @@ -27,6 +26,8 @@ import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; +import android.provider.VoicemailContract; +import android.provider.VoicemailContract.Voicemails; import java.io.IOException; import java.io.OutputStream; @@ -48,8 +49,7 @@ public final class VoicemailProviderHelpers implements VoicemailProviderHelper { Voicemails.DATE, Voicemails.SOURCE_PACKAGE, Voicemails.SOURCE_DATA, - Voicemails.NEW, - Voicemails.STATE + Voicemails.IS_READ }; private final ContentResolver mContentResolver; @@ -98,6 +98,10 @@ public final class VoicemailProviderHelpers implements VoicemailProviderHelper { check(voicemail.hasNumber(), "Inserted voicemails must have a number", voicemail); logger.d(String.format("Inserting new voicemail: %s", voicemail)); ContentValues contentValues = getContentValues(voicemail); + if (!voicemail.hasRead()) { + // If is_read is not set then set it to false as default value. + contentValues.put(Voicemails.IS_READ, 0); + } return mContentResolver.insert(mBaseUri, contentValues); } @@ -250,9 +254,7 @@ public final class VoicemailProviderHelpers implements VoicemailProviderHelper { .setUri(buildUriWithSourcePackage(id, sourcePackage)) .setHasContent(cursor.getInt( cursor.getColumnIndexOrThrow(Voicemails.HAS_CONTENT)) == 1) - .setIsRead(cursor.getInt(cursor.getColumnIndexOrThrow(Voicemails.NEW)) == 1) - .setMailbox(mapValueToMailBoxEnum(cursor.getInt( - cursor.getColumnIndexOrThrow(Voicemails.STATE)))) + .setIsRead(cursor.getInt(cursor.getColumnIndexOrThrow(Voicemails.IS_READ)) == 1) .build(); return voicemail; } @@ -261,15 +263,6 @@ public final class VoicemailProviderHelpers implements VoicemailProviderHelper { return ContentUris.withAppendedId(Voicemails.buildSourceUri(sourcePackage), id); } - private Voicemail.Mailbox mapValueToMailBoxEnum(int value) { - for (Voicemail.Mailbox mailbox : Voicemail.Mailbox.values()) { - if (mailbox.getValue() == value) { - return mailbox; - } - } - throw new IllegalArgumentException("Value: " + value + " not valid for Voicemail.Mailbox."); - } - /** * Maps structured {@link Voicemail} to {@link ContentValues} understood by content provider. */ @@ -291,10 +284,7 @@ public final class VoicemailProviderHelpers implements VoicemailProviderHelper { contentValues.put(Voicemails.SOURCE_DATA, voicemail.getSourceData()); } if (voicemail.hasRead()) { - contentValues.put(Voicemails.NEW, voicemail.isRead() ? 1 : 0); - } - if (voicemail.hasMailbox()) { - contentValues.put(Voicemails.STATE, voicemail.getMailbox().getValue()); + contentValues.put(Voicemails.IS_READ, voicemail.isRead() ? 1 : 0); } return contentValues; }