From a1fd281d4989d910ca6b2f78d2321a4792eca36f Mon Sep 17 00:00:00 2001 From: Nancy Chen Date: Wed, 18 Nov 2015 18:13:07 -0800 Subject: Handle backwards compatible permission lookup and requests (1/3). requestPermissions is not available to the Fragments class and checkSelfPermission is not available to the Context class in API < 23. Use other backwards compatible methods to implement the behavior. Bug: 25776171 Change-Id: I6cb221236f28b319f618d2cf32a9f503a6f4e6e0 --- src/com/android/dialer/calllog/CallLogFragment.java | 7 +++++-- src/com/android/dialer/list/AllContactsFragment.java | 7 +++++-- src/com/android/dialer/list/RegularSearchFragment.java | 7 +++++-- src/com/android/dialer/list/SmartDialSearchFragment.java | 7 +++++-- src/com/android/dialer/list/SpeedDialFragment.java | 7 +++++-- src/com/android/dialer/util/TelecomUtil.java | 2 +- 6 files changed, 26 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/com/android/dialer/calllog/CallLogFragment.java b/src/com/android/dialer/calllog/CallLogFragment.java index ab5bd435e..fa6deaf55 100644 --- a/src/com/android/dialer/calllog/CallLogFragment.java +++ b/src/com/android/dialer/calllog/CallLogFragment.java @@ -33,6 +33,7 @@ import android.provider.CallLog; import android.provider.CallLog.Calls; import android.provider.ContactsContract; import android.provider.VoicemailContract.Status; +import android.support.v13.app.FragmentCompat; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; @@ -55,7 +56,8 @@ import com.android.dialerbind.ObjectFactory; * (all, missed or voicemails), specify it in the constructor. */ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Listener, - CallLogAdapter.CallFetcher, OnEmptyViewActionButtonClickedListener { + CallLogAdapter.CallFetcher, OnEmptyViewActionButtonClickedListener, + FragmentCompat.OnRequestPermissionsResultCallback { private static final String TAG = "CallLogFragment"; /** @@ -513,7 +515,8 @@ public class CallLogFragment extends Fragment implements CallLogQueryHandler.Lis } if (!PermissionsUtil.hasPermission(activity, READ_CALL_LOG)) { - requestPermissions(new String[] {READ_CALL_LOG}, READ_CALL_LOG_PERMISSION_REQUEST_CODE); + FragmentCompat.requestPermissions(this, new String[] {READ_CALL_LOG}, + READ_CALL_LOG_PERMISSION_REQUEST_CODE); } else if (!mIsCallLogActivity) { // Show dialpad if we are not in the call log activity. ((HostInterface) activity).showDialpad(); diff --git a/src/com/android/dialer/list/AllContactsFragment.java b/src/com/android/dialer/list/AllContactsFragment.java index 0f31ff88f..6ed1fbbbd 100644 --- a/src/com/android/dialer/list/AllContactsFragment.java +++ b/src/com/android/dialer/list/AllContactsFragment.java @@ -28,6 +28,7 @@ import android.database.Cursor; import android.net.Uri; import android.provider.ContactsContract.CommonDataKinds.Phone; import android.provider.ContactsContract.QuickContact; +import android.support.v13.app.FragmentCompat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -49,7 +50,8 @@ import com.android.dialer.widget.EmptyContentView.OnEmptyViewActionButtonClicked * Fragments to show all contacts with phone numbers. */ public class AllContactsFragment extends ContactEntryListFragment - implements OnEmptyViewActionButtonClickedListener { + implements OnEmptyViewActionButtonClickedListener, + FragmentCompat.OnRequestPermissionsResultCallback { private static final int READ_CONTACTS_PERMISSION_REQUEST_CODE = 1; @@ -168,7 +170,8 @@ public class AllContactsFragment extends ContactEntryListFragment