Search in sources :

Example 1 with UIManager

use of com.facebook.accountkit.ui.UIManager 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;
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) UIManager(com.facebook.accountkit.ui.UIManager) ThemeUIManager(com.facebook.accountkit.ui.ThemeUIManager) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) ThemeUIManager(com.facebook.accountkit.ui.ThemeUIManager) Switch(android.widget.Switch) AccountKitConfiguration(com.facebook.accountkit.ui.AccountKitConfiguration) LoginType(com.facebook.accountkit.ui.LoginType) SkinManager(com.facebook.accountkit.ui.SkinManager)

Aggregations

BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Switch (android.widget.Switch)1 AccountKitConfiguration (com.facebook.accountkit.ui.AccountKitConfiguration)1 LoginType (com.facebook.accountkit.ui.LoginType)1 SkinManager (com.facebook.accountkit.ui.SkinManager)1 ThemeUIManager (com.facebook.accountkit.ui.ThemeUIManager)1 UIManager (com.facebook.accountkit.ui.UIManager)1