From 35071c06d1587942f5a66c8f12e6247e8f904d26 Mon Sep 17 00:00:00 2001 From: Chiao Cheng Date: Mon, 15 Oct 2012 18:36:24 -0700 Subject: Removing contacts dependencies from CallDetailActivity. Bug: 6993891 Change-Id: I3ef54efc0ff92367ea4f9b68c1629a99d90ff22c --- src/com/android/dialer/CallDetailActivity.java | 23 +++++++++++---- src/com/android/dialer/DialtactsActivity.java | 4 +-- src/com/android/dialer/calllog/CallLogAdapter.java | 4 +-- .../android/dialer/calllog/CallLogFragment.java | 4 +-- src/com/android/dialer/calllog/ContactInfo.java | 2 +- .../android/dialer/calllog/ContactInfoHelper.java | 2 +- .../android/dialer/dialpad/DialpadFragment.java | 23 +++++++++++---- .../android/dialer/list/PhoneFavoriteFragment.java | 2 +- src/com/android/dialer/util/OrientationUtil.java | 34 ++++++++++++++++++++++ .../voicemail/VoicemailStatusHelperImpl.java | 2 +- 10 files changed, 78 insertions(+), 22 deletions(-) create mode 100644 src/com/android/dialer/util/OrientationUtil.java (limited to 'src') diff --git a/src/com/android/dialer/CallDetailActivity.java b/src/com/android/dialer/CallDetailActivity.java index cadbb6bc0..d716de0f3 100644 --- a/src/com/android/dialer/CallDetailActivity.java +++ b/src/com/android/dialer/CallDetailActivity.java @@ -51,11 +51,10 @@ import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; +import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.CallUtil; -import com.android.contacts.ContactPhotoManager; -import com.android.contacts.ContactsUtils; -import com.android.contacts.format.FormatUtils; import com.android.contacts.common.ClipboardUtils; +import com.android.contacts.common.GeoUtil; import com.android.dialer.BackScrollManager.ScrollableHeader; import com.android.dialer.calllog.CallDetailHistoryAdapter; import com.android.dialer.calllog.CallTypeHelper; @@ -80,6 +79,9 @@ import java.util.List; public class CallDetailActivity extends Activity implements ProximitySensorAware { private static final String TAG = "CallDetail"; + private static final char LEFT_TO_RIGHT_EMBEDDING = '\u202A'; + private static final char POP_DIRECTIONAL_FORMATTING = '\u202C'; + /** The time to wait before enabling the blank the screen due to the proximity sensor. */ private static final long PROXIMITY_BLANK_DELAY_MILLIS = 100; /** The time to wait before disabling the blank the screen due to the proximity sensor. */ @@ -271,10 +273,10 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware mMainActionView = (ImageView) findViewById(R.id.main_action); mMainActionPushLayerView = (ImageButton) findViewById(R.id.main_action_push_layer); mContactBackgroundView = (ImageView) findViewById(R.id.contact_background); - mDefaultCountryIso = ContactsUtils.getCurrentCountryIso(this); + mDefaultCountryIso = GeoUtil.getCurrentCountryIso(this); mContactPhotoManager = ContactPhotoManager.getInstance(this); mProximitySensorManager = new ProximitySensorManager(this, mProximitySensorListener); - mContactInfoHelper = new ContactInfoHelper(this, ContactsUtils.getCurrentCountryIso(this)); + mContactInfoHelper = new ContactInfoHelper(this, GeoUtil.getCurrentCountryIso(this)); configureActionBar(); optionallyHandleVoicemail(); if (getIntent().getBooleanExtra(EXTRA_FROM_NOTIFICATION, false)) { @@ -511,7 +513,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware ViewEntry entry = new ViewEntry( getString(R.string.menu_callNumber, - FormatUtils.forceLeftToRight(displayNumber)), + forceLeftToRight(displayNumber)), CallUtil.getCallIntent(mNumber), getString(R.string.description_call, nameOrNumber)); @@ -935,4 +937,13 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware mTargetView.setBackground(mOriginalViewBackground); } } + + /** Returns the given text, forced to be left-to-right. */ + private static CharSequence forceLeftToRight(CharSequence text) { + StringBuilder sb = new StringBuilder(); + sb.append(LEFT_TO_RIGHT_EMBEDDING); + sb.append(text); + sb.append(POP_DIRECTIONAL_FORMATTING); + return sb.toString(); + } } diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 230c8f48d..e66dd347f 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -57,7 +57,6 @@ import android.widget.SearchView.OnCloseListener; import android.widget.SearchView.OnQueryTextListener; import com.android.contacts.common.CallUtil; -import com.android.contacts.ContactsUtils; import com.android.contacts.activities.TransactionSafeActivity; import com.android.contacts.interactions.PhoneNumberInteraction; import com.android.contacts.list.ContactListFilterController; @@ -69,6 +68,7 @@ import com.android.contacts.util.AccountFilterUtil; import com.android.dialer.calllog.CallLogFragment; import com.android.dialer.dialpad.DialpadFragment; import com.android.dialer.list.PhoneFavoriteFragment; +import com.android.dialer.util.OrientationUtil; import com.android.internal.telephony.ITelephony; /** @@ -1018,7 +1018,7 @@ public class DialtactsActivity extends TransactionSafeActivity // This is when the user is looking at the dialer pad. In this case, the real // ActionBar is hidden and fake menu items are shown. // Except in landscape, in which case the real search menu item is shown. - searchMenuItem.setVisible(ContactsUtils.isLandscape(this)); + searchMenuItem.setVisible(OrientationUtil.isLandscape(this)); // If a permanent menu key is available, then we need to show the call settings item // so that the call settings item can be invoked by the permanent menu key. callSettingsMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey()); diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java index 1899bc59e..b0af99a38 100644 --- a/src/com/android/dialer/calllog/CallLogAdapter.java +++ b/src/com/android/dialer/calllog/CallLogAdapter.java @@ -32,8 +32,8 @@ import android.view.ViewGroup; import android.view.ViewTreeObserver; import com.android.common.widget.GroupingListAdapter; -import com.android.contacts.ContactPhotoManager; -import com.android.contacts.util.UriUtils; +import com.android.contacts.common.ContactPhotoManager; +import com.android.contacts.common.util.UriUtils; import com.android.dialer.PhoneCallDetails; import com.android.dialer.PhoneCallDetailsHelper; import com.android.dialer.R; diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index 60471549e..eb0b371b2 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -46,8 +46,8 @@ import android.widget.ListView; import android.widget.TextView; import com.android.common.io.MoreCloseables; -import com.android.contacts.ContactsUtils; import com.android.contacts.common.CallUtil; +import com.android.contacts.common.GeoUtil; import com.android.dialer.R; import com.android.dialer.util.EmptyLoader; import com.android.dialer.voicemail.VoicemailStatusHelper; @@ -220,7 +220,7 @@ public class CallLogFragment extends ListFragment @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - String currentCountryIso = ContactsUtils.getCurrentCountryIso(getActivity()); + String currentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); mAdapter = new CallLogAdapter(getActivity(), this, new ContactInfoHelper(getActivity(), currentCountryIso)); setListAdapter(mAdapter); diff --git a/src/com/android/dialer/calllog/ContactInfo.java b/src/com/android/dialer/calllog/ContactInfo.java index b48adef0f..e0a074d99 100644 --- a/src/com/android/dialer/calllog/ContactInfo.java +++ b/src/com/android/dialer/calllog/ContactInfo.java @@ -19,7 +19,7 @@ package com.android.dialer.calllog; import android.net.Uri; import android.text.TextUtils; -import com.android.contacts.util.UriUtils; +import com.android.contacts.common.util.UriUtils; /** * Information for a contact as needed by the Call Log. diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java index b6f0662f2..abe4a069d 100644 --- a/src/com/android/dialer/calllog/ContactInfoHelper.java +++ b/src/com/android/dialer/calllog/ContactInfoHelper.java @@ -24,7 +24,7 @@ import android.provider.ContactsContract.PhoneLookup; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; -import com.android.contacts.util.UriUtils; +import com.android.contacts.common.util.UriUtils; /** * Utility class to look up the contact information for a given number. diff --git a/src/com/android/dialer/dialpad/DialpadFragment.java b/src/com/android/dialer/dialpad/DialpadFragment.java index 014f188c6..776b2c938 100644 --- a/src/com/android/dialer/dialpad/DialpadFragment.java +++ b/src/com/android/dialer/dialpad/DialpadFragment.java @@ -67,13 +67,14 @@ import android.widget.ListView; import android.widget.PopupMenu; import android.widget.TextView; -import com.android.contacts.ContactsUtils; import com.android.contacts.common.CallUtil; +import com.android.contacts.common.GeoUtil; import com.android.contacts.util.PhoneNumberFormatter; import com.android.contacts.util.StopWatch; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; import com.android.dialer.SpecialCharSequenceMgr; +import com.android.dialer.util.OrientationUtil; import com.android.internal.telephony.ITelephony; import com.android.phone.common.CallLogAsync; import com.android.phone.common.HapticFeedback; @@ -200,6 +201,16 @@ public class DialpadFragment extends Fragment private static final String PREF_DIGITS_FILLED_BY_INTENT = "pref_digits_filled_by_intent"; + /** + * Return an Intent for launching voicemail screen. + */ + private static Intent getVoicemailIntent() { + final Intent intent = new Intent(Intent.ACTION_CALL_PRIVILEGED, + Uri.fromParts("voicemail", "", null)); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + return intent; + } + @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { mWasEmptyBeforeTextChange = TextUtils.isEmpty(s); @@ -241,7 +252,7 @@ public class DialpadFragment extends Fragment public void onCreate(Bundle state) { super.onCreate(state); - mCurrentCountryIso = ContactsUtils.getCurrentCountryIso(getActivity()); + mCurrentCountryIso = GeoUtil.getCurrentCountryIso(getActivity()); try { mHaptic.init(getActivity(), @@ -290,7 +301,7 @@ public class DialpadFragment extends Fragment mDialButtonContainer = fragmentView.findViewById(R.id.dialButtonContainer); // If in portrait, add padding to the dial button since we need space for the // search and menu/overflow buttons. - if (mDialButtonContainer != null && !ContactsUtils.isLandscape(this.getActivity())) { + if (mDialButtonContainer != null && !OrientationUtil.isLandscape(this.getActivity())) { mDialButtonContainer.setPadding( fakeMenuItemWidth, mDialButtonContainer.getPaddingTop(), fakeMenuItemWidth, mDialButtonContainer.getPaddingBottom()); @@ -625,7 +636,7 @@ public class DialpadFragment extends Fragment super.onCreateOptionsMenu(menu, inflater); // Landscape dialer uses the real actionbar menu, whereas portrait uses a fake one // that is created using constructPopupMenu() - if (ContactsUtils.isLandscape(this.getActivity()) || + if (OrientationUtil.isLandscape(this.getActivity()) || ViewConfiguration.get(getActivity()).hasPermanentMenuKey() && isLayoutReady() && mDialpadChooser != null) { inflater.inflate(R.menu.dialpad_options, menu); @@ -635,7 +646,7 @@ public class DialpadFragment extends Fragment @Override public void onPrepareOptionsMenu(Menu menu) { // Hardware menu key should be available and Views should already be ready. - if (ContactsUtils.isLandscape(this.getActivity()) || + if (OrientationUtil.isLandscape(this.getActivity()) || ViewConfiguration.get(getActivity()).hasPermanentMenuKey() && isLayoutReady() && mDialpadChooser != null) { setupMenuItems(menu); @@ -1000,7 +1011,7 @@ public class DialpadFragment extends Fragment } public void callVoicemail() { - startActivity(ContactsUtils.getVoicemailIntent()); + startActivity(getVoicemailIntent()); mClearDigitsOnStop = true; getActivity().finish(); } diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java index e7ef808d4..497647281 100644 --- a/src/com/android/dialer/list/PhoneFavoriteFragment.java +++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java @@ -45,7 +45,7 @@ import android.widget.FrameLayout; import android.widget.ListView; import android.widget.TextView; -import com.android.contacts.ContactPhotoManager; +import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.ContactTileLoaderFactory; import com.android.contacts.dialog.ClearFrequentsDialog; import com.android.contacts.interactions.ImportExportDialogFragment; diff --git a/src/com/android/dialer/util/OrientationUtil.java b/src/com/android/dialer/util/OrientationUtil.java new file mode 100644 index 000000000..2eb2af3ff --- /dev/null +++ b/src/com/android/dialer/util/OrientationUtil.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2012 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.util; + +import android.content.Context; +import android.content.res.Configuration; + +/** + * Static methods related to device orientation. + */ +public class OrientationUtil { + + /** + * @return if the context is in landscape orientation. + */ + public static boolean isLandscape(Context context) { + return context.getResources().getConfiguration().orientation + == Configuration.ORIENTATION_LANDSCAPE; + } +} diff --git a/src/com/android/dialer/voicemail/VoicemailStatusHelperImpl.java b/src/com/android/dialer/voicemail/VoicemailStatusHelperImpl.java index 284b8361e..ff1786862 100644 --- a/src/com/android/dialer/voicemail/VoicemailStatusHelperImpl.java +++ b/src/com/android/dialer/voicemail/VoicemailStatusHelperImpl.java @@ -28,7 +28,7 @@ import android.database.Cursor; import android.net.Uri; import android.provider.VoicemailContract.Status; -import com.android.contacts.util.UriUtils; +import com.android.contacts.common.util.UriUtils; import com.android.dialer.R; import java.util.ArrayList; -- cgit v1.2.3