alhazmy13_____MediaPicker_____ImageActivity
if (ActivityCompat.checkSelfPermission(ImageActivity.this, permission) != PackageManager.PERMISSION_GRANTED) {
permissionsList.add(permission);
// Check for Rationale Option
return ActivityCompat.shouldShowRequestPermissionRationale(ImageActivity.this, permission);
}
android_____platform_packages_apps_contacts_____QuickContactActivity
protected void onCreate(Bundle savedInstanceState) {
Trace.beginSection("onCreate()");
super.onCreate(savedInstanceState);
if (RequestPermissionsActivity.startPermissionActivityIfNeeded(this)) {
return;
}
mIsRecreatedInstance = savedInstanceState != null;
if (mIsRecreatedInstance) {
mPreviousContactId = savedInstanceState.getLong(KEY_PREVIOUS_CONTACT_ID);
// Phone specific options menus
mSendToVoicemailState = savedInstanceState.getBoolean(KEY_SEND_TO_VOICE_MAIL_STATE);
mArePhoneOptionsChangable =
savedInstanceState.getBoolean(KEY_ARE_PHONE_OPTIONS_CHANGEABLE);
mCustomRingtone = savedInstanceState.getString(KEY_CUSTOM_RINGTONE);
}
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setIndeterminate(true);
mProgressDialog.setCancelable(false);
mListener = new SaveServiceListener();
final IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(ContactSaveService.BROADCAST_LINK_COMPLETE);
intentFilter.addAction(ContactSaveService.BROADCAST_UNLINK_COMPLETE);
LocalBroadcastManager.getInstance(this).registerReceiver(mListener,
intentFilter);
mShouldLog = true;
// There're 3 states for each permission:
// 1. App doesn't have permission, not asked user yet.
// 2. App doesn't have permission, user denied it previously.
// 3. App has permission.
// Permission explanation card is displayed only for case 1.
final boolean hasTelephonyFeature =
getPackageManager().hasSystemFeature(PackageManager.FEATURE_TELEPHONY);
final boolean hasCalendarPermission = PermissionsUtil.hasPermission(
this, Manifest.permission.READ_CALENDAR);
final boolean hasSMSPermission = hasTelephonyFeature
&& PermissionsUtil.hasPermission(this, Manifest.permission.READ_SMS);
final boolean wasCalendarPermissionDenied =
ActivityCompat.shouldShowRequestPermissionRationale(
this, Manifest.permission.READ_CALENDAR);
final boolean wasSMSPermissionDenied =
hasTelephonyFeature && ActivityCompat.shouldShowRequestPermissionRationale(
this, Manifest.permission.READ_SMS);
final boolean shouldDisplayCalendarMessage =
!hasCalendarPermission && !wasCalendarPermissionDenied;
final boolean shouldDisplaySMSMessage =
hasTelephonyFeature && !hasSMSPermission && !wasSMSPermissionDenied;
mShouldShowPermissionExplanation = shouldDisplayCalendarMessage || shouldDisplaySMSMessage;
if (shouldDisplayCalendarMessage && shouldDisplaySMSMessage) {
mPermissionExplanationCardSubHeader =
getString(R.string.permission_explanation_subheader_calendar_and_SMS);
} else if (shouldDisplayCalendarMessage) {
mPermissionExplanationCardSubHeader =
getString(R.string.permission_explanation_subheader_calendar);
} else if (shouldDisplaySMSMessage) {
mPermissionExplanationCardSubHeader =
getString(R.string.permission_explanation_subheader_SMS);
}
final int previousScreenType = getIntent().getIntExtra
(EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.UNKNOWN);
Logger.logScreenView(this, ScreenType.QUICK_CONTACT, previousScreenType);
mReferrer = getCallingPackage();
if (mReferrer == null && CompatUtils.isLollipopMr1Compatible() && getReferrer() != null) {
mReferrer = getReferrer().getAuthority();
}
mContactType = ContactType.UNKNOWN_TYPE;
if (CompatUtils.isLollipopCompatible()) {
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
processIntent(getIntent());
// Show QuickContact in front of soft input
getWindow().setFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
setContentView(R.layout.quickcontact_activity);
mMaterialColorMapUtils = new MaterialColorMapUtils(getResources());
mScroller = (MultiShrinkScroller) findViewById(R.id.multiscroller);
mContactCard = (ExpandingEntryCardView) findViewById(R.id.communication_card);
mNoContactDetailsCard = (ExpandingEntryCardView) findViewById(R.id.no_contact_data_card);
mRecentCard = (ExpandingEntryCardView) findViewById(R.id.recent_card);
mAboutCard = (ExpandingEntryCardView) findViewById(R.id.about_card);
mPermissionExplanationCard =
(ExpandingEntryCardView) findViewById(R.id.permission_explanation_card);
mPermissionExplanationCard.setOnClickListener(mEntryClickHandler);
mNoContactDetailsCard.setOnClickListener(mEntryClickHandler);
mContactCard.setOnClickListener(mEntryClickHandler);
mContactCard.setOnCreateContextMenuListener(mEntryContextMenuListener);
mRecentCard.setOnClickListener(mEntryClickHandler);
mRecentCard.setTitle(getResources().getString(R.string.recent_card_title));
mAboutCard.setOnClickListener(mEntryClickHandler);
mAboutCard.setOnCreateContextMenuListener(mEntryContextMenuListener);
mPhotoView = (QuickContactImageView) findViewById(R.id.photo);
final View transparentView = findViewById(R.id.transparent_view);
if (mScroller != null) {
transparentView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mScroller.scrollOffBottom();
}
});
}
// Allow a shadow to be shown under the toolbar.
ViewUtil.addRectangularOutlineProvider(findViewById(R.id.toolbar_parent), getResources());
final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setActionBar(toolbar);
getActionBar().setTitle(null);
// Put a TextView with a known resource id into the ActionBar. This allows us to easily
// find the correct TextView location & size later.
toolbar.addView(getLayoutInflater().inflate(R.layout.quickcontact_title_placeholder, null));
mHasAlreadyBeenOpened = savedInstanceState != null;
mIsEntranceAnimationFinished = mHasAlreadyBeenOpened;
mWindowScrim = new ColorDrawable(SCRIM_COLOR);
mWindowScrim.setAlpha(0);
getWindow().setBackgroundDrawable(mWindowScrim);
mScroller.initialize(mMultiShrinkScrollerListener, mExtraMode == MODE_FULLY_EXPANDED,
/* maximumHeaderTextSize */ -1,
/* shouldUpdateNameViewHeight */ true);
// mScroller needs to perform asynchronous measurements after initalize(), therefore
// we can't mark this as GONE.
mScroller.setVisibility(View.INVISIBLE);
setHeaderNameText(R.string.missing_name);
SchedulingUtils.doOnPreDraw(mScroller, /* drawNextFrame = */ true,
new Runnable() {
@Override
public void run() {
if (!mHasAlreadyBeenOpened) {
// The initial scrim opacity must match the scrim opacity that would be
// achieved by scrolling to the starting position.
final float alphaRatio = mExtraMode == MODE_FULLY_EXPANDED ?
1 : mScroller.getStartingTransparentHeightRatio();
final int duration = getResources().getInteger(
android.R.integer.config_shortAnimTime);
final int desiredAlpha = (int) (0xFF * alphaRatio);
ObjectAnimator o = ObjectAnimator.ofInt(mWindowScrim, "alpha", 0,
desiredAlpha).setDuration(duration);
o.start();
}
}
});
if (savedInstanceState != null) {
final int color = savedInstanceState.getInt(KEY_THEME_COLOR, 0);
SchedulingUtils.doOnPreDraw(mScroller, /* drawNextFrame = */ false,
new Runnable() {
@Override
public void run() {
// Need to wait for the pre draw before setting the initial scroll
// value. Prior to pre draw all scroll values are invalid.
if (mHasAlreadyBeenOpened) {
mScroller.setVisibility(View.VISIBLE);
mScroller.setScroll(mScroller.getScrollNeededToBeFullScreen());
}
// Need to wait for pre draw for setting the theme color. Setting the
// header tint before the MultiShrinkScroller has been measured will
// cause incorrect tinting calculations.
if (color != 0) {
setThemeColor(mMaterialColorMapUtils
.calculatePrimaryAndSecondaryColor(color));
}
}
});
}
Trace.endSection();
}
00ec454_____Ask_____AskActivity
if (ActivityCompat.shouldShowRequestPermissionRationale(this, permission)) {
showRationalsFor.add(permission);
// if multiple rational message corresponding to each permission
if (rationalMessages != null && rationalMessages.length == permissions.length) {
if (!neededRationalMessages.contains(rationalMessages[i])) {
neededRationalMessages.add(rationalMessages[i]);
}
}
}