diff options
author | Andrew Lee <anwlee@google.com> | 2015-05-14 17:57:32 -0700 |
---|---|---|
committer | Andrew Lee <anwlee@google.com> | 2015-05-14 18:27:04 -0700 |
commit | 6ed11569195e1a267aacd14b5464f73f3578f738 (patch) | |
tree | d3ada29124323a3e13b53c8c38e57da5f6da5427 | |
parent | 4937a7223c63c7bbdfcc8463195d315cfdbb1aba (diff) |
Remove VM StatusMessage code from Call Details.
This isn't used in any particular case right now.
Remove some unused layouts too.
Bug: 21170557
Change-Id: Ie21264d7059e73c905b2807b993b95c91a0dd3ec
-rw-r--r-- | res/layout/call_details_voicemail_header.xml | 15 | ||||
-rw-r--r-- | res/layout/call_log_voicemail_status.xml | 46 | ||||
-rw-r--r-- | src/com/android/dialer/CallDetailActivity.java | 59 | ||||
-rw-r--r-- | src/com/android/dialer/CallDetailActivityQueryHandler.java | 105 |
4 files changed, 4 insertions, 221 deletions
diff --git a/res/layout/call_details_voicemail_header.xml b/res/layout/call_details_voicemail_header.xml index f2a016b22..7f8b9b81e 100644 --- a/res/layout/call_details_voicemail_header.xml +++ b/res/layout/call_details_voicemail_header.xml @@ -18,14 +18,6 @@ android:layout_height="wrap_content" android:orientation="vertical" > - <FrameLayout - android:id="@+id/voicemail_status" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="gone" - > - <include layout="@layout/call_log_voicemail_status"/> - </FrameLayout> <TextView android:id="@+id/voicemail_transcription" android:layout_width="match_parent" @@ -34,14 +26,15 @@ android:paddingEnd="@dimen/call_detail_horizontal_margin" android:paddingTop="@dimen/transcription_top_margin" android:paddingBottom="@dimen/transcription_bottom_margin" /> + <LinearLayout android:id="@+id/voicemail_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:paddingBottom="@dimen/call_detail_button_spacing" - android:visibility="gone" - > + android:visibility="gone"> <!-- The voicemail fragment will be put here. --> </LinearLayout> -</LinearLayout>
\ No newline at end of file + +</LinearLayout> diff --git a/res/layout/call_log_voicemail_status.xml b/res/layout/call_log_voicemail_status.xml deleted file mode 100644 index be808e400..000000000 --- a/res/layout/call_log_voicemail_status.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- 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. ---> -<merge xmlns:android="http://schemas.android.com/apk/res/android"> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="?attr/call_log_voicemail_status_height" - android:background="?attr/call_log_voicemail_status_background_color" - > - <TextView - android:id="@+id/voicemail_status_message" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="center_vertical" - android:layout_weight="1" - android:paddingStart="@dimen/call_log_outer_margin" - android:paddingEnd="@dimen/call_log_inner_margin" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textColor="?attr/call_log_voicemail_status_text_color" - /> - <TextView - android:id="@+id/voicemail_status_action" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:gravity="center_vertical" - android:paddingStart="@dimen/call_log_inner_margin" - android:paddingEnd="@dimen/call_log_outer_margin" - android:textAppearance="?android:attr/textAppearanceMedium" - android:textColor="?attr/call_log_voicemail_status_action_text_color" - android:background="?android:attr/selectableItemBackground" - android:clickable="true" - /> - </LinearLayout> -</merge> diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index f5802d0e2..a509c7fa1 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -121,14 +121,7 @@ public class CallDetailActivity extends Activity { /* package */ Resources mResources; /** Helper to load contact photos. */ private ContactPhotoManager mContactPhotoManager; - /** Helper to make async queries to content resolver. */ - private CallDetailActivityQueryHandler mAsyncQueryHandler; - /** Helper to get voicemail status messages. */ - private VoicemailStatusHelper mVoicemailStatusHelper; // Views related to voicemail status message. - private View mStatusMessageView; - private TextView mStatusMessageText; - private TextView mStatusMessageAction; private TextView mVoicemailTranscription; private LinearLayout mVoicemailHeader; @@ -182,8 +175,6 @@ public class CallDetailActivity extends Activity { mCallTypeHelper = new CallTypeHelper(getResources()); mPhoneNumberHelper = new PhoneNumberDisplayHelper(this, mResources); - mVoicemailStatusHelper = new VoicemailStatusHelperImpl(); - mAsyncQueryHandler = new CallDetailActivityQueryHandler(this); mVoicemailUri = getIntent().getParcelableExtra(EXTRA_VOICEMAIL_URI); @@ -225,11 +216,6 @@ public class CallDetailActivity extends Activity { mVoicemailHeader = (LinearLayout) inflater.inflate(R.layout.call_details_voicemail_header, null); View voicemailContainer = mVoicemailHeader.findViewById(R.id.voicemail_container); - mStatusMessageView = mVoicemailHeader.findViewById(R.id.voicemail_status); - mStatusMessageText = - (TextView) mVoicemailHeader.findViewById(R.id.voicemail_status_message); - mStatusMessageAction = - (TextView) mVoicemailHeader.findViewById(R.id.voicemail_status_action); mVoicemailTranscription = ( TextView) mVoicemailHeader.findViewById(R.id.voicemail_transcription); ListView historyList = (ListView) findViewById(R.id.history); @@ -256,7 +242,6 @@ public class CallDetailActivity extends Activity { } voicemailContainer.setVisibility(View.VISIBLE); - mAsyncQueryHandler.startVoicemailStatusQuery(mVoicemailUri); markVoicemailAsRead(mVoicemailUri); } } @@ -592,50 +577,6 @@ public class CallDetailActivity extends Activity { } } - protected void updateVoicemailStatusMessage(Cursor statusCursor) { - if (statusCursor == null) { - mStatusMessageView.setVisibility(View.GONE); - return; - } - final StatusMessage message = getStatusMessage(statusCursor); - if (message == null || !message.showInCallDetails()) { - mStatusMessageView.setVisibility(View.GONE); - return; - } - - mStatusMessageView.setVisibility(View.VISIBLE); - mStatusMessageText.setText(message.callDetailsMessageId); - if (message.actionMessageId != -1) { - mStatusMessageAction.setText(message.actionMessageId); - } - if (message.actionUri != null) { - mStatusMessageAction.setClickable(true); - mStatusMessageAction.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - DialerUtils.startActivityWithErrorToast(CallDetailActivity.this, - new Intent(Intent.ACTION_VIEW, message.actionUri)); - } - }); - } else { - mStatusMessageAction.setClickable(false); - } - } - - private StatusMessage getStatusMessage(Cursor statusCursor) { - List<StatusMessage> messages = mVoicemailStatusHelper.getStatusMessages(statusCursor); - if (messages.size() == 0) { - return null; - } - // There can only be a single status message per source package, so num of messages can - // at most be 1. - if (messages.size() > 1) { - Log.w(TAG, String.format("Expected 1, found (%d) num of status messages." + - " Will use the first one.", messages.size())); - } - return messages.get(0); - } - @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.call_details_options, menu); diff --git a/src/com/android/dialer/CallDetailActivityQueryHandler.java b/src/com/android/dialer/CallDetailActivityQueryHandler.java deleted file mode 100644 index ecbbac114..000000000 --- a/src/com/android/dialer/CallDetailActivityQueryHandler.java +++ /dev/null @@ -1,105 +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.android.dialer; - -import android.database.Cursor; -import android.net.Uri; -import android.provider.VoicemailContract.Status; -import android.provider.VoicemailContract.Voicemails; -import android.util.Log; - -import com.android.common.io.MoreCloseables; -import com.android.contacts.common.database.NoNullCursorAsyncQueryHandler; -import com.android.dialer.voicemail.VoicemailStatusHelperImpl; - -/** - * Class used by {@link CallDetailActivity} to fire async content resolver queries. - */ -public class CallDetailActivityQueryHandler extends NoNullCursorAsyncQueryHandler { - private static final String TAG = "CallDetail"; - private static final int QUERY_VOICEMAIL_CONTENT_TOKEN = 101; - private static final int QUERY_VOICEMAIL_STATUS_TOKEN = 102; - - private final String[] VOICEMAIL_CONTENT_PROJECTION = new String[] { - Voicemails.SOURCE_PACKAGE, - Voicemails.HAS_CONTENT - }; - private static final int SOURCE_PACKAGE_COLUMN_INDEX = 0; - private static final int HAS_CONTENT_COLUMN_INDEX = 1; - - private final CallDetailActivity mCallDetailActivity; - - public CallDetailActivityQueryHandler(CallDetailActivity callDetailActivity) { - super(callDetailActivity.getContentResolver()); - mCallDetailActivity = callDetailActivity; - } - - /** - * Fires a query to update voicemail status for the given voicemail record. On completion of the - * query a call to {@link CallDetailActivity#updateVoicemailStatusMessage(Cursor)} is made. - * <p> - * if this is a voicemail record then it makes up to two asynchronous content resolver queries. - * The first one to fetch voicemail content details and check if the voicemail record has audio. - * If the voicemail record does not have an audio yet then it fires the second query to get the - * voicemail status of the associated source. - */ - public void startVoicemailStatusQuery(Uri voicemailUri) { - startQuery(QUERY_VOICEMAIL_CONTENT_TOKEN, null, voicemailUri, VOICEMAIL_CONTENT_PROJECTION, - null, null, null); - } - - @Override - protected synchronized void onNotNullableQueryComplete(int token, Object cookie, - Cursor cursor) { - try { - if (token == QUERY_VOICEMAIL_CONTENT_TOKEN) { - // Query voicemail status only if this voicemail record does not have audio. - if (moveToFirst(cursor) && hasNoAudio(cursor)) { - startQuery(QUERY_VOICEMAIL_STATUS_TOKEN, null, - Status.buildSourceUri(getSourcePackage(cursor)), - VoicemailStatusHelperImpl.PROJECTION, null, null, null); - } else { - // nothing to show in status - mCallDetailActivity.updateVoicemailStatusMessage(null); - } - } else if (token == QUERY_VOICEMAIL_STATUS_TOKEN) { - mCallDetailActivity.updateVoicemailStatusMessage(cursor); - } else { - Log.w(TAG, "Unknown query completed: ignoring: " + token); - } - } finally { - MoreCloseables.closeQuietly(cursor); - } - } - - /** Check that the cursor is non-null and can be moved to first. */ - private boolean moveToFirst(Cursor cursor) { - if (cursor == null || !cursor.moveToFirst()) { - Log.e(TAG, "Cursor not valid, could not move to first"); - return false; - } - return true; - } - - private boolean hasNoAudio(Cursor voicemailCursor) { - return voicemailCursor.getInt(HAS_CONTENT_COLUMN_INDEX) == 0; - } - - private String getSourcePackage(Cursor voicemailCursor) { - return voicemailCursor.getString(SOURCE_PACKAGE_COLUMN_INDEX); - } -} |