use of com.facebook.accountkit.ui.LoginType in project facebook-android-sdk by facebook.
the class AccountKitLoginActivity method createAccountKitConfiguration.
private AccountKitConfiguration.AccountKitConfigurationBuilder createAccountKitConfiguration(final LoginType loginType) {
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = new AccountKitConfiguration.AccountKitConfigurationBuilder(loginType, getResponseType());
final Switch titleTypeSwitch = (Switch) findViewById(R.id.title_type_switch);
final Switch stateParamSwitch = (Switch) findViewById(R.id.state_param_switch);
final Switch facebookNotificationsSwitch = (Switch) findViewById(R.id.facebook_notification_switch);
final Switch useManualWhiteListBlacklist = (Switch) findViewById(R.id.whitelist_blacklist_switch);
final Switch readPhoneStateSwitch = (Switch) findViewById(R.id.read_phone_state_switch);
final Switch receiveSMS = (Switch) findViewById(R.id.receive_sms_switch);
if (titleTypeSwitch != null && titleTypeSwitch.isChecked()) {
configurationBuilder.setTitleType(AccountKitActivity.TitleType.APP_NAME);
}
final UIManager uiManager;
if (advancedUISwitch != null && advancedUISwitch.isChecked()) {
if (isReverbThemeSelected()) {
if (switchLoginTypeReceiver == null) {
switchLoginTypeReceiver = new BroadcastReceiver() {
@Override
public void onReceive(final Context context, final Intent intent) {
final String loginTypeString = intent.getStringExtra(ReverbUIManager.LOGIN_TYPE_EXTRA);
if (loginTypeString == null) {
return;
}
final LoginType loginType = LoginType.valueOf(loginTypeString);
onLogin(loginType);
}
};
LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(switchLoginTypeReceiver, new IntentFilter(ReverbUIManager.SWITCH_LOGIN_TYPE_EVENT));
}
uiManager = new ReverbUIManager(confirmButton, entryButton, loginType, textPosition, selectedThemeId);
} else {
uiManager = new AccountKitSampleAdvancedUIManager(confirmButton, entryButton, textPosition, loginType);
}
} else if (isSkinSelected()) {
@ColorInt final int primaryColor = ContextCompat.getColor(this, R.color.default_color);
if (getBackgroundImage() >= 0) {
uiManager = new SkinManager(loginType, skin, primaryColor, getBackgroundImage(), getSkinTintOption(), getSkinBackgroundTintIntensity());
} else {
uiManager = new SkinManager(loginType, skin, primaryColor);
}
} else {
uiManager = new ThemeUIManager(loginType, selectedThemeId);
}
configurationBuilder.setUIManager(uiManager);
if (stateParamSwitch != null && stateParamSwitch.isChecked()) {
initialStateParam = UUID.randomUUID().toString();
configurationBuilder.setInitialAuthState(initialStateParam);
}
if (facebookNotificationsSwitch != null && !facebookNotificationsSwitch.isChecked()) {
configurationBuilder.setFacebookNotificationsEnabled(false);
}
if (useManualWhiteListBlacklist != null && useManualWhiteListBlacklist.isChecked()) {
final String[] blackList = getResources().getStringArray(R.array.blacklistedSmsCountryCodes);
final String[] whiteList = getResources().getStringArray(R.array.whitelistedSmsCountryCodes);
configurationBuilder.setSMSBlacklist(blackList);
configurationBuilder.setSMSWhitelist(whiteList);
}
if (readPhoneStateSwitch != null && !(readPhoneStateSwitch.isChecked())) {
configurationBuilder.setReadPhoneStateEnabled(false);
}
if (receiveSMS != null && !receiveSMS.isChecked()) {
configurationBuilder.setReceiveSMS(false);
}
return configurationBuilder;
}
use of com.facebook.accountkit.ui.LoginType in project facebook-android-sdk by facebook.
the class ReverbUIManager method getFooterFragment.
@Override
@Nullable
public Fragment getFooterFragment(final LoginFlowState state) {
final int progress;
switch(state) {
case PHONE_NUMBER_INPUT:
case EMAIL_INPUT:
progress = 1;
break;
case SENDING_CODE:
case SENT_CODE:
progress = 2;
break;
case CODE_INPUT:
case EMAIL_VERIFY:
case CONFIRM_ACCOUNT_VERIFIED:
progress = 3;
break;
case VERIFYING_CODE:
case CONFIRM_INSTANT_VERIFICATION_LOGIN:
progress = 4;
break;
case VERIFIED:
progress = 5;
break;
case RESEND:
case ERROR:
case NONE:
default:
return null;
}
final ReverbFooterFragment fragment = new ReverbFooterFragment();
if (progress == 1) {
fragment.setLoginType(loginType);
fragment.setOnSwitchLoginTypeListener(new ReverbFooterFragment.OnSwitchLoginTypeListener() {
@Override
public void onSwitchLoginType() {
if (listener == null) {
return;
}
listener.onCancel();
final Activity activity = fragment.getActivity();
if (activity == null) {
return;
}
final Context applicationContext = activity.getApplicationContext();
final LoginType newLoginType;
switch(loginType) {
case EMAIL:
newLoginType = LoginType.PHONE;
break;
case PHONE:
newLoginType = LoginType.EMAIL;
break;
default:
return;
}
LocalBroadcastManager.getInstance(applicationContext).sendBroadcast(new Intent(SWITCH_LOGIN_TYPE_EVENT).putExtra(LOGIN_TYPE_EXTRA, newLoginType.name()));
}
});
}
if (getThemeId() == R.style.AppLoginTheme_Reverb_A) {
fragment.setProgressType(ReverbFooterFragment.ProgressType.BAR);
} else if (getThemeId() == R.style.AppLoginTheme_Reverb_B || getThemeId() == R.style.AppLoginTheme_Reverb_C) {
fragment.setProgressType(ReverbFooterFragment.ProgressType.DOTS);
}
fragment.setProgress(progress);
return fragment;
}
Aggregations