diff options
Diffstat (limited to 'src/com')
8 files changed, 78 insertions, 106 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 1c933504d..3293af91a 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -176,6 +176,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O */ private ListsFragment mListsFragment; + /** + * Tracks whether onSaveInstanceState has been called. If true, no fragment transactions can + * be commited. + */ + private boolean mStateSaved; private boolean mInDialpadSearch; private boolean mInRegularSearch; private boolean mClearSearchOnPause; @@ -460,6 +465,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override protected void onResume() { super.onResume(); + mStateSaved = false; if (mFirstLaunch) { displayFragment(getIntent()); } else if (!phoneIsInUse() && mInCallDialpadUp) { @@ -481,6 +487,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O hideDialpadAndSearchUi(); mClearSearchOnPause = false; } + if (mSlideOut.hasStarted() && !mSlideOut.hasEnded()) { + commitDialpadFragmentHide(); + } super.onPause(); } @@ -493,6 +502,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch); outState.putBoolean(KEY_IS_DIALPAD_SHOWN, mIsDialpadShown); mActionBarController.saveInstanceState(outState); + mStateSaved = true; } @Override @@ -608,7 +618,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * @see #onDialpadShown */ private void showDialpadFragment(boolean animate) { - if (mIsDialpadShown) { + if (mIsDialpadShown || mStateSaved) { return; } mIsDialpadShown = true; @@ -684,10 +694,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * Finishes hiding the dialpad fragment after any animations are completed. */ private void commitDialpadFragmentHide() { - final FragmentTransaction ft = getFragmentManager().beginTransaction(); - ft.hide(mDialpadFragment); - ft.commit(); - + if (!mStateSaved && !mDialpadFragment.isHidden()) { + final FragmentTransaction ft = getFragmentManager().beginTransaction(); + ft.hide(mDialpadFragment); + ft.commit(); + } mFloatingActionButtonController.scaleIn(AnimUtils.NO_DELAY); } @@ -840,7 +851,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O * Shows the search fragment */ private void enterSearchUi(boolean smartDialSearch, String query) { - if (getFragmentManager().isDestroyed()) { + if (mStateSaved || getFragmentManager().isDestroyed()) { // Weird race condition where fragment is doing work after the activity is destroyed // due to talkback being on (b/10209937). Just return since we can't do any // constructive here. @@ -893,7 +904,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O */ private void exitSearchUi() { // See related bug in enterSearchUI(); - if (getFragmentManager().isDestroyed()) { + if (getFragmentManager().isDestroyed() || mStateSaved) { return; } @@ -914,15 +925,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mActionBarController.onSearchUiExited(); } - /** Returns an Intent to launch Call Settings screen */ - public static Intent getCallSettingsIntent() { - final Intent intent = new Intent(TelecomManager.ACTION_SHOW_CALL_SETTINGS); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - return intent; - } - @Override public void onBackPressed() { + if (mStateSaved) { + return; + } if (mIsDialpadShown) { if (TextUtils.isEmpty(mSearchQuery) || (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible() diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index bd20d2209..50520bb42 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -74,10 +74,10 @@ public class CallLogAdapter extends GroupingListAdapter /** Interface used to inform a parent UI element that a list item has been expanded. */ public interface CallItemExpandedListener { /** - * @param view The {@link CallLogListItemView} that represents the item that was clicked + * @param view The {@link View} that represents the item that was clicked * on. */ - public void onItemExpanded(CallLogListItemView view); + public void onItemExpanded(View view); /** * Retrieves the call log view for the specified call Id. If the view is not currently @@ -86,7 +86,7 @@ public class CallLogAdapter extends GroupingListAdapter * @param callId The call Id. * @return The call log view. */ - public CallLogListItemView getViewForCallId(long callId); + public View getViewForCallId(long callId); } /** Interface used to initiate a refresh of the content. */ @@ -267,6 +267,7 @@ public class CallLogAdapter extends GroupingListAdapter private int mCallLogBackgroundColor; private int mExpandedBackgroundColor; private float mExpandedTranslationZ; + private int mPhotoSize; /** Listener for the primary or secondary actions in the list. * Primary opens the call details. @@ -286,7 +287,7 @@ public class CallLogAdapter extends GroupingListAdapter private final View.OnClickListener mExpandCollapseListener = new View.OnClickListener() { @Override public void onClick(View v) { - final CallLogListItemView callLogItem = (CallLogListItemView) v.getParent().getParent(); + final View callLogItem = (View) v.getParent().getParent(); handleRowExpanded(callLogItem, true /* animate */, false /* forceExpand */); } }; @@ -296,7 +297,7 @@ public class CallLogAdapter extends GroupingListAdapter public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, AccessibilityEvent event) { if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED) { - handleRowExpanded((CallLogListItemView) host, false /* animate */, + handleRowExpanded(host, false /* animate */, true /* forceExpand */); } return super.onRequestSendAccessibilityEvent(host, child, event); @@ -365,6 +366,7 @@ public class CallLogAdapter extends GroupingListAdapter mCallLogBackgroundColor = resources.getColor(R.color.background_dialer_list_items); mExpandedBackgroundColor = resources.getColor(R.color.call_log_expanded_background_color); mExpandedTranslationZ = resources.getDimension(R.dimen.call_log_expanded_translation_z); + mPhotoSize = resources.getDimensionPixelSize(R.dimen.contact_photo_size); mContactPhotoManager = ContactPhotoManager.getInstance(mContext); mPhoneNumberHelper = new PhoneNumberDisplayHelper(mContext, resources); @@ -588,8 +590,7 @@ public class CallLogAdapter extends GroupingListAdapter @Override protected View newChildView(Context context, ViewGroup parent) { LayoutInflater inflater = LayoutInflater.from(context); - CallLogListItemView view = - (CallLogListItemView) inflater.inflate(R.layout.call_log_list_item, parent, false); + View view = inflater.inflate(R.layout.call_log_list_item, parent, false); // Get the views to bind to and cache them. CallLogListItemViews views = CallLogListItemViews.fromView(view); @@ -624,14 +625,13 @@ public class CallLogAdapter extends GroupingListAdapter /** * Binds the views in the entry to the data in the call log. * - * @param view the view corresponding to this entry + * @param callLogItemView the view corresponding to this entry * @param c the cursor pointing to the entry in the call log * @param count the number of entries in the current item, greater than 1 if it is a group */ - private void bindView(View view, Cursor c, int count) { - view.setAccessibilityDelegate(mAccessibilityDelegate); - final CallLogListItemView callLogItemView = (CallLogListItemView) view; - final CallLogListItemViews views = (CallLogListItemViews) view.getTag(); + private void bindView(View callLogItemView, Cursor c, int count) { + callLogItemView.setAccessibilityDelegate(mAccessibilityDelegate); + final CallLogListItemViews views = (CallLogListItemViews) callLogItemView.getTag(); // Default case: an item in the call log. views.primaryActionView.setVisibility(View.VISIBLE); @@ -813,11 +813,11 @@ public class CallLogAdapter extends GroupingListAdapter // Listen for the first draw if (mViewTreeObserver == null) { - mViewTreeObserver = view.getViewTreeObserver(); + mViewTreeObserver = callLogItemView.getViewTreeObserver(); mViewTreeObserver.addOnPreDrawListener(this); } - bindBadge(view, info, details, callType); + bindBadge(callLogItemView, info, details, callType); } /** @@ -886,12 +886,13 @@ public class CallLogAdapter extends GroupingListAdapter } /** - * Expands or collapses the view containing the CALLBACK, VOICEMAIL and DETAILS action buttons. + * Expands or collapses the view containing the CALLBACK/REDIAL, VOICEMAIL and DETAILS action + * buttons. * * @param callLogItem The call log entry parent view. * @param isExpanded The new expansion state of the view. */ - private void expandOrCollapseActions(CallLogListItemView callLogItem, boolean isExpanded) { + private void expandOrCollapseActions(View callLogItem, boolean isExpanded) { final CallLogListItemViews views = (CallLogListItemViews)callLogItem.getTag(); expandVoicemailTranscriptionView(views, isExpanded); @@ -1234,7 +1235,7 @@ public class CallLogAdapter extends GroupingListAdapter views.quickContactView.setOverlay(null); DefaultImageRequest request = new DefaultImageRequest(displayName, identifier, contactType, true /* isCircular */); - mContactPhotoManager.loadDirectoryPhoto(views.quickContactView, photoUri, + mContactPhotoManager.loadPhoto(views.quickContactView, photoUri, mPhotoSize, false /* darkTheme */, true /* isCircular */, request); } @@ -1386,7 +1387,7 @@ public class CallLogAdapter extends GroupingListAdapter * @param forceExpand Whether or not to force the call log row into an expanded state regardless * of its previous state */ - private void handleRowExpanded(CallLogListItemView view, boolean animate, boolean forceExpand) { + private void handleRowExpanded(View view, boolean animate, boolean forceExpand) { final CallLogListItemViews views = (CallLogListItemViews) view.getTag(); if (forceExpand && isExpanded(views.rowId)) { @@ -1407,7 +1408,7 @@ public class CallLogAdapter extends GroupingListAdapter // Animate the collapse of the previous item if it is still visible on screen. if (mPreviouslyExpanded != NONE_EXPANDED) { - CallLogListItemView previousItem = mCallItemExpandedListener.getViewForCallId( + View previousItem = mCallItemExpandedListener.getViewForCallId( mPreviouslyExpanded); if (previousItem != null) { diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index f4db08068..dfb774996 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -548,7 +548,7 @@ public class CallLogFragment extends AnalyticsListFragment } @Override - public void onItemExpanded(final CallLogListItemView view) { + public void onItemExpanded(final View view) { final int startingHeight = view.getHeight(); final CallLogListItemViews viewHolder = (CallLogListItemViews) view.getTag(); final ViewTreeObserver observer = getListView().getViewTreeObserver(); @@ -661,7 +661,7 @@ public class CallLogFragment extends AnalyticsListFragment * @return The call log view. */ @Override - public CallLogListItemView getViewForCallId(long callId) { + public View getViewForCallId(long callId) { ListView listView = getListView(); int firstPosition = listView.getFirstVisiblePosition(); @@ -673,7 +673,7 @@ public class CallLogFragment extends AnalyticsListFragment if (view != null) { final CallLogListItemViews viewHolder = (CallLogListItemViews) view.getTag(); if (viewHolder != null && viewHolder.rowId == callId) { - return (CallLogListItemView)view; + return view; } } } diff --git a/src/com/android/dialer/calllog/CallLogListItemView.java b/src/com/android/dialer/calllog/CallLogListItemView.java deleted file mode 100644 index b8990f50a..000000000 --- a/src/com/android/dialer/calllog/CallLogListItemView.java +++ /dev/null @@ -1,38 +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.calllog; - -import android.content.Context; -import android.util.AttributeSet; -import android.widget.LinearLayout; - -/** - * An entry in the call log. - */ -public class CallLogListItemView extends LinearLayout { - public CallLogListItemView(Context context) { - super(context); - } - - public CallLogListItemView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public CallLogListItemView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } -} diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index c9ea25a68..b5b31211e 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -611,26 +611,8 @@ public class DialpadFragment extends AnalyticsFragment stopWatch.lap("tm"); - // Potentially show hint text in the mDigits field when the user - // hasn't typed any digits yet. (If there's already an active call, - // this hint text will remind the user that he's about to add a new - // call.) - // - // TODO: consider adding better UI for the case where *both* lines - // are currently in use. (Right now we let the user try to add - // another call, but that call is guaranteed to fail. Perhaps the - // entire dialer UI should be disabled instead.) - if (isPhoneInUse()) { - final SpannableString hint = new SpannableString( - getActivity().getString(R.string.dialerDialpadHintText)); - hint.setSpan(new RelativeSizeSpan(0.8f), 0, hint.length(), 0); - mDigits.setHint(hint); - } else { - // Common case; no hint necessary. - mDigits.setHint(null); - - // Also, a sanity-check: the "dialpad chooser" UI should NEVER - // be visible if the phone is idle! + if (!isPhoneInUse()) { + // A sanity-check: the "dialpad chooser" UI should not be visible if the phone is idle. showDialpadChooser(false); } @@ -1203,7 +1185,7 @@ public class DialpadFragment extends AnalyticsFragment } if (enabled) { - Log.i(TAG, "Showing dialpad chooser!"); + Log.d(TAG, "Showing dialpad chooser!"); if (mDialpadView != null) { mDialpadView.setVisibility(View.GONE); } @@ -1218,7 +1200,7 @@ public class DialpadFragment extends AnalyticsFragment } mDialpadChooser.setAdapter(mDialpadChooserAdapter); } else { - Log.i(TAG, "Displaying normal Dialer UI."); + Log.d(TAG, "Displaying normal Dialer UI."); if (mDialpadView != null) { mDialpadView.setVisibility(View.VISIBLE); } else { diff --git a/src/com/android/dialer/list/ShortcutCardsAdapter.java b/src/com/android/dialer/list/ShortcutCardsAdapter.java index 4fe638ea1..78b774b02 100644 --- a/src/com/android/dialer/list/ShortcutCardsAdapter.java +++ b/src/com/android/dialer/list/ShortcutCardsAdapter.java @@ -32,7 +32,6 @@ import android.widget.TextView; import com.android.dialer.R; import com.android.dialer.calllog.CallLogAdapter; -import com.android.dialer.calllog.CallLogListItemView; import com.android.dialer.calllog.CallLogNotificationsHelper; import com.android.dialer.calllog.CallLogQueryHandler; import com.android.dialer.list.SwipeHelper.OnItemGestureListener; @@ -266,8 +265,7 @@ public class ShortcutCardsAdapter extends BaseAdapter { R.dimen.recent_call_log_item_translation_z); view.setTranslationZ(mPreviousTranslationZ); - final CallLogListItemView callLogItem = - (CallLogListItemView) view.findViewById(R.id.call_log_list_item); + final ViewGroup callLogItem = (ViewGroup) view.findViewById(R.id.call_log_list_item); // Reset the internal call log item view if it is being recycled callLogItem.setTranslationX(0); callLogItem.setTranslationY(0); diff --git a/src/com/android/dialer/settings/DialerSettingsActivity.java b/src/com/android/dialer/settings/DialerSettingsActivity.java index 7d80ac390..53c23c4b3 100644 --- a/src/com/android/dialer/settings/DialerSettingsActivity.java +++ b/src/com/android/dialer/settings/DialerSettingsActivity.java @@ -3,11 +3,15 @@ package com.android.dialer.settings; import com.google.common.collect.Lists; import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.os.UserHandle; import android.os.UserManager; import android.preference.PreferenceManager; +import android.preference.PreferenceActivity.Header; +import android.telecom.TelecomManager; +import android.telephony.TelephonyManager; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.MenuItem; @@ -45,13 +49,31 @@ public class DialerSettingsActivity extends AnalyticsPreferenceActivity { generalSettingsHeader.fragment = GeneralSettingsFragment.class.getName(); target.add(generalSettingsHeader); - // Only add the call settings header if the current user is the primary/owner user. + // Only show call setting menus if the current user is the primary/owner user. if (isPrimaryUser()) { - final Header callSettingHeader = new Header(); - callSettingHeader.titleRes = R.string.call_settings_label; - callSettingHeader.summaryRes = R.string.call_settings_description; - callSettingHeader.intent = DialtactsActivity.getCallSettingsIntent(); - target.add(callSettingHeader); + final TelephonyManager telephonyManager = + (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); + // Show "Call Settings" if there is one SIM and "Phone Accounts" if there are more. + if (telephonyManager.getPhoneCount() <= 1) { + final Header callSettingsHeader = new Header(); + Intent callSettingsIntent = new Intent(TelecomManager.ACTION_SHOW_CALL_SETTINGS); + callSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + + callSettingsHeader.titleRes = R.string.call_settings_label; + callSettingsHeader.summaryRes = R.string.call_settings_description; + callSettingsHeader.intent = callSettingsIntent; + target.add(callSettingsHeader); + } else { + final Header phoneAccountSettingsHeader = new Header(); + Intent phoneAccountSettingsIntent = + new Intent(TelecomManager.ACTION_CHANGE_PHONE_ACCOUNTS); + phoneAccountSettingsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + + phoneAccountSettingsHeader.titleRes = R.string.phone_account_settings_label; + phoneAccountSettingsHeader.summaryRes = R.string.phone_account_settings_description; + phoneAccountSettingsHeader.intent = phoneAccountSettingsIntent; + target.add(phoneAccountSettingsHeader); + } } } diff --git a/src/com/android/dialer/util/DialerUtils.java b/src/com/android/dialer/util/DialerUtils.java index 9cd4d9936..10eadffd5 100644 --- a/src/com/android/dialer/util/DialerUtils.java +++ b/src/com/android/dialer/util/DialerUtils.java @@ -71,7 +71,7 @@ public class DialerUtils { */ public static void startActivityWithErrorToast(Context context, Intent intent, int msgId) { try { - if (Intent.ACTION_CALL.equals(intent.getAction())) { + if (Intent.ACTION_CALL.equals(intent.getAction()) && context instanceof Activity) { // All dialer-initiated calls should pass the touch point to the InCallUI Point touchPoint = TouchPointManager.getInstance().getPoint(); if (touchPoint.x != 0 || touchPoint.y != 0) { |