use of com.facebook.accountkit.ui.AccountKitConfiguration in project facebook-android-sdk by facebook.
the class AccountKitLoginActivity method onLogin.
private void onLogin(final LoginType loginType) {
final Intent intent = new Intent(this, AccountKitActivity.class);
final AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = createAccountKitConfiguration(loginType);
final AccountKitConfiguration configuration = configurationBuilder.build();
intent.putExtra(AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION, configuration);
OnCompleteListener completeListener = new OnCompleteListener() {
@Override
public void onComplete() {
startActivityForResult(intent, FRAMEWORK_REQUEST_CODE);
}
};
switch(loginType) {
case EMAIL:
final OnCompleteListener getAccountsCompleteListener = completeListener;
completeListener = new OnCompleteListener() {
@Override
public void onComplete() {
requestPermissions(Manifest.permission.GET_ACCOUNTS, R.string.permissions_get_accounts_title, R.string.permissions_get_accounts_message, getAccountsCompleteListener);
}
};
break;
case PHONE:
if (configuration.isReceiveSMSEnabled()) {
final OnCompleteListener receiveSMSCompleteListener = completeListener;
completeListener = new OnCompleteListener() {
@Override
public void onComplete() {
requestPermissions(Manifest.permission.RECEIVE_SMS, R.string.permissions_receive_sms_title, R.string.permissions_receive_sms_message, receiveSMSCompleteListener);
}
};
}
if (configuration.isReadPhoneStateEnabled()) {
final OnCompleteListener readPhoneStateCompleteListener = completeListener;
completeListener = new OnCompleteListener() {
@Override
public void onComplete() {
requestPermissions(Manifest.permission.READ_PHONE_STATE, R.string.permissions_read_phone_state_title, R.string.permissions_read_phone_state_message, readPhoneStateCompleteListener);
}
};
}
break;
}
completeListener.onComplete();
}
Aggregations