diff options
author | Yorke Lee <yorkelee@google.com> | 2013-07-26 17:05:04 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2013-07-29 08:36:33 -0700 |
commit | 80a05ed48a899da3f54792bb12e62200a5683f99 (patch) | |
tree | 8757ec45ac42fd1f45ae764668f35aa9e65694cc | |
parent | fca42086a510778d951fe1d5d80f35223f9d7a0d (diff) |
Allow Dialer to respond to dial and view call log intents.
Change-Id: I5a67cf690be172e5d55a426f61e53e6b1bb7a935
-rw-r--r-- | AndroidManifest.xml | 8 | ||||
-rw-r--r-- | src/com/android/dialer/NewDialtactsActivity.java | 78 | ||||
-rw-r--r-- | src/com/android/dialer/dialpad/NewDialpadFragment.java | 7 |
3 files changed, 41 insertions, 52 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index c576cd736..8c9726515 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -183,6 +183,14 @@ android:theme="@style/NewDialtactsTheme" android:screenOrientation="portrait" android:icon="@mipmap/ic_launcher_phone"> + <!-- + <intent-filter> + <action android:name="android.intent.action.VIEW" /> + <category android:name="android.intent.category.DEFAULT" /> + <category android:name="android.intent.category.BROWSABLE" /> + <data android:mimeType="vnd.android.cursor.dir/calls" /> + </intent-filter> + --> </activity> <activity android:name="com.android.dialer.CallDetailActivity" diff --git a/src/com/android/dialer/NewDialtactsActivity.java b/src/com/android/dialer/NewDialtactsActivity.java index 4b9a82d44..0229c6bfe 100644 --- a/src/com/android/dialer/NewDialtactsActivity.java +++ b/src/com/android/dialer/NewDialtactsActivity.java @@ -38,6 +38,7 @@ import android.provider.ContactsContract; import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.Intents.UI; import android.provider.Settings; +import android.telephony.TelephonyManager; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -107,14 +108,6 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie */ private static final String ACTION_TOUCH_DIALER = "com.android.phone.action.TOUCH_DIALER"; - private SharedPreferences mPrefs; - - public static final String SHARED_PREFS_NAME = "com.android.dialer_preferences"; - - /** Last manually selected tab index */ - private static final String PREF_LAST_MANUALLY_SELECTED_TAB = - "DialtactsActivity_last_manually_selected_tab"; - private static final int SUBACTIVITY_ACCOUNT_FILTER = 1; private String mFilterText; @@ -156,12 +149,6 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie private EditText mSearchView; /** - * The index of the Fragment (or, the tab) that has last been manually selected. - * This value does not keep track of programmatically set Tabs (e.g. Call Log after a Call) - */ - private int mLastManuallySelectedFragment; - - /** * Listener used when one of phone numbers in search UI is selected. This will initiate a * phone call using the phone number. */ @@ -257,16 +244,7 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie mBottomPaddingView = findViewById(R.id.dialtacts_bottom_padding); prepareSearchView(); - // Load the last manually loaded tab - mPrefs = this.getSharedPreferences(SHARED_PREFS_NAME, Context.MODE_PRIVATE); - - /* - * TODO krelease : Remember which fragment was last displayed, and then redisplay it as - * necessary. mLastManuallySelectedFragment = mPrefs.getInt(PREF_LAST_MANUALLY_SELECTED_TAB, - * PREF_LAST_MANUALLY_SELECTED_TAB_DEFAULT); if (mLastManuallySelectedFragment >= - * TAB_INDEX_COUNT) { // Stored value may have exceeded the number of current tabs. Reset - * it. mLastManuallySelectedFragment = PREF_LAST_MANUALLY_SELECTED_TAB_DEFAULT; } - */ + displayFragment(intent); if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction()) && savedInstanceState == null) { @@ -346,10 +324,13 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie break; } case R.id.dialpad_button: - showDialpadFragment(); + showDialpadFragment(true); break; case R.id.call_history_on_dialpad_button: case R.id.call_history_button: + // TODO krelease: This should start an intent with content type + // CallLog.Calls.CONTENT_TYPE, once the intent filters for the call log activity + // is enabled final Intent intent = new Intent(this, NewCallLogActivity.class); startActivity(intent); break; @@ -366,16 +347,20 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie } } - private void showDialpadFragment() { + private void showDialpadFragment(boolean animate) { final FragmentTransaction ft = getFragmentManager().beginTransaction(); - ft.setCustomAnimations(R.anim.slide_in, 0); + if (animate) { + ft.setCustomAnimations(R.anim.slide_in, 0); + } ft.show(mDialpadFragment); ft.commit(); } - private void hideDialpadFragment() { + private void hideDialpadFragment(boolean animate) { final FragmentTransaction ft = getFragmentManager().beginTransaction(); - ft.setCustomAnimations(0, R.anim.slide_out); + if (animate) { + ft.setCustomAnimations(0, R.anim.slide_out); + } ft.hide(mDialpadFragment); ft.commit(); } @@ -400,7 +385,7 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie private void hideDialpadFragmentIfNecessary() { if (mDialpadFragment.isVisible()) { - hideDialpadFragment(); + hideDialpadFragment(true); } } @@ -481,19 +466,6 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie callhistoryButton.setOnClickListener(this); } - @Override - protected void onPause() { - super.onPause(); - mPrefs.edit().putInt(PREF_LAST_MANUALLY_SELECTED_TAB, mLastManuallySelectedFragment) - .apply(); - requestBackup(); - } - - private void requestBackup() { - final BackupManager bm = new BackupManager(this); - bm.dataChanged(); - } - private void fixIntent(Intent intent) { // This should be cleaned up: the call key used to send an Intent // that just said to go to the recent calls list. It now sends this @@ -547,6 +519,14 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie finish(); return; } + + if ((mDialpadFragment != null && phoneIsInUse()) + || isDialIntent(intent)) { + mDialpadFragment.setStartedFromNewIntent(true); + // TODO krelease: This should use showDialpadFragment(false) to avoid animating + // the dialpad in. Need to fix the onPreDrawListener in NewDialpadFragment first. + showDialpadFragment(true); + } } @Override @@ -555,9 +535,7 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie fixIntent(newIntent); displayFragment(newIntent); final String action = newIntent.getAction(); - if (UI.FILTER_CONTACTS_ACTION.equals(action)) { - setupFilterText(newIntent); - } + if (mInSearchUi || (mRegularSearchFragment != null && mRegularSearchFragment.isVisible())) { exitSearchUi(); } @@ -724,7 +702,7 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie @Override public void onBackPressed() { if (mDialpadFragment.isVisible()) { - hideDialpadFragment(); + hideDialpadFragment(true); } else if (mInSearchUi) { mSearchView.setText(null); } else if (isTaskRoot()) { @@ -765,5 +743,9 @@ public class NewDialtactsActivity extends TransactionSafeActivity implements Vie setupFakeActionBarItemsForDialpadFragment(); } - + private boolean phoneIsInUse() { + final TelephonyManager tm = (TelephonyManager) getSystemService( + Context.TELEPHONY_SERVICE); + return tm.getCallState() != TelephonyManager.CALL_STATE_IDLE; + } } diff --git a/src/com/android/dialer/dialpad/NewDialpadFragment.java b/src/com/android/dialer/dialpad/NewDialpadFragment.java index d7bc3f9b4..96b1039c7 100644 --- a/src/com/android/dialer/dialpad/NewDialpadFragment.java +++ b/src/com/android/dialer/dialpad/NewDialpadFragment.java @@ -347,8 +347,8 @@ public class NewDialpadFragment extends Fragment mFragmentView = fragmentView; mFragmentView.buildLayer(); - // TODO krelease: Get rid of this ugly hack which is to prevent the first frame of the - // animation from drawing the fragment at translationY = 0 + // Set the translationY to the correct value before it is drawn for the first frame + // to prevent flicker when the animation first starts final ViewTreeObserver vto = mFragmentView.getViewTreeObserver(); final OnPreDrawListener preDrawListener = new OnPreDrawListener() { @@ -510,11 +510,10 @@ public class NewDialpadFragment extends Fragment */ private void configureScreenFromIntent(Activity parent) { // If we were not invoked with a DIAL intent, - if (!(parent instanceof DialtactsActivity)) { + if (!(parent instanceof NewDialtactsActivity)) { setStartedFromNewIntent(false); return; } - // See if we were invoked with a DIAL intent. If we were, fill in the appropriate // digits in the dialer field. Intent intent = parent.getIntent(); |