diff options
author | Yorke Lee <yorkelee@google.com> | 2015-05-19 15:51:01 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2015-05-22 11:40:21 -0700 |
commit | c16ea5ad67bf454158b364dec2f26c95a879c350 (patch) | |
tree | d711fcd0374d8d82102f81ad74d6f94cd75729d8 /src/com/android/dialer/DialtactsActivity.java | |
parent | 5a194cd1f573d6c94a6b0e3e14cfabd69e42b856 (diff) |
Handle runtime permissions in Dialer
Conditionally disable the following features if the required
permissions are not available:
1) Display of all contacts
2) Display of speed dial
3) Caller ID in call log
4) Import/export contacts
5) Conversion of People.CONTENT_ITEM_TYPE and Phones.CONTENT_ITEM_TYPE
into a phone number (via DIAL intent)
6) UndemoteOutgoingCallReceiver
7) Contact Search
8) Contact lookup in call detail activity
9) Nearby places search
Bug: 20266292
Change-Id: I6d26902acb0eac407ae7bc18c11aa6ec57299506
Diffstat (limited to 'src/com/android/dialer/DialtactsActivity.java')
-rw-r--r-- | src/com/android/dialer/DialtactsActivity.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 56d5ad171..e240cf0aa 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -29,12 +29,10 @@ import android.content.res.Resources; import android.net.Uri; import android.os.Bundle; import android.os.Trace; -import android.provider.ContactsContract.Intents; import android.speech.RecognizerIntent; import android.support.v4.view.ViewPager; import android.telecom.PhoneAccount; import android.telecom.TelecomManager; -import android.telephony.TelephonyManager; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; @@ -63,6 +61,7 @@ import com.android.contacts.common.dialog.ClearFrequentsDialog; import com.android.contacts.common.interactions.ImportExportDialogFragment; import com.android.contacts.common.interactions.TouchPointManager; import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; +import com.android.contacts.common.util.PermissionsUtil; import com.android.contacts.common.widget.FloatingActionButtonController; import com.android.contacts.commonbind.analytics.AnalyticsUtil; import com.android.dialer.calllog.CallLogActivity; @@ -248,11 +247,16 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O @Override public void show() { + final boolean hasContactsPermission = + PermissionsUtil.hasContactsPermissions(DialtactsActivity.this); final Menu menu = getMenu(); final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents); clearFrequents.setVisible(mListsFragment != null && mListsFragment.getSpeedDialFragment() != null && - mListsFragment.getSpeedDialFragment().hasFrequents()); + mListsFragment.getSpeedDialFragment().hasFrequents() && hasContactsPermission); + + menu.findItem(R.id.menu_import_export).setVisible(hasContactsPermission); + menu.findItem(R.id.menu_add_contact).setVisible(hasContactsPermission); super.show(); } } @@ -359,6 +363,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O protected void onCreate(Bundle savedInstanceState) { Trace.beginSection(TAG + " onCreate"); super.onCreate(savedInstanceState); + mFirstLaunch = true; final Resources resources = getResources(); @@ -818,7 +823,6 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O protected OptionsPopupMenu buildOptionsMenu(View invoker) { final OptionsPopupMenu popupMenu = new OptionsPopupMenu(this, invoker); popupMenu.inflate(R.menu.dialtacts_options); - final Menu menu = popupMenu.getMenu(); popupMenu.setOnMenuItemClickListener(this); return popupMenu; } @@ -829,7 +833,9 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mSearchView.setText(mPendingSearchViewQuery); mPendingSearchViewQuery = null; } - mActionBarController.restoreActionBarOffset(); + if (mActionBarController != null) { + mActionBarController.restoreActionBarOffset(); + } return false; } |