From 6ed11569195e1a267aacd14b5464f73f3578f738 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 14 May 2015 17:57:32 -0700 Subject: 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 --- src/com/android/dialer/CallDetailActivity.java | 59 ------------ .../dialer/CallDetailActivityQueryHandler.java | 105 --------------------- 2 files changed, 164 deletions(-) delete mode 100644 src/com/android/dialer/CallDetailActivityQueryHandler.java (limited to 'src/com/android') 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 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. - *

- * 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); - } -} -- cgit v1.2.3