use of android.widget.ArrayAdapter in project android_frameworks_base by ResurrectionRemix.
the class PrintActivity method bindUi.
private void bindUi() {
// Summary
mSummaryContainer = findViewById(R.id.summary_content);
mSummaryCopies = (TextView) findViewById(R.id.copies_count_summary);
mSummaryPaperSize = (TextView) findViewById(R.id.paper_size_summary);
// Options container
mOptionsContent = (PrintContentView) findViewById(R.id.options_content);
mOptionsContent.setOptionsStateChangeListener(this);
mOptionsContent.setOpenOptionsController(this);
OnItemSelectedListener itemSelectedListener = new MyOnItemSelectedListener();
OnClickListener clickListener = new MyClickListener();
// Copies
mCopiesEditText = (EditText) findViewById(R.id.copies_edittext);
mCopiesEditText.setOnFocusChangeListener(mSelectAllOnFocusListener);
mCopiesEditText.setText(MIN_COPIES_STRING);
mCopiesEditText.setSelection(mCopiesEditText.getText().length());
mCopiesEditText.addTextChangedListener(new EditTextWatcher());
// Destination.
mPrintersObserver = new PrintersObserver();
mDestinationSpinnerAdapter.registerDataSetObserver(mPrintersObserver);
mDestinationSpinner = (Spinner) findViewById(R.id.destination_spinner);
mDestinationSpinner.setAdapter(mDestinationSpinnerAdapter);
mDestinationSpinner.setOnItemSelectedListener(itemSelectedListener);
// Media size.
mMediaSizeSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
mMediaSizeSpinner = (Spinner) findViewById(R.id.paper_size_spinner);
mMediaSizeSpinner.setAdapter(mMediaSizeSpinnerAdapter);
mMediaSizeSpinner.setOnItemSelectedListener(itemSelectedListener);
// Color mode.
mColorModeSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
mColorModeSpinner = (Spinner) findViewById(R.id.color_spinner);
mColorModeSpinner.setAdapter(mColorModeSpinnerAdapter);
mColorModeSpinner.setOnItemSelectedListener(itemSelectedListener);
// Duplex mode.
mDuplexModeSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
mDuplexModeSpinner = (Spinner) findViewById(R.id.duplex_spinner);
mDuplexModeSpinner.setAdapter(mDuplexModeSpinnerAdapter);
mDuplexModeSpinner.setOnItemSelectedListener(itemSelectedListener);
// Orientation
mOrientationSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
String[] orientationLabels = getResources().getStringArray(R.array.orientation_labels);
mOrientationSpinnerAdapter.add(new SpinnerItem<>(ORIENTATION_PORTRAIT, orientationLabels[0]));
mOrientationSpinnerAdapter.add(new SpinnerItem<>(ORIENTATION_LANDSCAPE, orientationLabels[1]));
mOrientationSpinner = (Spinner) findViewById(R.id.orientation_spinner);
mOrientationSpinner.setAdapter(mOrientationSpinnerAdapter);
mOrientationSpinner.setOnItemSelectedListener(itemSelectedListener);
// Range options
ArrayAdapter<SpinnerItem<Integer>> rangeOptionsSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
mRangeOptionsSpinner = (Spinner) findViewById(R.id.range_options_spinner);
mRangeOptionsSpinner.setAdapter(rangeOptionsSpinnerAdapter);
mRangeOptionsSpinner.setOnItemSelectedListener(itemSelectedListener);
updatePageRangeOptions(PrintDocumentInfo.PAGE_COUNT_UNKNOWN);
// Page range
mPageRangeTitle = (TextView) findViewById(R.id.page_range_title);
mPageRangeEditText = (EditText) findViewById(R.id.page_range_edittext);
mPageRangeEditText.setVisibility(View.INVISIBLE);
mPageRangeTitle.setVisibility(View.INVISIBLE);
mPageRangeEditText.setOnFocusChangeListener(mSelectAllOnFocusListener);
mPageRangeEditText.addTextChangedListener(new RangeTextWatcher());
// Advanced options button.
mMoreOptionsButton = (Button) findViewById(R.id.more_options_button);
mMoreOptionsButton.setOnClickListener(clickListener);
// Print button
mPrintButton = (ImageView) findViewById(R.id.print_button);
mPrintButton.setOnClickListener(clickListener);
// The UI is now initialized
mIsOptionsUiBound = true;
// Special prompt instead of destination spinner for the first time the user printed
if (!hasUserEverPrinted()) {
mShowDestinationPrompt = true;
mSummaryCopies.setEnabled(false);
mSummaryPaperSize.setEnabled(false);
mDestinationSpinner.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
mShowDestinationPrompt = false;
mSummaryCopies.setEnabled(true);
mSummaryPaperSize.setEnabled(true);
updateOptionsUi();
mDestinationSpinner.setOnTouchListener(null);
mDestinationSpinnerAdapter.notifyDataSetChanged();
return false;
}
});
}
}
use of android.widget.ArrayAdapter in project android_frameworks_base by ResurrectionRemix.
the class LocalePicker method constructAdapter.
public static ArrayAdapter<LocaleInfo> constructAdapter(Context context, final int layoutId, final int fieldId) {
boolean isInDeveloperMode = Settings.Global.getInt(context.getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
final List<LocaleInfo> localeInfos = getAllAssetLocales(context, isInDeveloperMode);
final LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return new ArrayAdapter<LocaleInfo>(context, layoutId, fieldId, localeInfos) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view;
TextView text;
if (convertView == null) {
view = inflater.inflate(layoutId, parent, false);
text = (TextView) view.findViewById(fieldId);
view.setTag(text);
} else {
view = convertView;
text = (TextView) view.getTag();
}
LocaleInfo item = getItem(position);
text.setText(item.toString());
text.setTextLocale(item.getLocale());
return view;
}
};
}
use of android.widget.ArrayAdapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SupportItemAdapter method bindOfflineEscalationOptions.
private void bindOfflineEscalationOptions(ViewHolder holder, OfflineEscalationData data) {
// Bind Title
holder.tileTitleView.setText(data.tileTitle);
holder.tileTitleView.setContentDescription(data.tileTitleDescription);
holder.tileSummaryView.setText(data.tileSummary);
// Bind spinner
final Spinner spinner = (Spinner) holder.itemView.findViewById(R.id.spinner);
final ArrayAdapter<String> adapter = new ArrayAdapter(mActivity, android.R.layout.simple_spinner_dropdown_item, data.countries);
spinner.setAdapter(adapter);
final List<String> countryCodes = mSupportFeatureProvider.getPhoneSupportCountryCodes();
for (int i = 0; i < countryCodes.size(); i++) {
if (TextUtils.equals(countryCodes.get(i), mSelectedCountry)) {
spinner.setSelection(i);
break;
}
}
spinner.setOnItemSelectedListener(mSpinnerItemSelectListener);
// Bind buttons
if (data.tollFreePhone != null) {
holder.text1View.setText(data.tollFreePhone.number);
holder.text1View.setVisibility(View.VISIBLE);
holder.text1View.setOnClickListener(mEscalationClickListener);
} else {
holder.text1View.setVisibility(View.GONE);
}
if (data.tolledPhone != null) {
holder.text2View.setText(mActivity.getString(R.string.support_international_phone_title));
holder.text2View.setVisibility(View.VISIBLE);
holder.text2View.setOnClickListener(mEscalationClickListener);
} else {
holder.text2View.setVisibility(View.GONE);
}
if (ActivityManager.isUserAMonkey()) {
holder.text1View.setVisibility(View.GONE);
holder.text2View.setVisibility(View.GONE);
spinner.setVisibility(View.GONE);
holder.itemView.findViewById(R.id.support_text).setVisibility(View.GONE);
}
}
use of android.widget.ArrayAdapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiConfigController method showSecurityFields.
private void showSecurityFields() {
if (mAccessPointSecurity == AccessPoint.SECURITY_NONE) {
mView.findViewById(R.id.security_fields).setVisibility(View.GONE);
return;
}
mView.findViewById(R.id.security_fields).setVisibility(View.VISIBLE);
if (mPasswordView == null) {
mPasswordView = (TextView) mView.findViewById(R.id.password);
mPasswordView.addTextChangedListener(this);
mPasswordView.setOnEditorActionListener(this);
mPasswordView.setOnKeyListener(this);
((CheckBox) mView.findViewById(R.id.show_password)).setOnCheckedChangeListener(this);
if (mAccessPoint != null && mAccessPoint.isSaved()) {
mPasswordView.setHint(R.string.wifi_unchanged);
}
}
if (mAccessPointSecurity != AccessPoint.SECURITY_EAP) {
mView.findViewById(R.id.eap).setVisibility(View.GONE);
return;
}
mView.findViewById(R.id.eap).setVisibility(View.VISIBLE);
if (mEapMethodSpinner == null) {
getSIMInfo();
mEapMethodSpinner = (Spinner) mView.findViewById(R.id.method);
mEapMethodSpinner.setOnItemSelectedListener(this);
if (Utils.isWifiOnly(mContext) || !mContext.getResources().getBoolean(com.android.internal.R.bool.config_eap_sim_based_auth_supported)) {
String[] eapMethods = mContext.getResources().getStringArray(R.array.eap_method_without_sim_auth);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_item, eapMethods);
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mEapMethodSpinner.setAdapter(spinnerAdapter);
}
mPhase2Spinner = (Spinner) mView.findViewById(R.id.phase2);
mEapCaCertSpinner = (Spinner) mView.findViewById(R.id.ca_cert);
mEapCaCertSpinner.setOnItemSelectedListener(this);
mEapDomainView = (TextView) mView.findViewById(R.id.domain);
mEapDomainView.addTextChangedListener(this);
mEapUserCertSpinner = (Spinner) mView.findViewById(R.id.user_cert);
mEapUserCertSpinner.setOnItemSelectedListener(this);
mSimCardSpinner = (Spinner) mView.findViewById(R.id.sim_card);
mEapIdentityView = (TextView) mView.findViewById(R.id.identity);
mEapAnonymousView = (TextView) mView.findViewById(R.id.anonymous);
loadCertificates(mEapCaCertSpinner, Credentials.CA_CERTIFICATE, mDoNotValidateEapServerString, false, true);
loadCertificates(mEapUserCertSpinner, Credentials.USER_PRIVATE_KEY, mDoNotProvideEapUserCertString, false, false);
// Modifying an existing network
if (mAccessPoint != null && mAccessPoint.isSaved()) {
WifiEnterpriseConfig enterpriseConfig = mAccessPoint.getConfig().enterpriseConfig;
int eapMethod = enterpriseConfig.getEapMethod();
int phase2Method = enterpriseConfig.getPhase2Method();
mEapMethodSpinner.setSelection(eapMethod);
showEapFieldsByMethod(eapMethod);
switch(eapMethod) {
case Eap.PEAP:
switch(phase2Method) {
case Phase2.NONE:
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_NONE);
break;
case Phase2.MSCHAPV2:
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_MSCHAPV2);
break;
case Phase2.GTC:
mPhase2Spinner.setSelection(WIFI_PEAP_PHASE2_GTC);
break;
default:
Log.e(TAG, "Invalid phase 2 method " + phase2Method);
break;
}
break;
case Eap.SIM:
case Eap.AKA:
case Eap.AKA_PRIME:
WifiConfiguration config = mAccessPoint.getConfig();
mSimCardSpinner.setSelection(config.SIMNum - 1);
break;
default:
mPhase2Spinner.setSelection(phase2Method);
break;
}
if (!TextUtils.isEmpty(enterpriseConfig.getCaPath())) {
setSelection(mEapCaCertSpinner, mUseSystemCertsString);
} else {
String[] caCerts = enterpriseConfig.getCaCertificateAliases();
if (caCerts == null) {
setSelection(mEapCaCertSpinner, mDoNotValidateEapServerString);
} else if (caCerts.length == 1) {
setSelection(mEapCaCertSpinner, caCerts[0]);
} else {
// Reload the cert spinner with an extra "multiple certificates added" item.
loadCertificates(mEapCaCertSpinner, Credentials.CA_CERTIFICATE, mDoNotValidateEapServerString, true, true);
setSelection(mEapCaCertSpinner, mMultipleCertSetString);
}
}
mEapDomainView.setText(enterpriseConfig.getDomainSuffixMatch());
String userCert = enterpriseConfig.getClientCertificateAlias();
if (TextUtils.isEmpty(userCert)) {
setSelection(mEapUserCertSpinner, mDoNotProvideEapUserCertString);
} else {
setSelection(mEapUserCertSpinner, userCert);
}
mEapIdentityView.setText(enterpriseConfig.getIdentity());
mEapAnonymousView.setText(enterpriseConfig.getAnonymousIdentity());
} else {
showEapFieldsByMethod(mEapMethodSpinner.getSelectedItemPosition());
}
} else {
showEapFieldsByMethod(mEapMethodSpinner.getSelectedItemPosition());
}
}
use of android.widget.ArrayAdapter in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiConfigController method showEapFieldsByMethod.
/**
* EAP-PWD valid fields include
* identity
* password
* EAP-PEAP valid fields include
* phase2: MSCHAPV2, GTC
* ca_cert
* identity
* anonymous_identity
* password
* EAP-TLS valid fields include
* user_cert
* ca_cert
* domain
* identity
* EAP-TTLS valid fields include
* phase2: PAP, MSCHAP, MSCHAPV2, GTC
* ca_cert
* identity
* anonymous_identity
* password
*/
private void showEapFieldsByMethod(int eapMethod) {
// Common defaults
mView.findViewById(R.id.l_method).setVisibility(View.VISIBLE);
mView.findViewById(R.id.l_identity).setVisibility(View.VISIBLE);
mView.findViewById(R.id.l_domain).setVisibility(View.VISIBLE);
// Defaults for most of the EAP methods and over-riden by
// by certain EAP methods
mView.findViewById(R.id.l_ca_cert).setVisibility(View.VISIBLE);
mView.findViewById(R.id.password_layout).setVisibility(View.VISIBLE);
mView.findViewById(R.id.show_password_layout).setVisibility(View.VISIBLE);
Context context = mConfigUi.getContext();
switch(eapMethod) {
case WIFI_EAP_METHOD_PWD:
setPhase2Invisible();
setCaCertInvisible();
setDomainInvisible();
setAnonymousIdentInvisible();
setUserCertInvisible();
setSimCardInvisible();
break;
case WIFI_EAP_METHOD_TLS:
mView.findViewById(R.id.l_user_cert).setVisibility(View.VISIBLE);
setPhase2Invisible();
setAnonymousIdentInvisible();
setPasswordInvisible();
setSimCardInvisible();
break;
case WIFI_EAP_METHOD_PEAP:
// Reset adapter if needed
if (mPhase2Adapter != mPhase2PeapAdapter) {
mPhase2Adapter = mPhase2PeapAdapter;
mPhase2Spinner.setAdapter(mPhase2Adapter);
}
mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE);
mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
setUserCertInvisible();
setSimCardInvisible();
break;
case WIFI_EAP_METHOD_TTLS:
// Reset adapter if needed
if (mPhase2Adapter != mPhase2FullAdapter) {
mPhase2Adapter = mPhase2FullAdapter;
mPhase2Spinner.setAdapter(mPhase2Adapter);
}
mView.findViewById(R.id.l_phase2).setVisibility(View.VISIBLE);
mView.findViewById(R.id.l_anonymous).setVisibility(View.VISIBLE);
setUserCertInvisible();
setSimCardInvisible();
break;
case WIFI_EAP_METHOD_SIM:
case WIFI_EAP_METHOD_AKA:
case WIFI_EAP_METHOD_AKA_PRIME:
WifiConfiguration config = null;
if (mAccessPoint != null) {
config = mAccessPoint.getConfig();
}
ArrayAdapter<String> eapSimAdapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_item, mSimDisplayNames.toArray(new String[mSimDisplayNames.size()]));
eapSimAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSimCardSpinner.setAdapter(eapSimAdapter);
mView.findViewById(R.id.l_sim_card).setVisibility(View.VISIBLE);
if (config != null) {
mSimCardSpinner.setSelection(config.SIMNum - 1);
}
setPhase2Invisible();
setAnonymousIdentInvisible();
setCaCertInvisible();
setDomainInvisible();
setUserCertInvisible();
setPasswordInvisible();
setIdentityInvisible();
break;
}
if (mView.findViewById(R.id.l_ca_cert).getVisibility() != View.GONE) {
String eapCertSelection = (String) mEapCaCertSpinner.getSelectedItem();
if (eapCertSelection.equals(mDoNotValidateEapServerString) || eapCertSelection.equals(mUnspecifiedCertString)) {
// Domain suffix matching is not relevant if the user hasn't chosen a CA
// certificate yet, or chooses not to validate the EAP server.
setDomainInvisible();
}
}
}
Aggregations