diff options
author | keyboardr <keyboardr@google.com> | 2017-06-26 15:16:26 -0700 |
---|---|---|
committer | Brandon Maxwell <maxwelb@google.com> | 2017-06-30 14:33:17 -0700 |
commit | a60579e8f6abff88814d940f9da51e22788d6007 (patch) | |
tree | 188bdb9ec664a2d572efef0f87841958fa966c9d /java/com/android/dialer/app/filterednumber | |
parent | 4b499669dde98f485199fd38883ad0dc26d1f0f3 (diff) |
All Fragments are now support library Fragments.
Switch a bunch of imports to support library Fragments (and Loaders) instead of framework Fragments (and Loaders). This was needed to use FragmentManager.isStateSaved() instead of manually tracking that state. This should reduce errors around committing after state is saved.
Also adds METADATA presubmit to prevent new usages of framework Fragments or Loaders.
Bug: 38241305
Test: Covered by existing tests.
PiperOrigin-RevId: 160202511
Change-Id: I5dc0b467da984ca571e49b4dfa0deea44eb372b2
Diffstat (limited to 'java/com/android/dialer/app/filterednumber')
6 files changed, 28 insertions, 29 deletions
diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java index dbd4e868c..503b4c4ca 100644 --- a/java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java +++ b/java/com/android/dialer/app/filterednumber/BlockedNumbersAdapter.java @@ -15,9 +15,9 @@ */ package com.android.dialer.app.filterednumber; -import android.app.FragmentManager; import android.content.Context; import android.database.Cursor; +import android.support.v4.app.FragmentManager; import android.telephony.PhoneNumberUtils; import android.view.View; import com.android.contacts.common.ContactPhotoManager; diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java index f53a45840..cb56db842 100644 --- a/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java +++ b/java/com/android/dialer/app/filterednumber/BlockedNumbersFragment.java @@ -15,15 +15,15 @@ */ package com.android.dialer.app.filterednumber; -import android.app.ListFragment; -import android.app.LoaderManager; import android.content.Context; -import android.content.CursorLoader; -import android.content.Loader; import android.database.Cursor; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.support.v4.app.ActivityCompat; +import android.support.v4.app.ListFragment; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; @@ -71,8 +71,8 @@ public class BlockedNumbersFragment extends ListFragment (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); getListView().addHeaderView(inflater.inflate(R.layout.blocked_number_header, null)); getListView().addFooterView(inflater.inflate(R.layout.blocked_number_footer, null)); - //replace the icon for add number with LetterTileDrawable(), so it will have identical style - ImageView addNumberIcon = (ImageView) getActivity().findViewById(R.id.add_number_icon); + // replace the icon for add number with LetterTileDrawable(), so it will have identical style + ImageView addNumberIcon = getActivity().findViewById(R.id.add_number_icon); LetterTileDrawable drawable = new LetterTileDrawable(getResources()); drawable.setLetter(ADD_BLOCKED_NUMBER_ICON_LETTER); drawable.setColor( @@ -83,11 +83,11 @@ public class BlockedNumbersFragment extends ListFragment if (mAdapter == null) { mAdapter = BlockedNumbersAdapter.newBlockedNumbersAdapter( - getContext(), getActivity().getFragmentManager()); + getContext(), getActivity().getSupportFragmentManager()); } setListAdapter(mAdapter); - blockedNumbersText = (TextView) getListView().findViewById(R.id.blocked_number_text_view); + blockedNumbersText = getListView().findViewById(R.id.blocked_number_text_view); migratePromoView = getListView().findViewById(R.id.migrate_promo); getListView().findViewById(R.id.migrate_promo_allow_button).setOnClickListener(this); mImportSettings = getListView().findViewById(R.id.import_settings); @@ -98,7 +98,7 @@ public class BlockedNumbersFragment extends ListFragment getListView().findViewById(R.id.view_numbers_button).setOnClickListener(this); getListView().findViewById(R.id.add_number_linear_layout).setOnClickListener(this); - footerText = (TextView) getActivity().findViewById(R.id.blocked_number_footer_textview); + footerText = getActivity().findViewById(R.id.blocked_number_footer_textview); mVoicemailEnabledChecker = new VisualVoicemailEnabledChecker(getContext(), this); mVoicemailEnabledChecker.asyncUpdate(); updateActiveVoicemailProvider(); diff --git a/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java b/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java index 9310fcb22..b944e6364 100644 --- a/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java +++ b/java/com/android/dialer/app/filterednumber/BlockedNumbersSettingsActivity.java @@ -46,12 +46,12 @@ public class BlockedNumbersSettingsActivity extends AppCompatActivity public void showManagementUi() { BlockedNumbersFragment fragment = (BlockedNumbersFragment) - getFragmentManager().findFragmentByTag(TAG_BLOCKED_MANAGEMENT_FRAGMENT); + getSupportFragmentManager().findFragmentByTag(TAG_BLOCKED_MANAGEMENT_FRAGMENT); if (fragment == null) { fragment = new BlockedNumbersFragment(); } - getFragmentManager() + getSupportFragmentManager() .beginTransaction() .replace(R.id.blocked_numbers_activity_container, fragment, TAG_BLOCKED_MANAGEMENT_FRAGMENT) .commit(); @@ -63,7 +63,7 @@ public class BlockedNumbersSettingsActivity extends AppCompatActivity public void showSearchUi() { BlockedListSearchFragment fragment = (BlockedListSearchFragment) - getFragmentManager().findFragmentByTag(TAG_BLOCKED_SEARCH_FRAGMENT); + getSupportFragmentManager().findFragmentByTag(TAG_BLOCKED_SEARCH_FRAGMENT); if (fragment == null) { fragment = new BlockedListSearchFragment(); fragment.setHasOptionsMenu(false); @@ -71,7 +71,7 @@ public class BlockedNumbersSettingsActivity extends AppCompatActivity fragment.setDirectorySearchEnabled(false); } - getFragmentManager() + getSupportFragmentManager() .beginTransaction() .replace(R.id.blocked_numbers_activity_container, fragment, TAG_BLOCKED_SEARCH_FRAGMENT) .addToBackStack(null) @@ -87,12 +87,12 @@ public class BlockedNumbersSettingsActivity extends AppCompatActivity public void showNumbersToImportPreviewUi() { ViewNumbersToImportFragment fragment = (ViewNumbersToImportFragment) - getFragmentManager().findFragmentByTag(TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT); + getSupportFragmentManager().findFragmentByTag(TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT); if (fragment == null) { fragment = new ViewNumbersToImportFragment(); } - getFragmentManager() + getSupportFragmentManager() .beginTransaction() .replace( R.id.blocked_numbers_activity_container, fragment, TAG_VIEW_NUMBERS_TO_IMPORT_FRAGMENT) @@ -112,8 +112,8 @@ public class BlockedNumbersSettingsActivity extends AppCompatActivity @Override public void onBackPressed() { // TODO: Achieve back navigation without overriding onBackPressed. - if (getFragmentManager().getBackStackEntryCount() > 0) { - getFragmentManager().popBackStack(); + if (getSupportFragmentManager().getBackStackEntryCount() > 0) { + getSupportFragmentManager().popBackStack(); } else { super.onBackPressed(); } diff --git a/java/com/android/dialer/app/filterednumber/NumbersAdapter.java b/java/com/android/dialer/app/filterednumber/NumbersAdapter.java index d98395ec7..800ea2314 100644 --- a/java/com/android/dialer/app/filterednumber/NumbersAdapter.java +++ b/java/com/android/dialer/app/filterednumber/NumbersAdapter.java @@ -15,10 +15,10 @@ */ package com.android.dialer.app.filterednumber; -import android.app.FragmentManager; import android.content.Context; import android.provider.ContactsContract; import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.support.v4.app.FragmentManager; import android.text.BidiFormatter; import android.text.TextDirectionHeuristics; import android.text.TextUtils; @@ -57,10 +57,9 @@ public class NumbersAdapter extends SimpleCursorAdapter { } public void updateView(View view, String number, String countryIso) { - final TextView callerName = (TextView) view.findViewById(R.id.caller_name); - final TextView callerNumber = (TextView) view.findViewById(R.id.caller_number); - final QuickContactBadge quickContactBadge = - (QuickContactBadge) view.findViewById(R.id.quick_contact_photo); + final TextView callerName = view.findViewById(R.id.caller_name); + final TextView callerNumber = view.findViewById(R.id.caller_number); + final QuickContactBadge quickContactBadge = view.findViewById(R.id.quick_contact_photo); quickContactBadge.setOverlay(null); if (CompatUtils.hasPrioritizedMimeType()) { quickContactBadge.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE); diff --git a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java b/java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java index 313efb4d7..45ea29ed3 100644 --- a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java +++ b/java/com/android/dialer/app/filterednumber/ViewNumbersToImportAdapter.java @@ -15,9 +15,9 @@ */ package com.android.dialer.app.filterednumber; -import android.app.FragmentManager; import android.content.Context; import android.database.Cursor; +import android.support.v4.app.FragmentManager; import android.view.View; import com.android.contacts.common.ContactPhotoManager; import com.android.dialer.app.R; diff --git a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java b/java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java index d45f61ed7..6eca03b29 100644 --- a/java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java +++ b/java/com/android/dialer/app/filterednumber/ViewNumbersToImportFragment.java @@ -15,14 +15,14 @@ */ package com.android.dialer.app.filterednumber; -import android.app.ListFragment; -import android.app.LoaderManager; import android.content.Context; -import android.content.CursorLoader; -import android.content.Loader; import android.database.Cursor; import android.os.Bundle; import android.provider.ContactsContract.CommonDataKinds.Phone; +import android.support.v4.app.ListFragment; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.view.LayoutInflater; @@ -49,7 +49,7 @@ public class ViewNumbersToImportFragment extends ListFragment if (mAdapter == null) { mAdapter = ViewNumbersToImportAdapter.newViewNumbersToImportAdapter( - getContext(), getActivity().getFragmentManager()); + getContext(), getActivity().getSupportFragmentManager()); } setListAdapter(mAdapter); } |