diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..953724b --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +*.iml +.gradle +/local.properties +/.idea/ +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild + diff --git a/AUTHOR.md b/AUTHOR.md new file mode 100644 index 0000000..4b74b7c --- /dev/null +++ b/AUTHOR.md @@ -0,0 +1 @@ +* Leonardo Javier Esparis Meza \ No newline at end of file diff --git a/CHANGELOGS.md b/CHANGELOGS.md new file mode 100644 index 0000000..5f062d3 --- /dev/null +++ b/CHANGELOGS.md @@ -0,0 +1,3 @@ +Version 1.0 +------------ +* First commit \ No newline at end of file diff --git a/CONTRIBUTORS.MD b/CONTRIBUTORS.MD new file mode 100644 index 0000000..4b74b7c --- /dev/null +++ b/CONTRIBUTORS.MD @@ -0,0 +1 @@ +* Leonardo Javier Esparis Meza \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..371b4bc --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e359fba --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +PhoneEditText +------------- +special phone edittext library, all international phone codes came from ![https://countrycode.org/](https://countrycode.org/) + + +Usage +----- +1- first of all, add gradle dependencie +```gradle + +allprojects { + repositories { + jcenter() + maven { url "https://jitpack.io" } + } +} + . + . + . + + +dependencies { + compile 'com.github.leoxnidas:phoneedittext:phoneedittext:1.0' +} +``` + +2- add PhoneEditText to your layout +```xml + +``` + +3- enjoy =P + +![image](./img/phone.png) + + +License +-------- +![LICENSE](./LICENSE.md) \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..f49259c --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,31 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.2" + defaultConfig { + applicationId "com.leoxnidas.phoneedittextexample" + minSdkVersion 15 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:25.1.1' + testCompile 'junit:junit:4.12' + + compile project(':phoneedittext') +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..9df8379 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/joker/Android/Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/androidTest/java/com/leoxnidas/phoneedittextexample/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/leoxnidas/phoneedittextexample/ExampleInstrumentedTest.java new file mode 100644 index 0000000..3ed2f6f --- /dev/null +++ b/app/src/androidTest/java/com/leoxnidas/phoneedittextexample/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.leoxnidas.phoneedittextexample; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.leoxnidas.phoneedittextexample", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c8886d1 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/leoxnidas/phoneedittextexample/MainActivity.java b/app/src/main/java/com/leoxnidas/phoneedittextexample/MainActivity.java new file mode 100644 index 0000000..7720a6e --- /dev/null +++ b/app/src/main/java/com/leoxnidas/phoneedittextexample/MainActivity.java @@ -0,0 +1,528 @@ +package com.leoxnidas.phoneedittextexample; + +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Spinner; +import android.widget.TextView; + +import com.github.leoxnidas.phoneedittext.Codes; +import com.github.leoxnidas.phoneedittext.PhoneEditText; + + +public class MainActivity extends AppCompatActivity + implements AdapterView.OnItemSelectedListener { + + private PhoneEditText phoneEdittext; + private Spinner codes; + private ArrayAdapter mAdapterCodes; + + private String[] CODES; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + phoneEdittext = (PhoneEditText) findViewById(R.id.phone_code); + + + codes = (Spinner) findViewById(R.id.codes); + CODES = getResources().getStringArray(R.array.CODES); + mAdapterCodes = new ArrayAdapter(this, + android.R.layout.simple_spinner_dropdown_item, CODES); + codes.setAdapter(mAdapterCodes); + codes.setOnItemSelectedListener(this); + + } + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + String country = ((TextView)view).getText().toString(); + + if(country.equals("Afghanistan")) + phoneEdittext.setCode(Codes.AFG); + if(country.equals("Albania")) + phoneEdittext.setCode(Codes.ALB); + if(country.equals("Algeria")) + phoneEdittext.setCode(Codes.DZA); + if(country.equals("American Samoa")) + phoneEdittext.setCode(Codes.ASM); + if(country.equals("Andorra")) + phoneEdittext.setCode(Codes.AND); + if(country.equals("Angola")) + phoneEdittext.setCode(Codes.AGO); + if(country.equals("Anguilla")) + phoneEdittext.setCode(Codes.AIA); + if(country.equals("Antarctica")) + phoneEdittext.setCode(Codes.ATA); + if(country.equals("Antigua and Barbuda")) + phoneEdittext.setCode(Codes.ATG); + if(country.equals("Argentina")) + phoneEdittext.setCode(Codes.ARG); + if(country.equals("Armenia")) + phoneEdittext.setCode(Codes.ARM); + if(country.equals("Aruba")) + phoneEdittext.setCode(Codes.ABW); + if(country.equals("Australia")) + phoneEdittext.setCode(Codes.AUS); + if(country.equals("Austria")) + phoneEdittext.setCode(Codes.AUT); + if(country.equals("Azerbaijan")) + phoneEdittext.setCode(Codes.AZE); + if(country.equals("Bahamas")) + phoneEdittext.setCode(Codes.BHS); + if(country.equals("Bahrain")) + phoneEdittext.setCode(Codes.BHR); + if(country.equals("Bangladesh")) + phoneEdittext.setCode(Codes.BGD); + if(country.equals("Barbados")) + phoneEdittext.setCode(Codes.BRB); + if(country.equals("Belarus")) + phoneEdittext.setCode(Codes.BLR); + if(country.equals("Belgium")) + phoneEdittext.setCode(Codes.BEL); + if(country.equals("Belize")) + phoneEdittext.setCode(Codes.BLZ); + if(country.equals("Benin")) + phoneEdittext.setCode(Codes.BEN); + if(country.equals("Bermuda")) + phoneEdittext.setCode(Codes.BMU); + if(country.equals("Bhutan")) + phoneEdittext.setCode(Codes.BTN); + if(country.equals("Bolivia")) + phoneEdittext.setCode(Codes.BOL); + if(country.equals("Bosnia and Herzegovina")) + phoneEdittext.setCode(Codes.BIH); + if(country.equals("Botswana")) + phoneEdittext.setCode(Codes.BWA); + if(country.equals("Brazil")) + phoneEdittext.setCode(Codes.BRA); + if(country.equals("British Indian Ocean Territory")) + phoneEdittext.setCode(Codes.IOT); + if(country.equals("British Virgin Islands")) + phoneEdittext.setCode(Codes.VGB); + if(country.equals("Brunei")) + phoneEdittext.setCode(Codes.BRN); + if(country.equals("Bulgaria")) + phoneEdittext.setCode(Codes.BGR); + if(country.equals("Burkina Faso")) + phoneEdittext.setCode(Codes.BFA); + if(country.equals("Burundi")) + phoneEdittext.setCode(Codes.BDI); + if(country.equals("Cambodia")) + phoneEdittext.setCode(Codes.KHM); + if(country.equals("Cameroon")) + phoneEdittext.setCode(Codes.CMR); + if(country.equals("Canada")) + phoneEdittext.setCode(Codes.CAN); + if(country.equals("Cape Verde")) + phoneEdittext.setCode(Codes.CPV); + if(country.equals("Cayman Islands")) + phoneEdittext.setCode(Codes.CYM); + if(country.equals("Central African Republic")) + phoneEdittext.setCode(Codes.CAF); + if(country.equals("Chad")) + phoneEdittext.setCode(Codes.TCD); + if(country.equals("Chile")) + phoneEdittext.setCode(Codes.CHL); + if(country.equals("China")) + phoneEdittext.setCode(Codes.CHN); + if(country.equals("Christmas Island")) + phoneEdittext.setCode(Codes.CXR); + if(country.equals("Cocos Islands")) + phoneEdittext.setCode(Codes.CCK); + if(country.equals("Colombia")) + phoneEdittext.setCode(Codes.COL); + if(country.equals("Comoros")) + phoneEdittext.setCode(Codes.COM); + if(country.equals("Cook Islands")) + phoneEdittext.setCode(Codes.COK); + if(country.equals("Costa Rica")) + phoneEdittext.setCode(Codes.CRI); + if(country.equals("Croatia")) + phoneEdittext.setCode(Codes.HRV); + if(country.equals("Cuba")) + phoneEdittext.setCode(Codes.CUB); + if(country.equals("Curacao")) + phoneEdittext.setCode(Codes.CUW); + if(country.equals("Cyprus")) + phoneEdittext.setCode(Codes.CYP); + if(country.equals("Czech Republic")) + phoneEdittext.setCode(Codes.CZE); + if(country.equals("Democratic Republic of the Congo")) + phoneEdittext.setCode(Codes.COD); + if(country.equals("Denmark")) + phoneEdittext.setCode(Codes.DNK); + if(country.equals("Djibouti")) + phoneEdittext.setCode(Codes.DJI); + if(country.equals("Djibouti")) + phoneEdittext.setCode(Codes.DMA); + if(country.equals("Dominican Republic")) + phoneEdittext.setCode(Codes.DOM); + if(country.equals("East Timor")) + phoneEdittext.setCode(Codes.TLS); + if(country.equals("Ecuador")) + phoneEdittext.setCode(Codes.ECU); + if(country.equals("Egypt")) + phoneEdittext.setCode(Codes.EGY); + if(country.equals("El Salvador")) + phoneEdittext.setCode(Codes.SLV); + if(country.equals("Equatorial Guinea")) + phoneEdittext.setCode(Codes.GNQ); + if(country.equals("Eritrea")) + phoneEdittext.setCode(Codes.ERI); + if(country.equals("Estonia")) + phoneEdittext.setCode(Codes.EST); + if(country.equals("Ethiopia")) + phoneEdittext.setCode(Codes.ETH); + if(country.equals("Falkland Islands")) + phoneEdittext.setCode(Codes.FLK); + if(country.equals("Faroe Islands")) + phoneEdittext.setCode(Codes.FRO); + if(country.equals("Fiji")) + phoneEdittext.setCode(Codes.FJI); + if(country.equals("Finland")) + phoneEdittext.setCode(Codes.FIN); + if(country.equals("France")) + phoneEdittext.setCode(Codes.FRA); + if(country.equals("French Polynesia")) + phoneEdittext.setCode(Codes.PYF); + if(country.equals("Gabon")) + phoneEdittext.setCode(Codes.GAB); + if(country.equals("Gambia")) + phoneEdittext.setCode(Codes.GMB); + if(country.equals("Georgia")) + phoneEdittext.setCode(Codes.GEO); + if(country.equals("Germany")) + phoneEdittext.setCode(Codes.DEU); + if(country.equals("Ghana")) + phoneEdittext.setCode(Codes.GHA); + if(country.equals("Gibraltar")) + phoneEdittext.setCode(Codes.GIB); + if(country.equals("Greece")) + phoneEdittext.setCode(Codes.GRC); + if(country.equals("Greenland")) + phoneEdittext.setCode(Codes.GRL); + if(country.equals("Grenada")) + phoneEdittext.setCode(Codes.GRD); + if(country.equals("Guam")) + phoneEdittext.setCode(Codes.GUM); + if(country.equals("Guatemala")) + phoneEdittext.setCode(Codes.GTM); + if(country.equals("Guernsey")) + phoneEdittext.setCode(Codes.GGY); + if(country.equals("Guinea")) + phoneEdittext.setCode(Codes.GIN); + if(country.equals("Guinea-Bissau")) + phoneEdittext.setCode(Codes.GNB); + if(country.equals("Guyana")) + phoneEdittext.setCode(Codes.GUY); + if(country.equals("Haiti")) + phoneEdittext.setCode(Codes.HTI); + if(country.equals("Honduras")) + phoneEdittext.setCode(Codes.HND); + if(country.equals("Hong Kong")) + phoneEdittext.setCode(Codes.HKG); + if(country.equals("Hungary")) + phoneEdittext.setCode(Codes.HUN); + if(country.equals("Iceland")) + phoneEdittext.setCode(Codes.ISL); + if(country.equals("India")) + phoneEdittext.setCode(Codes.IND); + if(country.equals("Indonesia")) + phoneEdittext.setCode(Codes.IDN); + if(country.equals("Iran")) + phoneEdittext.setCode(Codes.IRN); + if(country.equals("Iraq")) + phoneEdittext.setCode(Codes.IRQ); + if(country.equals("Ireland")) + phoneEdittext.setCode(Codes.IRL); + if(country.equals("Isle of Man")) + phoneEdittext.setCode(Codes.IMN); + if(country.equals("Israel")) + phoneEdittext.setCode(Codes.ISR); + if(country.equals("Italy")) + phoneEdittext.setCode(Codes.ITA); + if(country.equals("Ivory Coast")) + phoneEdittext.setCode(Codes.CIV); + if(country.equals("Jamaica")) + phoneEdittext.setCode(Codes.JAM); + if(country.equals("Japan")) + phoneEdittext.setCode(Codes.JPN); + if(country.equals("Jersey")) + phoneEdittext.setCode(Codes.JEY); + if(country.equals("Jordan")) + phoneEdittext.setCode(Codes.JOR); + if(country.equals("Kazakhstan")) + phoneEdittext.setCode(Codes.KAZ); + if(country.equals("Kenya")) + phoneEdittext.setCode(Codes.KEN); + if(country.equals("Kiribati")) + phoneEdittext.setCode(Codes.KIR); + if(country.equals("Kosovo")) + phoneEdittext.setCode(Codes.XKX); + if(country.equals("Kuwait")) + phoneEdittext.setCode(Codes.KWT); + if(country.equals("Kyrgyzstan")) + phoneEdittext.setCode(Codes.KGZ); + if(country.equals("Laos")) + phoneEdittext.setCode(Codes.LAO); + if(country.equals("Latvia")) + phoneEdittext.setCode(Codes.LVA); + if(country.equals("Lebanon")) + phoneEdittext.setCode(Codes.LBN); + if(country.equals("Lesotho")) + phoneEdittext.setCode(Codes.LSO); + if(country.equals("Liberia")) + phoneEdittext.setCode(Codes.LBR); + if(country.equals("Libya")) + phoneEdittext.setCode(Codes.LBY); + if(country.equals("Liechtenstein")) + phoneEdittext.setCode(Codes.LIE); + if(country.equals("Lithuania")) + phoneEdittext.setCode(Codes.LTU); + if(country.equals("Luxembourg")) + phoneEdittext.setCode(Codes.LUX); + if(country.equals("Macau")) + phoneEdittext.setCode(Codes.MAC); + if(country.equals("Macedonia")) + phoneEdittext.setCode(Codes.MKD); + if(country.equals("Madagascar")) + phoneEdittext.setCode(Codes.MDG); + if(country.equals("Malawi")) + phoneEdittext.setCode(Codes.MWI); + if(country.equals("Malaysia")) + phoneEdittext.setCode(Codes.MYS); + if(country.equals("Maldives")) + phoneEdittext.setCode(Codes.MDV); + if(country.equals("Mali")) + phoneEdittext.setCode(Codes.MLI); + if(country.equals("Malta")) + phoneEdittext.setCode(Codes.MLT); + if(country.equals("Marshall Islands")) + phoneEdittext.setCode(Codes.MHL); + if(country.equals("Mauritania")) + phoneEdittext.setCode(Codes.MRT); + if(country.equals("Mauritius")) + phoneEdittext.setCode(Codes.MUS); + if(country.equals("Mayotte")) + phoneEdittext.setCode(Codes.MYT); + if(country.equals("Mexico")) + phoneEdittext.setCode(Codes.MEX); + if(country.equals("Micronesia")) + phoneEdittext.setCode(Codes.FSM); + if(country.equals("Moldova")) + phoneEdittext.setCode(Codes.MDA); + if(country.equals("Monaco")) + phoneEdittext.setCode(Codes.MCO); + if(country.equals("Mongolia")) + phoneEdittext.setCode(Codes.MNG); + if(country.equals("Montenegro")) + phoneEdittext.setCode(Codes.MNE); + if(country.equals("Montserrat")) + phoneEdittext.setCode(Codes.MSR); + if(country.equals("Morocco")) + phoneEdittext.setCode(Codes.MAR); + if(country.equals("Mozambique")) + phoneEdittext.setCode(Codes.MOZ); + if(country.equals("Myanmar")) + phoneEdittext.setCode(Codes.MMR); + if(country.equals("Namibia")) + phoneEdittext.setCode(Codes.NAM); + if(country.equals("Nauru")) + phoneEdittext.setCode(Codes.NRU); + if(country.equals("Nepal")) + phoneEdittext.setCode(Codes.NPL); + if(country.equals("Netherlands")) + phoneEdittext.setCode(Codes.NLD); + if(country.equals("Netherlands Antilles")) + phoneEdittext.setCode(Codes.ANT); + if(country.equals("New Caledonia")) + phoneEdittext.setCode(Codes.NCL); + if(country.equals("New Zealand")) + phoneEdittext.setCode(Codes.NZL); + if(country.equals("Nicaragua")) + phoneEdittext.setCode(Codes.NIC); + if(country.equals("Niger")) + phoneEdittext.setCode(Codes.NER); + if(country.equals("Nigeria")) + phoneEdittext.setCode(Codes.NGA); + if(country.equals("Niue")) + phoneEdittext.setCode(Codes.NIU); + if(country.equals("North Korea")) + phoneEdittext.setCode(Codes.PRK); + if(country.equals("Northern Mariana Islands")) + phoneEdittext.setCode(Codes.MNP); + if(country.equals("Norway")) + phoneEdittext.setCode(Codes.NOR); + if(country.equals("Oman")) + phoneEdittext.setCode(Codes.OMN); + if(country.equals("Pakistan")) + phoneEdittext.setCode(Codes.PAK); + if(country.equals("Palau")) + phoneEdittext.setCode(Codes.PLW); + if(country.equals("Palestine")) + phoneEdittext.setCode(Codes.PSE); + if(country.equals("Panama")) + phoneEdittext.setCode(Codes.PAN); + if(country.equals("Papua New Guinea")) + phoneEdittext.setCode(Codes.PNG); + if(country.equals("Paraguay")) + phoneEdittext.setCode(Codes.PRY); + if(country.equals("Peru")) + phoneEdittext.setCode(Codes.PER); + if(country.equals("Philippines")) + phoneEdittext.setCode(Codes.PHL); + if(country.equals("Pitcairn")) + phoneEdittext.setCode(Codes.PCN); + if(country.equals("Poland")) + phoneEdittext.setCode(Codes.POL); + if(country.equals("Portugal")) + phoneEdittext.setCode(Codes.PRT); + if(country.equals("Puerto Rico")) + phoneEdittext.setCode(Codes.PRI); + if(country.equals("Qatar")) + phoneEdittext.setCode(Codes.QAT); + if(country.equals("Republic of the Congo")) + phoneEdittext.setCode(Codes.COG); + if(country.equals("Reunion")) + phoneEdittext.setCode(Codes.REU); + if(country.equals("Romania")) + phoneEdittext.setCode(Codes.ROU); + if(country.equals("Russia")) + phoneEdittext.setCode(Codes.RUS); + if(country.equals("Rwanda")) + phoneEdittext.setCode(Codes.RWA); + if(country.equals("Saint Barthelemy")) + phoneEdittext.setCode(Codes.BLM); + if(country.equals("Saint Helena")) + phoneEdittext.setCode(Codes.SHN); + if(country.equals("Saint Kitts and Nevis")) + phoneEdittext.setCode(Codes.KNA); + if(country.equals("Saint Lucia")) + phoneEdittext.setCode(Codes.LCA); + if(country.equals("Saint Martin")) + phoneEdittext.setCode(Codes.MAF); + if(country.equals("Saint Pierre and Miquelon")) + phoneEdittext.setCode(Codes.SPM); + if(country.equals("Saint Vincent and the Grenadines")) + phoneEdittext.setCode(Codes.VCT); + if(country.equals("Samoa")) + phoneEdittext.setCode(Codes.WSM); + if(country.equals("San Marino")) + phoneEdittext.setCode(Codes.SMR); + if(country.equals("Sao Tome and Principe")) + phoneEdittext.setCode(Codes.STP); + if(country.equals("Saudi Arabia")) + phoneEdittext.setCode(Codes.SAU); + if(country.equals("Senegal")) + phoneEdittext.setCode(Codes.SEN); + if(country.equals("Serbia")) + phoneEdittext.setCode(Codes.SRB); + if(country.equals("Seychelles")) + phoneEdittext.setCode(Codes.SYC); + if(country.equals("Sierra Leone")) + phoneEdittext.setCode(Codes.SLE); + if(country.equals("Singapore")) + phoneEdittext.setCode(Codes.SGP); + if(country.equals("Sint Maarten")) + phoneEdittext.setCode(Codes.SXM); + if(country.equals("Slovakia")) + phoneEdittext.setCode(Codes.SVK); + if(country.equals("Slovenia")) + phoneEdittext.setCode(Codes.SVN); + if(country.equals("Solomon Islands")) + phoneEdittext.setCode(Codes.SLB); + if(country.equals("Somalia")) + phoneEdittext.setCode(Codes.SOM); + if(country.equals("South Africa")) + phoneEdittext.setCode(Codes.ZAF); + if(country.equals("South Korea")) + phoneEdittext.setCode(Codes.KOR); + if(country.equals("South Sudan")) + phoneEdittext.setCode(Codes.SSD); + if(country.equals("Spain")) + phoneEdittext.setCode(Codes.ESP); + if(country.equals("Sri Lanka")) + phoneEdittext.setCode(Codes.LKA); + if(country.equals("Sudan")) + phoneEdittext.setCode(Codes.SDN); + if(country.equals("Suriname")) + phoneEdittext.setCode(Codes.SUR); + if(country.equals("Svalbard and Jan Mayen")) + phoneEdittext.setCode(Codes.SJM); + if(country.equals("Swaziland")) + phoneEdittext.setCode(Codes.SWZ); + if(country.equals("Sweden")) + phoneEdittext.setCode(Codes.SWE); + if(country.equals("Switzerland")) + phoneEdittext.setCode(Codes.CHE); + if(country.equals("Syria")) + phoneEdittext.setCode(Codes.SYR); + if(country.equals("Taiwan")) + phoneEdittext.setCode(Codes.TWN); + if(country.equals("Tajikistan")) + phoneEdittext.setCode(Codes.TJK); + if(country.equals("Tanzania")) + phoneEdittext.setCode(Codes.TZA); + if(country.equals("Thailand")) + phoneEdittext.setCode(Codes.THA); + if(country.equals("Togo")) + phoneEdittext.setCode(Codes.TGO); + if(country.equals("Tokelau")) + phoneEdittext.setCode(Codes.TKL); + if(country.equals("Tonga")) + phoneEdittext.setCode(Codes.TON); + if(country.equals("Trinidad and Tobago")) + phoneEdittext.setCode(Codes.TTO); + if(country.equals("Tunisia")) + phoneEdittext.setCode(Codes.TUN); + if(country.equals("Turkey")) + phoneEdittext.setCode(Codes.TUR); + if(country.equals("Turkmenistan")) + phoneEdittext.setCode(Codes.TKM); + if(country.equals("Turks and Caicos Islands")) + phoneEdittext.setCode(Codes.TCA); + if(country.equals("Tuvalu")) + phoneEdittext.setCode(Codes.TUV); + if(country.equals("U.S. Virgin Islands")) + phoneEdittext.setCode(Codes.VIR); + if(country.equals("Uganda")) + phoneEdittext.setCode(Codes.UGA); + if(country.equals("Ukraine")) + phoneEdittext.setCode(Codes.UKR); + if(country.equals("United Arab Emirates")) + phoneEdittext.setCode(Codes.ARE); + if(country.equals("United Kingdom")) + phoneEdittext.setCode(Codes.GBR); + if(country.equals("United States")) + phoneEdittext.setCode(Codes.USA); + if(country.equals("Uruguay")) + phoneEdittext.setCode(Codes.URY); + if(country.equals("Uzbekistan")) + phoneEdittext.setCode(Codes.UZB); + if(country.equals("Vanuatu")) + phoneEdittext.setCode(Codes.VUT); + if(country.equals("Vatican")) + phoneEdittext.setCode(Codes.VAT); + if(country.equals("Venezuela")) + phoneEdittext.setCode(Codes.VEN); + if(country.equals("Vietnam")) + phoneEdittext.setCode(Codes.VNM); + if(country.equals("Wallis and Futuna")) + phoneEdittext.setCode(Codes.WLF); + if(country.equals("Western Sahara")) + phoneEdittext.setCode(Codes.ESH); + if(country.equals("Yemen")) + phoneEdittext.setCode(Codes.YEM); + if(country.equals("Zambia")) + phoneEdittext.setCode(Codes.ZMB); + if(country.equals("Zimbabw")) + phoneEdittext.setCode(Codes.ZWE); + } + + @Override + public void onNothingSelected(AdapterView parent) {} +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..84da80b --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,26 @@ + + + + + + + diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..aee44e1 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml new file mode 100644 index 0000000..63fc816 --- /dev/null +++ b/app/src/main/res/values-w820dp/dimens.xml @@ -0,0 +1,6 @@ + + + 64dp + diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml new file mode 100644 index 0000000..d4b2bb9 --- /dev/null +++ b/app/src/main/res/values/arrays.xml @@ -0,0 +1,245 @@ + + + + Afghanistan + Albania + Algeria + American Samoa + Andorra + Angola + Anguilla + Antarctica + Antigua and Barbuda + Argentina + Armenia + Aruba + Australia + Austria + Azerbaijan + Bahamas + Bahrain + Bangladesh + Barbados + Belarus + Belgium + Belize + Benin + Bermuda + Bhutan + Bolivia + Bosnia and Herzegovina + Botswana + Brazil + British Indian Ocean Territory + British Virgin Islands + Brunei + Bulgaria + Burkina Faso + Burundi + Cambodia + Cameroon + Canada + Cape Verde + Cayman Islands + Central African Republic + Chad + Chile + China + Christmas Island + Cocos Islands + Colombia + Comoros + Cook Islands + Costa Rica + Croatia + Cuba + Curacao + Cyprus + Czech Republic + Democratic Republic of the Congo + Denmark + Djibouti + Djibouti + Dominican Republic + East Timor + Ecuador + Egypt + El Salvador + Equatorial Guinea + Eritrea + Estonia + Ethiopia + Falkland Islands + Faroe Islands + Fiji + Finland + France + French Polynesia + Gabon + Gambia + Georgia + Germany + Ghana + Gibraltar + Greece + Greenland + Grenada + Guam + Guatemala + Guernsey + Guinea + Guinea-Bissau + Guyana + Haiti + Honduras + Hong Kong + Hungary + Iceland + India + Indonesia + Iran + Iraq + Ireland + Isle of Man + Israel + Italy + Ivory Coast + Jamaica + Japan + Jersey + Jordan + Kazakhstan + Kenya + Kiribati + Kosovo + Kuwait + Kyrgyzstan + Laos + Latvia + Lebanon + Lesotho + Liberia + Libya + Liechtenstein + Lithuania + Luxembourg + Macau + Macedonia + Madagascar + Malawi + Malaysia + Maldives + Mali + Malta + Marshall Islands + Mauritania + Mauritius + Mayotte + Mexico + Micronesia + Moldova + Monaco + Mongolia + Montenegro + Montserrat + Morocco + Mozambique + Myanmar + Namibia + Nauru + Nepal + Netherlands + Netherlands Antilles + New Caledonia + New Zealand + Nicaragua + Niger + Nigeria + Niue + North Korea + Northern Mariana Islands + Norway + Oman + Pakistan + Palau + Palestine + Panama + Papua New Guinea + Paraguay + Peru + Philippines + Pitcairn + Poland + Portugal + Puerto Rico + Qatar + Republic of the Congo + Reunion + Romania + Russia + Rwanda + Saint Barthelemy + Saint Helena + Saint Kitts and Nevis + Saint Lucia + Saint Martin + Saint Pierre and Miquelon + Saint Vincent and the Grenadines + Samoa + San Marino + Sao Tome and Principe + Saudi Arabia + Senegal + Serbia + Seychelles + Sierra Leone + Singapore + Sint Maarten + Slovakia + Slovenia + Solomon Islands + Somalia + South Africa + South Korea + South Sudan + Spain + Sri Lanka + Sudan + Suriname + Svalbard and Jan Mayen + Swaziland + Sweden + Switzerland + Syria + Taiwan + Tajikistan + Tanzania + Thailand + Togo + Tokelau + Tonga + Trinidad and Tobago + Tunisia + Turkey + Turkmenistan + Turks and Caicos Islands + Tuvalu + U.S. Virgin Islands + Uganda + Ukraine + United Arab Emirates + United Kingdom + United States + Uruguay + Uzbekistan + Vanuatu + Vatican + Venezuela + Vietnam + Wallis and Futuna + Western Sahara + Yemen + Zambia + Zimbabw + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..3ab3e9c --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #3F51B5 + #303F9F + #FF4081 + diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml new file mode 100644 index 0000000..47c8224 --- /dev/null +++ b/app/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 16dp + 16dp + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..8995f06 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + PhoneEditTextExample + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..5885930 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/app/src/test/java/com/leoxnidas/phoneedittextexample/ExampleUnitTest.java b/app/src/test/java/com/leoxnidas/phoneedittextexample/ExampleUnitTest.java new file mode 100644 index 0000000..35fdf9b --- /dev/null +++ b/app/src/test/java/com/leoxnidas/phoneedittextexample/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.leoxnidas.phoneedittextexample; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..6586594 --- /dev/null +++ b/build.gradle @@ -0,0 +1,25 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.2.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + maven { url "https://jitpack.io" } + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..aac7c9b --- /dev/null +++ b/gradle.properties @@ -0,0 +1,17 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..13372ae Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..04e285f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Dec 28 10:00:20 PST 2015 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..9d82f78 --- /dev/null +++ b/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/img/phone.png b/img/phone.png new file mode 100755 index 0000000..8075a06 Binary files /dev/null and b/img/phone.png differ diff --git a/phoneedittext/.gitignore b/phoneedittext/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/phoneedittext/.gitignore @@ -0,0 +1 @@ +/build diff --git a/phoneedittext/build.gradle b/phoneedittext/build.gradle new file mode 100644 index 0000000..950b33a --- /dev/null +++ b/phoneedittext/build.gradle @@ -0,0 +1,30 @@ +apply plugin: 'com.android.library' +apply plugin: 'com.github.dcendents.android-maven' + +group='com.github.leoxnidas.phoneedittext' +version='1.0' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.2" + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_6 + targetCompatibility JavaVersion.VERSION_1_6 + } +} + diff --git a/phoneedittext/proguard-rules.pro b/phoneedittext/proguard-rules.pro new file mode 100644 index 0000000..9df8379 --- /dev/null +++ b/phoneedittext/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /home/joker/Android/Sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/phoneedittext/src/main/AndroidManifest.xml b/phoneedittext/src/main/AndroidManifest.xml new file mode 100644 index 0000000..de502d3 --- /dev/null +++ b/phoneedittext/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/Codes.java b/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/Codes.java new file mode 100644 index 0000000..d5adcf6 --- /dev/null +++ b/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/Codes.java @@ -0,0 +1,979 @@ +package com.github.leoxnidas.phoneedittext; + + + +public class Codes { + public static final int AFG = 1; + public static final int ALB = 2; + public static final int DZA = 3; + public static final int ASM = 4; + public static final int AND = 5; + public static final int AGO = 6; + public static final int AIA = 7; + public static final int ATA = 8; + public static final int ATG = 9; + public static final int ARG = 10; + public static final int ARM = 11; + public static final int ABW = 12; + public static final int AUS = 13; + public static final int AUT = 14; + public static final int AZE = 15; + public static final int BHS = 16; + public static final int BHR = 17; + public static final int BGD = 18; + public static final int BRB = 19; + public static final int BLR = 20; + public static final int BEL = 21; + public static final int BLZ = 22; + public static final int BEN = 23; + public static final int BMU = 24; + public static final int BTN = 25; + public static final int BOL = 26; + public static final int BIH = 27; + public static final int BWA = 28; + public static final int BRA = 29; + public static final int IOT = 30; + public static final int VGB = 31; + public static final int BRN = 32; + public static final int BGR = 33; + public static final int BFA = 34; + public static final int BDI = 35; + public static final int KHM = 36; + public static final int CMR = 37; + public static final int CAN = 38; + public static final int CPV = 39; + public static final int CYM = 40; + public static final int CAF = 41; + public static final int TCD = 42; + public static final int CHL = 43; + public static final int CHN = 44; + public static final int CXR = 45; + public static final int CCK = 46; + public static final int COL = 47; + public static final int COM = 48; + public static final int COK = 49; + public static final int CRI = 50; + public static final int HRV = 51; + public static final int CUB = 52; + public static final int CUW = 53; + public static final int CYP = 54; + public static final int CZE = 55; + public static final int COD = 56; + public static final int DNK = 57; + public static final int DJI = 58; + public static final int DMA = 59; + public static final int DOM = 60; + public static final int TLS = 61; + public static final int ECU = 62; + public static final int EGY = 63; + public static final int SLV = 64; + public static final int GNQ = 65; + public static final int ERI = 66; + public static final int EST = 67; + public static final int ETH = 68; + public static final int FLK = 69; + public static final int FRO = 70; + public static final int FJI = 71; + public static final int FIN = 72; + public static final int FRA = 73; + public static final int PYF = 74; + public static final int GAB = 75; + public static final int GMB = 76; + public static final int GEO = 77; + public static final int DEU = 78; + public static final int GHA = 79; + public static final int GIB = 80; + public static final int GRC = 81; + public static final int GRL = 82; + public static final int GRD = 83; + public static final int GUM = 84; + public static final int GTM = 85; + public static final int GGY = 86; + public static final int GIN = 87; + public static final int GNB = 88; + public static final int GUY = 89; + public static final int HTI = 90; + public static final int HND = 91; + public static final int HKG = 92; + public static final int HUN = 93; + public static final int ISL = 94; + public static final int IND = 95; + public static final int IDN = 96; + public static final int IRN = 97; + public static final int IRQ = 98; + public static final int IRL = 99; + public static final int IMN = 100; + public static final int ISR = 101; + public static final int ITA = 102; + public static final int CIV = 103; + public static final int JAM = 104; + public static final int JPN = 105; + public static final int JEY = 106; + public static final int JOR = 107; + public static final int KAZ = 108; + public static final int KEN = 109; + public static final int KIR = 110; + public static final int XKX = 111; + public static final int KWT = 112; + public static final int KGZ = 113; + public static final int LAO = 114; + public static final int LVA = 115; + public static final int LBN = 116; + public static final int LSO = 117; + public static final int LBR = 118; + public static final int LBY = 119; + public static final int LIE = 120; + public static final int LTU = 121; + public static final int LUX = 122; + public static final int MAC = 123; + public static final int MKD = 124; + public static final int MDG = 125; + public static final int MWI = 126; + public static final int MYS = 127; + public static final int MDV = 128; + public static final int MLI = 129; + public static final int MLT = 130; + public static final int MHL = 131; + public static final int MRT = 132; + public static final int MUS = 133; + public static final int MYT = 134; + public static final int MEX = 135; + public static final int FSM = 136; + public static final int MDA = 137; + public static final int MCO = 138; + public static final int MNG = 139; + public static final int MNE = 140; + public static final int MSR = 141; + public static final int MAR = 142; + public static final int MOZ = 143; + public static final int MMR = 144; + public static final int NAM = 145; + public static final int NRU = 146; + public static final int NPL = 147; + public static final int NLD = 148; + public static final int ANT = 149; + public static final int NCL = 150; + public static final int NZL = 151; + public static final int NIC = 152; + public static final int NER = 153; + public static final int NGA = 154; + public static final int NIU = 155; + public static final int PRK = 156; + public static final int MNP = 157; + public static final int NOR = 158; + public static final int OMN = 159; + public static final int PAK = 160; + public static final int PLW = 161; + public static final int PSE = 162; + public static final int PAN = 163; + public static final int PNG = 164; + public static final int PRY = 165; + public static final int PER = 166; + public static final int PHL = 167; + public static final int PCN = 168; + public static final int POL = 169; + public static final int PRT = 170; + public static final int PRI = 171; + public static final int QAT = 172; + public static final int COG = 173; + public static final int REU = 174; + public static final int ROU = 175; + public static final int RUS = 176; + public static final int RWA = 177; + public static final int BLM = 178; + public static final int SHN = 179; + public static final int KNA = 180; + public static final int LCA = 181; + public static final int MAF = 182; + public static final int SPM = 183; + public static final int VCT = 184; + public static final int WSM = 185; + public static final int SMR = 186; + public static final int STP = 187; + public static final int SAU = 188; + public static final int SEN = 189; + public static final int SRB = 190; + public static final int SYC = 191; + public static final int SLE = 192; + public static final int SGP = 193; + public static final int SXM = 194; + public static final int SVK = 195; + public static final int SVN = 196; + public static final int SLB = 197; + public static final int SOM = 198; + public static final int ZAF = 199; + public static final int KOR = 200; + public static final int SSD = 201; + public static final int ESP = 202; + public static final int LKA = 203; + public static final int SDN = 204; + public static final int SUR = 205; + public static final int SJM = 206; + public static final int SWZ = 207; + public static final int SWE = 208; + public static final int CHE = 209; + public static final int SYR = 210; + public static final int TWN = 211; + public static final int TJK = 212; + public static final int TZA = 213; + public static final int THA = 214; + public static final int TGO = 215; + public static final int TKL = 216; + public static final int TON = 217; + public static final int TTO = 218; + public static final int TUN = 219; + public static final int TUR = 220; + public static final int TKM = 221; + public static final int TCA = 222; + public static final int TUV = 223; + public static final int VIR = 224; + public static final int UGA = 225; + public static final int UKR = 226; + public static final int ARE = 227; + public static final int GBR = 228; + public static final int USA = 229; + public static final int URY = 230; + public static final int UZB = 231; + public static final int VUT = 232; + public static final int VAT = 233; + public static final int VEN = 234; + public static final int VNM = 235; + public static final int WLF = 236; + public static final int ESH = 237; + public static final int YEM = 238; + public static final int ZMB = 239; + public static final int ZWE = 240; + + public static String asString(int code) { + switch (code) { + case AFG: + return "93"; + case ALB: + return "355"; + case DZA: + return "213"; + case ASM: + return "1684"; + case AND: + return "376"; + case AGO: + return "244"; + case AIA: + return "1264"; + case ATA: + return "672"; + case ATG: + return "1268"; + case ARG: + return "54"; + case ARM: + return "374"; + case ABW: + return "297"; + case AUS: + return "61"; + case AUT: + return "43"; + case AZE: + return "994"; + case BHS: + return "1242"; + case BHR: + return "973"; + case BGD: + return "880"; + case BRB: + return "1246"; + case BLR: + return "375"; + case BEL: + return "32"; + case BLZ: + return "501"; + case BEN: + return "229"; + case BMU: + return "1441"; + case BTN: + return "975"; + case BOL: + return "591"; + case BIH: + return "387"; + case BWA: + return "267"; + case BRA: + return "55"; + case IOT: + return "246"; + case VGB: + return "1284"; + case BRN: + return "673"; + case BGR: + return "359"; + case BFA: + return "226"; + case BDI: + return "257"; + case KHM: + return "855"; + case CMR: + return "237"; + case USA: + case CAN: + return "1"; + case CPV: + return "238"; + case CYM: + return "1345"; + case CAF: + return "236"; + case TCD: + return "235"; + case CHL: + return "56"; + case CHN: + return "86"; + case CXR: + case CCK: + return "61"; + case COL: + return "57"; + case COM: + return "269"; + case COK: + return "682"; + case CRI: + return "506"; + case HRV: + return "385"; + case CUB: + return "53"; + case CUW: + return "599"; + case CYP: + return "357"; + case CZE: + return "420"; + case COD: + return "243"; + case DNK: + return "45"; + case DJI: + return "253"; + case DMA: + return "1767"; + case DOM: + return "1809"; + case TLS: + return "670"; + case ECU: + return "593"; + case EGY: + return "20"; + case SLV: + return "503"; + case GNQ: + return "240"; + case ERI: + return "291"; + case EST: + return "372"; + case ETH: + return "251"; + case FLK: + return "500"; + case FRO: + return "298"; + case FJI: + return "679"; + case FIN: + return "358"; + case FRA: + return "33"; + case PYF: + return "689"; + case GAB: + return "241"; + case GMB: + return "220"; + case GEO: + return "995"; + case DEU: + return "49"; + case GHA: + return "233"; + case GIB: + return "350"; + case GRC: + return "30"; + case GRL: + return "299"; + case GRD: + return "1473"; + case GUM: + return "1671"; + case GTM: + return "502"; + case GGY: + return "441481"; + case GIN: + return "224"; + case GNB: + return "245"; + case GUY: + return "592"; + case HTI: + return "509"; + case HND: + return "504"; + case HKG: + return "852"; + case HUN: + return "36"; + case ISL: + return "354"; + case IND: + return "91"; + case IDN: + return "62"; + case IRN: + return "98"; + case IRQ: + return "964"; + case IRL: + return "353"; + case IMN: + return "441624"; + case ISR: + return "972"; + case ITA: + return "39"; + case CIV: + return "225"; + case JAM: + return "1876"; + case JPN: + return "81"; + case JEY: + return "441534"; + case JOR: + return "962"; + case KAZ: + return "7"; + case KEN: + return "254"; + case KIR: + return "686"; + case XKX: + return "383"; + case KWT: + return "965"; + case KGZ: + return "996"; + case LAO: + return "856"; + case LVA: + return "371"; + case LBN: + return "961"; + case LSO: + return "266"; + case LBR: + return "231"; + case LBY: + return "218"; + case LIE: + return "423"; + case LTU: + return "370"; + case LUX: + return "352"; + case MAC: + return "853"; + case MKD: + return "389"; + case MDG: + return "261"; + case MWI: + return "265"; + case MYS: + return "60"; + case MDV: + return "960"; + case MLI: + return "223"; + case MLT: + return "356"; + case MHL: + return "692"; + case MRT: + return "222"; + case MUS: + return "230"; + case MYT: + return "262"; + case MEX: + return "52"; + case FSM: + return "691"; + case MDA: + return "373"; + case MCO: + return "377"; + case MNG: + return "976"; + case MNE: + return "382"; + case MSR: + return "1664"; + case MAR: + return "212"; + case MOZ: + return "258"; + case MMR: + return "95"; + case NAM: + return "264"; + case NRU: + return "674"; + case NPL: + return "977"; + case NLD: + return "31"; + case ANT: + return "599"; + case NCL: + return "687"; + case NZL: + return "64"; + case NIC: + return "505"; + case NER: + return "227"; + case NGA: + return "234"; + case NIU: + return "683"; + case PRK: + return "850"; + case MNP: + return "1670"; + case NOR: + return "47"; + case OMN: + return "968"; + case PAK: + return "92"; + case PLW: + return "680"; + case PSE: + return "970"; + case PAN: + return "507"; + case PNG: + return "675"; + case PRY: + return "595"; + case PER: + return "51"; + case PHL: + return "63"; + case PCN: + return "64"; + case POL: + return "48"; + case PRT: + return "351"; + case PRI: + return "1939"; + case QAT: + return "974"; + case COG: + return "242"; + case REU: + return "262"; + case ROU: + return "40"; + case RUS: + return "7"; + case RWA: + return "250"; + case BLM: + return "590"; + case SHN: + return "290"; + case KNA: + return "1869"; + case LCA: + return "1758"; + case MAF: + return "590"; + case SPM: + return "508"; + case VCT: + return "1784"; + case WSM: + return "685"; + case SMR: + return "378"; + case STP: + return "239"; + case SAU: + return "966"; + case SEN: + return "221"; + case SRB: + return "381"; + case SYC: + return "248"; + case SLE: + return "232"; + case SGP: + return "65"; + case SXM: + return "1721"; + case SVK: + return "421"; + case SVN: + return "386"; + case SLB: + return "677"; + case SOM: + return "252"; + case ZAF: + return "27"; + case KOR: + return "82"; + case SSD: + return "211"; + case ESP: + return "34"; + case LKA: + return "94"; + case SDN: + return "249"; + case SUR: + return "597"; + case SJM: + return "47"; + case SWZ: + return "268"; + case SWE: + return "46"; + case CHE: + return "41"; + case SYR: + return "963"; + case TWN: + return "886"; + case TJK: + return "992"; + case TZA: + return "255"; + case THA: + return "66"; + case TGO: + return "228"; + case TKL: + return "690"; + case TON: + return "676"; + case TTO: + return "1868"; + case TUN: + return "216"; + case TUR: + return "90"; + case TKM: + return "993"; + case TCA: + return "1649"; + case TUV: + return "688"; + case VIR: + return "1340"; + case UGA: + return "256"; + case UKR: + return "380"; + case ARE: + return "971"; + case GBR: + return "44"; + case URY: + return "598"; + case UZB: + return "998"; + case VUT: + return "678"; + case VAT: + return "379"; + case VEN: + return "58"; + case VNM: + return "84"; + case WLF: + return "681"; + case ESH: + return "212"; + case YEM: + return "967"; + case ZMB: + return "260"; + case ZWE: + return "263"; + default: + return null; + } + } + + public static boolean isCodeValid(int code) { + switch (code) { + case ASM: + case AND: + case AGO: + case AIA: + case ATA: + case ATG: + case ARG: + case ARM: + case ABW: + case AUS: + case AUT: + case AZE: + case BHS: + case BHR: + case BGD: + case BRB: + case BLR: + case BEL: + case BLZ: + case BEN: + case BMU: + case BTN: + case BOL: + case BIH: + case BWA: + case BRA: + case IOT: + case VGB: + case BRN: + case BGR: + case BFA: + case BDI: + case KHM: + case CMR: + case CAN: + case CPV: + case CYM: + case CAF: + case TCD: + case CHL: + case CHN: + case CXR: + case CCK: + case COL: + case COM: + case COK: + case CRI: + case HRV: + case CUB: + case CUW: + case CYP: + case CZE: + case COD: + case DNK: + case DJI: + case DMA: + case DOM: + case TLS: + case ECU: + case EGY: + case SLV: + case GNQ: + case ERI: + case EST: + case ETH: + case FLK: + case FRO: + case FJI: + case FIN: + case FRA: + case PYF: + case GAB: + case GMB: + case GEO: + case DEU: + case GHA: + case GIB: + case GRC: + case GRL: + case GRD: + case GUM: + case GTM: + case GGY: + case GIN: + case GNB: + case GUY: + case HTI: + case HND: + case HKG: + case HUN: + case ISL: + case IND: + case IDN: + case IRN: + case IRQ: + case IRL: + case IMN: + case ISR: + case ITA: + case CIV: + case JAM: + case JPN: + case JEY: + case JOR: + case KAZ: + case KEN: + case KIR: + case XKX: + case KWT: + case KGZ: + case LAO: + case LVA: + case LBN: + case LSO: + case LBR: + case LBY: + case LIE: + case LTU: + case LUX: + case MAC: + case MKD: + case MDG: + case MWI: + case MYS: + case MDV: + case MLI: + case MLT: + case MHL: + case MRT: + case MUS: + case MYT: + case MEX: + case FSM: + case MDA: + case MCO: + case MNG: + case MNE: + case MSR: + case MAR: + case MOZ: + case MMR: + case NAM: + case NRU: + case NPL: + case NLD: + case ANT: + case NCL: + case NZL: + case NIC: + case NER: + case NGA: + case NIU: + case PRK: + case MNP: + case NOR: + case OMN: + case PAK: + case PLW: + case PSE: + case PAN: + case PNG: + case PRY: + case PER: + case PHL: + case PCN: + case POL: + case PRT: + case PRI: + case QAT: + case COG: + case REU: + case ROU: + case RUS: + case RWA: + case BLM: + case SHN: + case KNA: + case LCA: + case MAF: + case SPM: + case VCT: + case WSM: + case SMR: + case STP: + case SAU: + case SEN: + case SRB: + case SYC: + case SLE: + case SGP: + case SXM: + case SVK: + case SVN: + case SLB: + case SOM: + case ZAF: + case KOR: + case SSD: + case ESP: + case LKA: + case SDN: + case SUR: + case SJM: + case SWZ: + case SWE: + case CHE: + case SYR: + case TWN: + case TJK: + case TZA: + case THA: + case TGO: + case TKL: + case TON: + case TTO: + case TUN: + case TUR: + case TKM: + case TCA: + case TUV: + case VIR: + case UGA: + case UKR: + case ARE: + case GBR: + case USA: + case URY: + case UZB: + case VUT: + case VAT: + case VEN: + case VNM: + case WLF: + case ESH: + case YEM: + case ZMB: + case ZWE: + case DZA: + case ALB: + case AFG: + return true; + default: + return false; + } + } +} diff --git a/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/PhoneEditText.java b/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/PhoneEditText.java new file mode 100644 index 0000000..3512db8 --- /dev/null +++ b/phoneedittext/src/main/java/com/github/leoxnidas/phoneedittext/PhoneEditText.java @@ -0,0 +1,90 @@ +package com.github.leoxnidas.phoneedittext; + +import android.content.Context; +import android.content.res.TypedArray; +import android.text.Editable; +import android.text.InputType; +import android.text.Selection; +import android.text.TextWatcher; +import android.util.AttributeSet; +import android.widget.EditText; + + +public class PhoneEditText extends EditText { + + private int p_mCode; + private String p_mCodeStr; + private String PLUS = "+"; + + public PhoneEditText(Context context, AttributeSet attrs) { + super(context, attrs); + initPhoneEditText(attrs); + + // no matter what kind of input type developer will use + // always, phone input type shall be used. + setInputType(-1); + addTextChangedListener(new PhoneEditTextWatcher()); + setText((PLUS + Codes.asString(p_mCode))); + } + + private void initPhoneEditText (AttributeSet attrs) { + TypedArray typedArray = getContext().getTheme() + .obtainStyledAttributes(attrs, R.styleable.PhoneEditText, 0, 0); + + try { + p_mCode = typedArray.getInt(R.styleable.PhoneEditText_code, -1); + } finally { + typedArray.recycle(); + } + + if(p_mCode == -1) + setCode(Codes.USA); + + setCode(p_mCode); + } + + public void setCode(int code) { + if(Codes.isCodeValid(code)) { + p_mCode = code; + p_mCodeStr = Codes.asString(code); + setText((PLUS + p_mCodeStr)); + } else { + throw new RuntimeException("International code does not exists."); + } + } + + public int getCode() { + return p_mCode; + } + + @Override + public void setInputType(int type) { + super.setInputType(InputType.TYPE_CLASS_PHONE); + } + + @Override + public void addTextChangedListener(TextWatcher watcher) { + if(watcher instanceof PhoneEditTextWatcher) { + super.addTextChangedListener(watcher); + } else { + throw new RuntimeException("textwatcher object should be a PhoneEditTextWatcher object or a child of it."); + } + } + + private class PhoneEditTextWatcher implements TextWatcher { + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) {} + + @Override + public void afterTextChanged(Editable s) { + if(s.length() < (1 + p_mCodeStr.length())) + setText((PLUS + p_mCodeStr)); + Selection.setSelection(s, s.length()); + } + } + +} diff --git a/phoneedittext/src/main/res/values/attrs.xml b/phoneedittext/src/main/res/values/attrs.xml new file mode 100644 index 0000000..b1c06e9 --- /dev/null +++ b/phoneedittext/src/main/res/values/attrs.xml @@ -0,0 +1,247 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..d30ba40 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app', ':phoneedittext'