Include a separate message for call details page in voicemail StatusMessage.
With this change now a StatusMessage also carries the info about where
it must be shown.
Bug: 5040099
Change-Id: Ib0d430b5eda1a7031ce90d84916b0159ac7cfd38
diff --git a/src/com/android/contacts/calllog/CallLogFragment.java b/src/com/android/contacts/calllog/CallLogFragment.java
index 4bc9f10..0deeb21 100644
--- a/src/com/android/contacts/calllog/CallLogFragment.java
+++ b/src/com/android/contacts/calllog/CallLogFragment.java
@@ -941,8 +941,8 @@
mStatusMessageView.setVisibility(View.VISIBLE);
// TODO: Change the code to show all messages. For now just pick the first message.
final StatusMessage message = messages.get(0);
- if (message.statusMessageId != -1) {
- mStatusMessageText.setText(message.statusMessageId);
+ if (message.showInCallLog()) {
+ mStatusMessageText.setText(message.callLogMessageId);
}
if (message.actionMessageId != -1) {
mStatusMessageAction.setText(message.actionMessageId);
diff --git a/src/com/android/contacts/calllog/VoicemailStatusHelper.java b/src/com/android/contacts/calllog/VoicemailStatusHelper.java
index 910a4f7..f6def45 100644
--- a/src/com/android/contacts/calllog/VoicemailStatusHelper.java
+++ b/src/com/android/contacts/calllog/VoicemailStatusHelper.java
@@ -35,19 +35,38 @@
public class StatusMessage {
/** Package of the source on behalf of which this message has to be shown.*/
public final String sourcePackage;
- /** The string resource id of the status message that should be shown. */
- public final int statusMessageId;
+ /**
+ * The string resource id of the status message that should be shown in the call log
+ * page. Set to -1, if this message is not to be shown in call log.
+ */
+ public final int callLogMessageId;
+ /**
+ * The string resource id of the status message that should be shown in the call details
+ * page. Set to -1, if this message is not to be shown in call details page.
+ */
+ public final int callDetailsMessageId;
/** The string resource id of the action message that should be shown. */
public final int actionMessageId;
/** URI for the corrective action, where applicable. Null if no action URI is available. */
public final Uri actionUri;
- public StatusMessage(String sourcePackage, int statusMessageId, int actionMessageId,
- Uri actionUri) {
+ public StatusMessage(String sourcePackage, int callLogMessageId, int callDetailsMessageId,
+ int actionMessageId, Uri actionUri) {
this.sourcePackage = sourcePackage;
- this.statusMessageId = statusMessageId;
+ this.callLogMessageId = callLogMessageId;
+ this.callDetailsMessageId = callDetailsMessageId;
this.actionMessageId = actionMessageId;
this.actionUri = actionUri;
}
+
+ /** Whether this message should be shown in the call log page. */
+ public boolean showInCallLog() {
+ return callLogMessageId != -1;
+ }
+
+ /** Whether this message should be shown in the call details page. */
+ public boolean showInCallDetails() {
+ return callDetailsMessageId != -1;
+ }
}
/**
diff --git a/src/com/android/contacts/calllog/VoicemailStatusHelperImpl.java b/src/com/android/contacts/calllog/VoicemailStatusHelperImpl.java
index 6296542..972fbd5 100644
--- a/src/com/android/contacts/calllog/VoicemailStatusHelperImpl.java
+++ b/src/com/android/contacts/calllog/VoicemailStatusHelperImpl.java
@@ -81,11 +81,14 @@
// TODO: Add separate string for call details and call log pages for the states that needs
// to be shown in both.
/** Both notification and data channel are not working. */
- NO_CONNECTION(0, Action.CALL_VOICEMAIL, R.string.voicemail_status_voicemail_not_available),
+ NO_CONNECTION(0, Action.CALL_VOICEMAIL, R.string.voicemail_status_voicemail_not_available,
+ R.string.voicemail_status_audio_not_available),
/** Notifications working, but data channel is not working. Audio cannot be downloaded. */
- NO_DATA(1, Action.CALL_VOICEMAIL, R.string.voicemail_status_audio_not_available),
+ NO_DATA(1, Action.CALL_VOICEMAIL, R.string.voicemail_status_voicemail_not_available,
+ R.string.voicemail_status_audio_not_available),
/** Messages are known to be waiting but data channel is not working. */
- MESSAGE_WAITING(2, Action.CALL_VOICEMAIL, R.string.voicemail_status_messages_waiting),
+ MESSAGE_WAITING(2, Action.CALL_VOICEMAIL, R.string.voicemail_status_messages_waiting,
+ R.string.voicemail_status_audio_not_available),
/** Notification channel not working, but data channel is. */
NO_NOTIFICATIONS(3, Action.CALL_VOICEMAIL,
R.string.voicemail_status_voicemail_not_available),
@@ -106,12 +109,19 @@
private final int mPriority;
private final Action mAction;
- private final int mMessageId;
+ private final int mCallLogMessageId;
+ private final int mCallDetailsMessageId;
- private OverallState(int priority, Action action, int messageId) {
+ private OverallState(int priority, Action action, int callLogMessageId) {
+ this(priority, action, callLogMessageId, -1);
+ }
+
+ private OverallState(int priority, Action action, int callLogMessageId,
+ int callDetailsMessageId) {
mPriority = priority;
mAction = action;
- mMessageId = messageId;
+ mCallLogMessageId = callLogMessageId;
+ mCallDetailsMessageId = callDetailsMessageId;
}
public Action getAction() {
@@ -122,8 +132,12 @@
return mPriority;
}
- public int getMessageId() {
- return mMessageId;
+ public int getCallLogMessageId() {
+ return mCallLogMessageId;
+ }
+
+ public int getCallDetailsMessageId() {
+ return mCallDetailsMessageId;
}
}
@@ -196,7 +210,8 @@
actionUri = Uri.parse(cursor.getString(SETTINGS_URI_INDEX));
}
return new MessageStatusWithPriority(
- new StatusMessage(sourcePackage, overallState.getMessageId(), action.getMessageId(),
+ new StatusMessage(sourcePackage, overallState.getCallLogMessageId(),
+ overallState.getCallDetailsMessageId(), action.getMessageId(),
actionUri),
overallState.getPriority());
}
diff --git a/tests/src/com/android/contacts/calllog/VoicemailStatusHelperImplTest.java b/tests/src/com/android/contacts/calllog/VoicemailStatusHelperImplTest.java
index 0501a9a..9b293c4 100644
--- a/tests/src/com/android/contacts/calllog/VoicemailStatusHelperImplTest.java
+++ b/tests/src/com/android/contacts/calllog/VoicemailStatusHelperImplTest.java
@@ -55,6 +55,7 @@
R.string.voicemail_status_action_call_server;
private static final int ACTION_MSG_CONFIGURE = R.string.voicemail_status_action_configure;
+ private static final int STATUS_MSG_NONE = -1;
private static final int STATUS_MSG_VOICEMAIL_NOT_AVAILABLE =
R.string.voicemail_status_voicemail_not_available;
private static final int STATUS_MSG_AUDIO_NOT_AVAIALABLE =
@@ -104,12 +105,14 @@
insertEntryForPackage(TEST_PACKAGE_2, getAllOkStatusValues());
ContentValues values = new ContentValues();
- // No notification + good data channel - for now same as no connection.
+ // Good data channel + no notification
+ // action: call voicemail
+ // msg: voicemail not available in call log page & none in call details page.
values.put(NOTIFICATION_CHANNEL_STATE, NOTIFICATION_CHANNEL_STATE_NO_CONNECTION);
values.put(DATA_CHANNEL_STATE, DATA_CHANNEL_STATE_OK);
updateEntryForPackage(TEST_PACKAGE_2, values);
checkExpectedMessage(TEST_PACKAGE_2, values, STATUS_MSG_VOICEMAIL_NOT_AVAILABLE,
- ACTION_MSG_CALL_VOICEMAIL);
+ STATUS_MSG_NONE, ACTION_MSG_CALL_VOICEMAIL);
// Message waiting + good data channel - no action.
values.put(NOTIFICATION_CHANNEL_STATE, NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING);
@@ -117,26 +120,32 @@
updateEntryForPackage(TEST_PACKAGE_2, values);
checkNoMessages(TEST_PACKAGE_2, values);
- // Notification OK + no data channel - call voicemail/no audio.
+ // No data channel + no notification
+ // action: call voicemail
+ // msg: voicemail not available in call log page & audio not available in call details page.
values.put(NOTIFICATION_CHANNEL_STATE, NOTIFICATION_CHANNEL_STATE_OK);
values.put(DATA_CHANNEL_STATE, DATA_CHANNEL_STATE_NO_CONNECTION);
updateEntryForPackage(TEST_PACKAGE_2, values);
- checkExpectedMessage(TEST_PACKAGE_2, values, STATUS_MSG_AUDIO_NOT_AVAIALABLE,
- ACTION_MSG_CALL_VOICEMAIL);
+ checkExpectedMessage(TEST_PACKAGE_2, values, STATUS_MSG_VOICEMAIL_NOT_AVAILABLE,
+ STATUS_MSG_AUDIO_NOT_AVAIALABLE, ACTION_MSG_CALL_VOICEMAIL);
- // No notification + no data channel - call voicemail/no connection.
+ // No data channel + Notification OK
+ // action: call voicemail
+ // msg: voicemail not available in call log page & audio not available in call details page.
values.put(NOTIFICATION_CHANNEL_STATE, NOTIFICATION_CHANNEL_STATE_NO_CONNECTION);
values.put(DATA_CHANNEL_STATE, DATA_CHANNEL_STATE_NO_CONNECTION);
updateEntryForPackage(TEST_PACKAGE_2, values);
checkExpectedMessage(TEST_PACKAGE_2, values, STATUS_MSG_VOICEMAIL_NOT_AVAILABLE,
- ACTION_MSG_CALL_VOICEMAIL);
+ STATUS_MSG_AUDIO_NOT_AVAIALABLE, ACTION_MSG_CALL_VOICEMAIL);
- // Message waiting + no data channel - call voicemail.
+ // No data channel + Notification OK
+ // action: call voicemail
+ // msg: message waiting in call log page & audio not available in call details page.
values.put(NOTIFICATION_CHANNEL_STATE, NOTIFICATION_CHANNEL_STATE_MESSAGE_WAITING);
values.put(DATA_CHANNEL_STATE, DATA_CHANNEL_STATE_NO_CONNECTION);
updateEntryForPackage(TEST_PACKAGE_2, values);
checkExpectedMessage(TEST_PACKAGE_2, values, STATUS_MSG_MESSAGE_WAITING,
- ACTION_MSG_CALL_VOICEMAIL);
+ STATUS_MSG_AUDIO_NOT_AVAIALABLE, ACTION_MSG_CALL_VOICEMAIL);
// Not configured. No user action, so no message.
values.put(CONFIGURATION_STATE, CONFIGURATION_STATE_NOT_CONFIGURED);
@@ -147,7 +156,7 @@
values.put(CONFIGURATION_STATE, CONFIGURATION_STATE_CAN_BE_CONFIGURED);
updateEntryForPackage(TEST_PACKAGE_2, values);
checkExpectedMessage(TEST_PACKAGE_2, values, STATUS_MSG_INVITE_FOR_CONFIGURATION,
- ACTION_MSG_CONFIGURE, TEST_SETTINGS_URI);
+ STATUS_MSG_NONE, ACTION_MSG_CONFIGURE, TEST_SETTINGS_URI);
}
// Test that priority of messages are handled well.
@@ -183,25 +192,28 @@
assertEquals(TEST_PACKAGE_2, messages.get(1).sourcePackage);
}
- /** Checks for the expected message with given values and actionUri as TEST_VOICEMAIL_URI. */
+ /** Checks that the expected source status message is returned by VoicemailStatusHelper. */
private void checkExpectedMessage(String sourcePackage, ContentValues values,
- int expectedStatusMsg, int expectedActionMsg) {
- checkExpectedMessage(sourcePackage, values, expectedStatusMsg, expectedActionMsg,
- TEST_VOICEMAIL_URI);
+ int expectedCallLogMsg, int expectedCallDetailsMsg, int expectedActionMsg,
+ Uri expectedUri) {
+ List<StatusMessage> messages = getStatusMessages();
+ assertEquals(1, messages.size());
+ checkMessageMatches(messages.get(0), sourcePackage, expectedCallLogMsg,
+ expectedCallDetailsMsg, expectedActionMsg, expectedUri);
}
private void checkExpectedMessage(String sourcePackage, ContentValues values,
- int expectedStatusMsg, int expectedActionMsg, Uri expectedUri) {
- List<StatusMessage> messages = getStatusMessages();
- assertEquals(1, messages.size());
- checkMessageMatches(messages.get(0), sourcePackage, expectedStatusMsg, expectedActionMsg,
- expectedUri);
+ int expectedCallLogMsg, int expectedCallDetailsMessage, int expectedActionMsg) {
+ checkExpectedMessage(sourcePackage, values, expectedCallLogMsg, expectedCallDetailsMessage,
+ expectedActionMsg, TEST_VOICEMAIL_URI);
}
private void checkMessageMatches(StatusMessage message, String expectedSourcePackage,
- int expectedStatusMsg, int expectedActionMsg, Uri expectedUri) {
+ int expectedCallLogMsg, int expectedCallDetailsMsg, int expectedActionMsg,
+ Uri expectedUri) {
assertEquals(expectedSourcePackage, message.sourcePackage);
- assertEquals(expectedStatusMsg, message.statusMessageId);
+ assertEquals(expectedCallLogMsg, message.callLogMessageId);
+ assertEquals(expectedCallDetailsMsg, message.callDetailsMessageId);
assertEquals(expectedActionMsg, message.actionMessageId);
if (expectedUri == null) {
assertNull(message.actionUri);