diff options
author | Andrew Lee <anwlee@google.com> | 2015-05-05 22:14:44 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-05 22:14:51 +0000 |
commit | 5e6431ec9df6cb62cab970c0b46618be3570c2f7 (patch) | |
tree | 7d6a4c66b1b14669b530bd9f3b82043a35e7d9d7 /src | |
parent | 71532b2fcee195bcb1574b939173e134242a313b (diff) | |
parent | fdfeaaf4e5ae0277a03529e501eb1c562f769851 (diff) |
Merge "Change FAB icon and behavior for contacts tab." into mnc-dev
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 48 | ||||
-rw-r--r-- | src/com/android/dialer/dialpad/DialpadFragment.java | 2 | ||||
-rw-r--r-- | src/com/android/dialer/list/ListsFragment.java | 11 |
3 files changed, 39 insertions, 22 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index b97dc437d..5c7dd6f19 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -198,11 +198,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; @@ -580,7 +575,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); } @@ -614,14 +611,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 @@ -1096,6 +1086,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, @@ -1188,22 +1189,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); } @@ -1243,7 +1248,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/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); |