diff options
Diffstat (limited to 'src')
12 files changed, 172 insertions, 85 deletions
diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index dbcfa64af..7a23944a0 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -55,6 +55,7 @@ import com.android.contacts.common.ContactPhotoManager.DefaultImageRequest; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.CallUtil; import com.android.dialer.calllog.CallDetailHistoryAdapter; +import com.android.dialer.calllog.CallLogNotificationsService; import com.android.dialer.calllog.CallTypeHelper; import com.android.dialer.calllog.ContactInfo; import com.android.dialer.calllog.ContactInfoHelper; @@ -280,6 +281,9 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware values.put(Voicemails.IS_READ, true); getContentResolver().update(voicemailUri, values, Voicemails.IS_READ + " = 0", null); + Intent intent = new Intent(getBaseContext(), CallLogNotificationsService.class); + intent.setAction(CallLogNotificationsService.ACTION_MARK_NEW_VOICEMAILS_AS_OLD); + getBaseContext().startService(intent); return null; } }); diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index bb03ed137..cccc06ea0 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -207,11 +207,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O private boolean mIsLandscape; /** - * The position of the currently selected tab in the attached {@link ListsFragment}. - */ - private int mCurrentTabPosition = 0; - - /** * True if the dialpad is only temporarily showing due to being in call */ private boolean mInCallDialpadUp; @@ -591,7 +586,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O public void onClick(View view) { switch (view.getId()) { case R.id.floating_action_button: - if (!mIsDialpadShown) { + if (mListsFragment.getTabPosition() == ListsFragment.TAB_INDEX_ALL_CONTACTS) { + sendAddNewContactIntent(); + } else if (!mIsDialpadShown) { mInCallDialpadUp = false; showDialpadFragment(true); } @@ -625,14 +622,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O startActivity(intent); break; case R.id.menu_add_contact: - try { - startActivity(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI)); - } catch (ActivityNotFoundException e) { - Toast toast = Toast.makeText(this, - R.string.add_contact_not_available, - Toast.LENGTH_SHORT); - toast.show(); - } + sendAddNewContactIntent(); break; case R.id.menu_import_export: // We hard-code the "contactsAreAvailable" argument because doing it properly would @@ -1113,6 +1103,17 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O return intent; } + private void sendAddNewContactIntent() { + try { + startActivity(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI)); + } catch (ActivityNotFoundException e) { + Toast toast = Toast.makeText(this, + R.string.add_contact_not_available, + Toast.LENGTH_SHORT); + toast.show(); + } + } + private boolean canIntentBeHandled(Intent intent) { final PackageManager packageManager = getPackageManager(); final List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, @@ -1205,22 +1206,26 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } else if (position != ListsFragment.TAB_INDEX_SPEED_DIAL) { mFloatingActionButtonController.onPageScrolled(1); } + + if (position == ListsFragment.TAB_INDEX_ALL_CONTACTS) { + mFloatingActionButtonController.changeIcon( + getResources().getDrawable(R.drawable.ic_person_add_24dp), + getResources().getString(R.string.search_shortcut_create_new_contact)); + } else { + mFloatingActionButtonController.changeIcon( + getResources().getDrawable(R.drawable.fab_ic_dial), + getResources().getString(R.string.action_menu_dialpad_button)); + } } @Override public void onPageSelected(int position) { - position = mListsFragment.getRtlPosition(position); - mCurrentTabPosition = position; } @Override public void onPageScrollStateChanged(int state) { } - private TelephonyManager getTelephonyManager() { - return (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); - } - private TelecomManager getTelecomManager() { return (TelecomManager) getSystemService(Context.TELECOM_SERVICE); } @@ -1260,7 +1265,8 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * @param animate Whether or not to animate the transition. */ private void updateFloatingActionButtonControllerAlignment(boolean animate) { - int align = (!mIsLandscape && mCurrentTabPosition == ListsFragment.TAB_INDEX_SPEED_DIAL) ? + int align = (!mIsLandscape && + mListsFragment.getTabPosition() == ListsFragment.TAB_INDEX_SPEED_DIAL) ? FloatingActionButtonController.ALIGN_MIDDLE : FloatingActionButtonController.ALIGN_END; mFloatingActionButtonController.align(align, 0 /* offsetX */, 0 /* offsetY */, animate); diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 8e22834e5..e79f6eedc 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -631,7 +631,7 @@ public class CallLogAdapter extends GroupingListAdapter private void handleRowExpanded(View view, boolean forceExpand) { final CallLogListItemViewHolder views = (CallLogListItemViewHolder) view.getTag(); - if (forceExpand && isExpanded(views.rowId)) { + if (views == null || (forceExpand && isExpanded(views.rowId))) { return; } diff --git a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java index 365290077..2e12d9a0e 100644 --- a/src/com/android/dialer/calllog/CallLogListItemViewHolder.java +++ b/src/com/android/dialer/calllog/CallLogListItemViewHolder.java @@ -65,13 +65,13 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { /** The view containing call log item actions. Null until the ViewStub is inflated. */ public View actionsView; /** The "video call" action button - assigned only when the action section is expanded. */ - public TextView videoCallButtonView; + public View videoCallButtonView; /** The "voicemail" action button - assigned only when the action section is expanded. */ - public TextView voicemailButtonView; + public View voicemailButtonView; /** The "details" action button - assigned only when the action section is expanded. */ - public TextView detailsButtonView; + public View detailsButtonView; /** The "report" action button. */ - public TextView reportButtonView; + public View reportButtonView; /** * The row Id for the first call associated with the call log entry. Used as a key for the @@ -217,19 +217,19 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { } if (videoCallButtonView == null) { - videoCallButtonView = (TextView) actionsView.findViewById(R.id.video_call_action); + videoCallButtonView = actionsView.findViewById(R.id.video_call_action); } if (voicemailButtonView == null) { - voicemailButtonView = (TextView) actionsView.findViewById(R.id.voicemail_action); + voicemailButtonView = actionsView.findViewById(R.id.voicemail_action); } if (detailsButtonView == null) { - detailsButtonView = (TextView) actionsView.findViewById(R.id.details_action); + detailsButtonView = actionsView.findViewById(R.id.details_action); } if (reportButtonView == null) { - reportButtonView = (TextView) actionsView.findViewById(R.id.report_action); + reportButtonView = actionsView.findViewById(R.id.report_action); reportButtonView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -341,29 +341,6 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder { actionsView.setVisibility(View.GONE); } } - - if (actionsView != null) { - final ViewTreeObserver observer = callLogEntryView.getViewTreeObserver(); - observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { - @Override - public boolean onPreDraw() { - ViewTreeObserver vto = observer; - if (!vto.isAlive()) { - vto = actionsView.getViewTreeObserver(); - } - vto.removeOnPreDrawListener(this); - - // TODO: Animate, instead of immediately resizing. - int currentHeight = primaryActionView.getHeight(); - int actionsHeight = actionsView.getVisibility() == View.VISIBLE - ? actionsView.getHeight() : 0; - callLogEntryView.getLayoutParams().height = currentHeight + actionsHeight; - callLogEntryView.requestLayout(); - - return false; - } - }); - } } public void expandVoicemailTranscriptionView(boolean isExpanded) { diff --git a/src/com/android/dialer/calllog/CallLogNotificationsService.java b/src/com/android/dialer/calllog/CallLogNotificationsService.java index ccd933542..2e0e50258 100644 --- a/src/com/android/dialer/calllog/CallLogNotificationsService.java +++ b/src/com/android/dialer/calllog/CallLogNotificationsService.java @@ -56,7 +56,7 @@ public class CallLogNotificationsService extends IntentService { */ public static final String EXTRA_NEW_VOICEMAIL_URI = "NEW_VOICEMAIL_URI"; - private CallLogQueryHandler mCallLogQueryHandler; + private VoicemailQueryHandler mVoicemailQueryHandler; public CallLogNotificationsService() { super("CallLogNotificationsService"); @@ -65,7 +65,7 @@ public class CallLogNotificationsService extends IntentService { @Override public void onCreate() { super.onCreate(); - mCallLogQueryHandler = new CallLogQueryHandler(getContentResolver(), null /*listener*/); + mVoicemailQueryHandler = new VoicemailQueryHandler(this, getContentResolver()); } @Override @@ -74,8 +74,9 @@ public class CallLogNotificationsService extends IntentService { Log.d(TAG, "onHandleIntent: could not handle null intent"); return; } + if (ACTION_MARK_NEW_VOICEMAILS_AS_OLD.equals(intent.getAction())) { - mCallLogQueryHandler.markNewVoicemailsAsOld(); + mVoicemailQueryHandler.markNewVoicemailsAsOld(); } else if (ACTION_UPDATE_NOTIFICATIONS.equals(intent.getAction())) { Uri voicemailUri = (Uri) intent.getParcelableExtra(EXTRA_NEW_VOICEMAIL_URI); DefaultVoicemailNotifier.getInstance(this).updateNotification(voicemailUri); diff --git a/src/com/android/dialer/calllog/CallLogQueryHandler.java b/src/com/android/dialer/calllog/CallLogQueryHandler.java index 761c8e08c..7eb5f8a0b 100644 --- a/src/com/android/dialer/calllog/CallLogQueryHandler.java +++ b/src/com/android/dialer/calllog/CallLogQueryHandler.java @@ -20,8 +20,6 @@ import android.content.AsyncQueryHandler; import android.content.ContentResolver; import android.content.ContentValues; import android.database.Cursor; -import android.database.MatrixCursor; -import android.database.MergeCursor; import android.database.sqlite.SQLiteDatabaseCorruptException; import android.database.sqlite.SQLiteDiskIOException; import android.database.sqlite.SQLiteException; @@ -35,7 +33,6 @@ 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; @@ -55,12 +52,10 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { private static final int QUERY_CALLLOG_TOKEN = 54; /** The token for the query to mark all missed calls as old after seeing the call log. */ private static final int UPDATE_MARK_AS_OLD_TOKEN = 55; - /** The token for the query to mark all new voicemails as old. */ - private static final int UPDATE_MARK_VOICEMAILS_AS_OLD_TOKEN = 56; /** The token for the query to mark all missed calls as read after seeing the call log. */ - private static final int UPDATE_MARK_MISSED_CALL_AS_READ_TOKEN = 57; + private static final int UPDATE_MARK_MISSED_CALL_AS_READ_TOKEN = 56; /** The token for the query to fetch voicemail status messages. */ - private static final int QUERY_VOICEMAIL_STATUS_TOKEN = 58; + private static final int QUERY_VOICEMAIL_STATUS_TOKEN = 57; private final int mLogLimit; @@ -195,22 +190,6 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { values, where.toString(), null); } - /** Updates all new voicemails to mark them as old. */ - public void markNewVoicemailsAsOld() { - // Mark all "new" voicemails as not new anymore. - StringBuilder where = new StringBuilder(); - where.append(Calls.NEW); - where.append(" = 1 AND "); - where.append(Calls.TYPE); - where.append(" = ?"); - - ContentValues values = new ContentValues(1); - values.put(Calls.NEW, "0"); - - startUpdate(UPDATE_MARK_VOICEMAILS_AS_OLD_TOKEN, null, Calls.CONTENT_URI_WITH_VOICEMAIL, - values, where.toString(), new String[]{ Integer.toString(Calls.VOICEMAIL_TYPE) }); - } - /** Updates all missed calls to mark them as read. */ public void markMissedCallsAsRead() { // Mark all "new" calls as not new anymore. @@ -227,7 +206,8 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { } @Override - protected synchronized void onNotNullableQueryComplete(int token, Object cookie, Cursor cursor) { + protected synchronized void onNotNullableQueryComplete(int token, Object cookie, + Cursor cursor) { if (cursor == null) { return; } @@ -274,7 +254,7 @@ public class CallLogQueryHandler extends NoNullCursorAsyncQueryHandler { void onVoicemailStatusFetched(Cursor statusCursor); /** - * Called when {@link CallLogQueryHandler#fetchCalls(int)}complete. + * Called when {@link CallLogQueryHandler#fetchCalls(int)} complete. * Returns true if takes ownership of cursor. */ boolean onCallsFetched(Cursor combinedCursor); diff --git a/src/com/android/dialer/calllog/CallTypeIconsView.java b/src/com/android/dialer/calllog/CallTypeIconsView.java index ef729ae39..31d4f4b0e 100644 --- a/src/com/android/dialer/calllog/CallTypeIconsView.java +++ b/src/com/android/dialer/calllog/CallTypeIconsView.java @@ -208,7 +208,7 @@ public class CallTypeIconsView extends View { // We want the video call icon to be the same height as the call arrows, while keeping // the same width aspect ratio. Bitmap videoIcon = BitmapFactory.decodeResource(context.getResources(), - R.drawable.ic_videocam_wht_24dp); + R.drawable.ic_videocam_24dp); int scaledHeight = missed.getIntrinsicHeight(); int scaledWidth = (int) ((float) videoIcon.getWidth() * ((float) missed.getIntrinsicHeight() / diff --git a/src/com/android/dialer/calllog/VoicemailQueryHandler.java b/src/com/android/dialer/calllog/VoicemailQueryHandler.java new file mode 100644 index 000000000..26f9bd172 --- /dev/null +++ b/src/com/android/dialer/calllog/VoicemailQueryHandler.java @@ -0,0 +1,69 @@ +/* + * 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.calllog; + +import android.content.AsyncQueryHandler; +import android.content.ContentResolver; +import android.content.ContentValues; +import android.content.Context; +import android.content.Intent; +import android.provider.CallLog.Calls; +import android.util.Log; + +/** + * Handles asynchronous queries to the call log for voicemail. + */ +public class VoicemailQueryHandler extends AsyncQueryHandler { + private static final String TAG = "VoicemailQueryHandler"; + + /** The token for the query to mark all new voicemails as old. */ + private static final int UPDATE_MARK_VOICEMAILS_AS_OLD_TOKEN = 50; + private Context mContext; + + public VoicemailQueryHandler(Context context, ContentResolver contentResolver) { + super(contentResolver); + mContext = context; + } + + /** Updates all new voicemails to mark them as old. */ + public void markNewVoicemailsAsOld() { + // Mark all "new" voicemails as not new anymore. + StringBuilder where = new StringBuilder(); + where.append(Calls.NEW); + where.append(" = 1 AND "); + where.append(Calls.TYPE); + where.append(" = ?"); + + ContentValues values = new ContentValues(1); + values.put(Calls.NEW, "0"); + + startUpdate(UPDATE_MARK_VOICEMAILS_AS_OLD_TOKEN, null, Calls.CONTENT_URI_WITH_VOICEMAIL, + values, where.toString(), new String[]{ Integer.toString(Calls.VOICEMAIL_TYPE) }); + } + + @Override + protected void onUpdateComplete(int token, Object cookie, int result) { + if (token == UPDATE_MARK_VOICEMAILS_AS_OLD_TOKEN) { + if (mContext != null) { + Intent serviceIntent = new Intent(mContext, CallLogNotificationsService.class); + serviceIntent.setAction(CallLogNotificationsService.ACTION_UPDATE_NOTIFICATIONS); + mContext.startService(serviceIntent); + } else { + Log.w(TAG, "Unknown update completed: ignoring: " + token); + } + } + } +} diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index d8b507eaa..6a66eb388 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -399,7 +399,7 @@ public class DialpadFragment extends Fragment final View floatingActionButtonContainer = fragmentView.findViewById(R.id.dialpad_floating_action_button_container); - final View floatingActionButton = + final ImageButton floatingActionButton = (ImageButton) fragmentView.findViewById(R.id.dialpad_floating_action_button); floatingActionButton.setOnClickListener(this); mFloatingActionButtonController = new FloatingActionButtonController(getActivity(), diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index 4e7e00de6..6e30af299 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -79,6 +79,11 @@ public class ListsFragment extends Fragment implements ViewPager.OnPageChangeLis private int[] mTabIcons; /** + * The position of the currently selected tab. + */ + private int mTabPosition = TAB_INDEX_SPEED_DIAL; + + /** * Call shortcuts older than this date (persisted in shared preferences) will not show up in * at the top of the screen */ @@ -225,6 +230,8 @@ public class ListsFragment extends Fragment implements ViewPager.OnPageChangeLis @Override public void onPageSelected(int position) { + mTabPosition = getRtlPosition(position); + final int count = mOnPageChangeListeners.size(); for (int i = 0; i < count; i++) { mOnPageChangeListeners.get(i).onPageSelected(position); @@ -240,6 +247,10 @@ public class ListsFragment extends Fragment implements ViewPager.OnPageChangeLis } } + public int getTabPosition() { + return mTabPosition; + } + public void showRemoveView(boolean show) { mRemoveViewContent.setVisibility(show ? View.VISIBLE : View.GONE); mRemoveView.setAlpha(show ? 0 : 1); diff --git a/src/com/android/dialer/list/RegularSearchListAdapter.java b/src/com/android/dialer/list/RegularSearchListAdapter.java index 3c55bc012..6c7045814 100644 --- a/src/com/android/dialer/list/RegularSearchListAdapter.java +++ b/src/com/android/dialer/list/RegularSearchListAdapter.java @@ -68,7 +68,9 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { @Override public void setQueryString(String queryString) { - final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString()); + // Don't show actions if the query string contains a letter. + final boolean showNumberShortcuts = !TextUtils.isEmpty(getFormattedQueryString()) + && hasDigitsInQueryString(); boolean changed = false; changed |= setShortcutEnabled(SHORTCUT_DIRECT_CALL, showNumberShortcuts); changed |= setShortcutEnabled(SHORTCUT_SEND_SMS_MESSAGE, showNumberShortcuts); @@ -79,4 +81,18 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter { } super.setQueryString(queryString); } + + /** + * Whether there is at least one digit in the query string. + */ + private boolean hasDigitsInQueryString() { + String queryString = getQueryString(); + int length = queryString.length(); + for (int i = 0; i < length; i++) { + if (Character.isDigit(queryString.charAt(i))) { + return true; + } + } + return false; + } } diff --git a/src/com/android/dialer/widget/SearchEditTextLayout.java b/src/com/android/dialer/widget/SearchEditTextLayout.java index f22a3be9e..f1fa9868a 100644 --- a/src/com/android/dialer/widget/SearchEditTextLayout.java +++ b/src/com/android/dialer/widget/SearchEditTextLayout.java @@ -20,6 +20,9 @@ import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.content.Context; import android.util.AttributeSet; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; import android.view.KeyEvent; import android.view.View; import android.widget.EditText; @@ -123,6 +126,21 @@ public class SearchEditTextLayout extends FrameLayout { } }); + mSearchView.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + mClearButtonView.setVisibility(TextUtils.isEmpty(s) ? View.GONE : View.VISIBLE); + } + + @Override + public void afterTextChanged(Editable s) { + } + }); + findViewById(R.id.search_close_button).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -177,6 +195,7 @@ public class SearchEditTextLayout extends FrameLayout { mIsFadedOut = true; } } + public void expand(boolean animate, boolean requestFocus) { updateVisibility(true /* isExpand */); @@ -245,7 +264,11 @@ public class SearchEditTextLayout extends FrameLayout { // TODO: Prevents keyboard from jumping up in landscape mode after exiting the // SearchFragment when the query string is empty. More elegant fix? //mExpandedSearchBox.setVisibility(expandedViewVisibility); - mClearButtonView.setVisibility(expandedViewVisibility); + if (TextUtils.isEmpty(mSearchView.getText())) { + mClearButtonView.setVisibility(View.GONE); + } else { + mClearButtonView.setVisibility(expandedViewVisibility); + } } private void prepareAnimator(final boolean expand) { |