Search in sources :

Example 1 with ButtonType

use of com.facebook.accountkit.ui.ButtonType in project facebook-android-sdk by facebook.

the class AccountKitLoginActivity method setupAdvancedUIOptions.

private void setupAdvancedUIOptions() {
    advancedUISwitch = (Switch) findViewById(R.id.advanced_ui_switch);
    final View advancedUIOptionsLayout = findViewById(R.id.advanced_ui_options);
    final List<CharSequence> buttonNames = new ArrayList<>();
    buttonNames.add("Default");
    for (ButtonType buttonType : ButtonType.values()) {
        buttonNames.add(buttonType.name());
    }
    final ArrayAdapter<CharSequence> buttonNameAdapter = new ArrayAdapter<>(AccountKitLoginActivity.this, android.R.layout.simple_spinner_dropdown_item, buttonNames);
    advancedUISwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                if (isSkinSelected()) {
                    advancedUISwitch.setChecked(false);
                    Toast.makeText(AccountKitLoginActivity.this, R.string.skin_ui_required, Toast.LENGTH_LONG).show();
                    return;
                }
                advancedUIOptionsLayout.setVisibility(View.VISIBLE);
                final Spinner entryButtonSpinner = (Spinner) findViewById(R.id.entry_button_spinner);
                if (entryButtonSpinner != null) {
                    entryButtonSpinner.setAdapter(buttonNameAdapter);
                    entryButtonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
                            // First position is empty, so anything past that
                            if (position > 0) {
                                entryButton = ButtonType.valueOf(entryButtonSpinner.getSelectedItem().toString());
                            } else {
                                entryButton = null;
                            }
                        }

                        @Override
                        public void onNothingSelected(final AdapterView<?> parent) {
                            entryButton = null;
                        }
                    });
                }
                final Spinner confirmButtonSpinner = (Spinner) findViewById(R.id.confirm_button_spinner);
                if (confirmButtonSpinner != null) {
                    confirmButtonSpinner.setAdapter(buttonNameAdapter);
                    confirmButtonSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
                            // that
                            if (position > 0) {
                                confirmButton = ButtonType.valueOf(confirmButtonSpinner.getSelectedItem().toString());
                            } else {
                                confirmButton = null;
                            }
                        }

                        @Override
                        public void onNothingSelected(final AdapterView<?> parent) {
                            confirmButton = null;
                        }
                    });
                }
                final Spinner textPositionSpinner = (Spinner) findViewById(R.id.text_position_spinner);
                if (textPositionSpinner != null) {
                    final List<CharSequence> textPositions = new ArrayList<>();
                    textPositions.add("Default");
                    for (TextPosition textPosition : TextPosition.values()) {
                        textPositions.add(textPosition.name());
                    }
                    final ArrayAdapter<CharSequence> textPositionAdapter = new ArrayAdapter<>(AccountKitLoginActivity.this, android.R.layout.simple_spinner_dropdown_item, textPositions);
                    textPositionSpinner.setAdapter(textPositionAdapter);
                    textPositionSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(final AdapterView<?> parent, final View view, final int position, final long id) {
                            // that
                            if (position > 0) {
                                textPosition = TextPosition.valueOf(textPositionSpinner.getSelectedItem().toString());
                            } else {
                                textPosition = null;
                            }
                        }

                        @Override
                        public void onNothingSelected(final AdapterView<?> parent) {
                            textPosition = null;
                        }
                    });
                }
            } else if (isReverbThemeSelected()) {
                advancedUISwitch.setChecked(true);
                Toast.makeText(AccountKitLoginActivity.this, R.string.reverb_advanced_ui_required, Toast.LENGTH_LONG).show();
            } else {
                advancedUIOptionsLayout.setVisibility(View.GONE);
            }
        }
    });
}
Also used : Spinner(android.widget.Spinner) ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) TextPosition(com.facebook.accountkit.ui.TextPosition) AdapterView(android.widget.AdapterView) ArrayList(java.util.ArrayList) List(java.util.List) ButtonType(com.facebook.accountkit.ui.ButtonType) ArrayAdapter(android.widget.ArrayAdapter) CompoundButton(android.widget.CompoundButton)

Aggregations

View (android.view.View)1 AdapterView (android.widget.AdapterView)1 ArrayAdapter (android.widget.ArrayAdapter)1 CompoundButton (android.widget.CompoundButton)1 Spinner (android.widget.Spinner)1 TextView (android.widget.TextView)1 ButtonType (com.facebook.accountkit.ui.ButtonType)1 TextPosition (com.facebook.accountkit.ui.TextPosition)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1