diff --git a/app/src/main/java/com/github/willena/android_phonenumber_input/MainActivity.java b/app/src/main/java/com/github/willena/android_phonenumber_input/MainActivity.java index 29b2b74..ca8e966 100644 --- a/app/src/main/java/com/github/willena/android_phonenumber_input/MainActivity.java +++ b/app/src/main/java/com/github/willena/android_phonenumber_input/MainActivity.java @@ -26,9 +26,9 @@ protected void onCreate(Bundle savedInstanceState) { phoneView = (PhoneInputView) findViewById(R.id.phoneId); CountryConfigurator config = new CountryConfigurator(); - config.setDisplayFlag(true); + config.setDisplayFlag(false); config.setDisplayCountryCode(true); - config.setDisplayDialingCode(true); + config.setDisplayDialingCode(false); phoneView.setConfig(config); diff --git a/phoneinputview/build.gradle b/phoneinputview/build.gradle index c4f3607..373261d 100644 --- a/phoneinputview/build.gradle +++ b/phoneinputview/build.gradle @@ -10,8 +10,8 @@ android { defaultConfig { minSdkVersion 15 targetSdkVersion 25 - versionCode 1 - versionName "1.0" + versionCode 12 + versionName "1.2" consumerProguardFiles 'proguard-rules.pro' } } diff --git a/phoneinputview/src/main/java/com/github/willena/phoneinputview/SpinnerCountryArrayAdapter.java b/phoneinputview/src/main/java/com/github/willena/phoneinputview/SpinnerCountryArrayAdapter.java index 6af41c3..6eb3479 100644 --- a/phoneinputview/src/main/java/com/github/willena/phoneinputview/SpinnerCountryArrayAdapter.java +++ b/phoneinputview/src/main/java/com/github/willena/phoneinputview/SpinnerCountryArrayAdapter.java @@ -23,7 +23,7 @@ class SpinnerCountryArrayAdapter extends ArrayAdapter { private final PhoneNumberUtil phoneUtils; SpinnerCountryArrayAdapter(Context context, CountryConfigurator config, PhoneNumberUtil phoneUtil, - List objects) { + List objects) { super(context, R.layout.phone_input_spinner_top_item, objects); this.phoneUtils = phoneUtil; this.config = config; @@ -49,39 +49,48 @@ public View getCustomView(int position, View convertView, ViewGroup parent, Bool TextView countryName = (TextView) row.findViewById(R.id.phone_input_spinner_item_country_name); TextView dialCode = (TextView) row.findViewById(R.id.phone_input_spinner_item_dialcode); - if (top) - countryName.setVisibility(View.GONE); - else{ + if (!top) { countryName.setText(getItem(position).getName()); - } - - if (this.config.getDisplayCountryCode()) + dialCode.setText("(+" + phoneUtils.getExampleNumber(getItem(position).getCode()).getCountryCode() + ")"); countryCode.setText(getItem(position).getCode()); - else - countryCode.setVisibility(View.GONE); - if (this.config.getDisplayFlag()) { Resources resources = row.getResources(); int resourceId = resources.getIdentifier(getItem(position).getCode().toLowerCase() + "_", "drawable", row.getContext().getPackageName()); + flag.setImageDrawable((resourceId <= 0) ? null : resources.getDrawable(resourceId)); + + + } else { + countryName.setVisibility(View.GONE); + + if (this.config.getDisplayCountryCode()) { + countryCode.setText(getItem(position).getCode()); + } else { + countryCode.setVisibility(View.GONE); + } - if (resourceId <= 0) - flag.setImageDrawable(null); - else - flag.setImageDrawable(resources.getDrawable(resourceId)); - } else - flag.setVisibility(View.GONE); + if (this.config.getDisplayFlag()) { + Resources resources = row.getResources(); + int resourceId = resources.getIdentifier(getItem(position).getCode().toLowerCase() + "_", "drawable", row.getContext().getPackageName()); - if (this.config.getDisplayDialingCode()) { - try { - dialCode.setText("(+" + phoneUtils.getExampleNumber(getItem(position).getCode()).getCountryCode() + ")"); - } catch (Exception e) { - dialCode.setText(""); + flag.setImageDrawable((resourceId <= 0) ? null : resources.getDrawable(resourceId)); + } else { + flag.setVisibility(View.GONE); } - } else { - dialCode.setVisibility(View.GONE); + + + if (this.config.getDisplayDialingCode()) { + try { + dialCode.setText("(+" + phoneUtils.getExampleNumber(getItem(position).getCode()).getCountryCode() + ")"); + } catch (Exception e) { + dialCode.setText(""); + } + } else { + dialCode.setVisibility(View.GONE); + } + } return row;