Skip to content

Commit d981385

Browse files
committed
Minor Bugs Fixed. DIAL_CODE getter added
1 parent 5dfd54e commit d981385

File tree

4 files changed

+38
-10
lines changed

4 files changed

+38
-10
lines changed

app/build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
apply plugin: 'com.android.application'
2-
1+
apply plugin: 'com.android.library'
32
android {
43
compileSdkVersion 28
54
defaultConfig {
6-
applicationId "com.asdev.myapplication"
5+
76
minSdkVersion 21
87
targetSdkVersion 28
98
versionCode 1
@@ -12,9 +11,12 @@ android {
1211
}
1312
buildTypes {
1413
release {
15-
minifyEnabled false
14+
minifyEnabled true
1615
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
1716
}
17+
debug {
18+
minifyEnabled false
19+
}
1820
}
1921
}
2022

@@ -27,4 +29,5 @@ dependencies {
2729
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
2830
implementation 'com.android.support:support-compat:28.0.0'
2931
implementation 'com.google.android.material:material:1.1.0-alpha09'
32+
implementation 'com.asdev.PhoneEditText-Android:PhoneEditText-Android:1.0.2'
3033
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
}
99
dependencies {
1010
classpath 'com.android.tools.build:gradle:3.4.2'
11-
11+
classpath 'com.novoda:bintray-release:0.9.1'
1212
// NOTE: Do not place your application dependencies here; they belong
1313
// in the individual module build.gradle files
1414
}

phoneedittext/build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
apply plugin: 'com.android.library'
2+
apply plugin: 'com.novoda.bintray-release'
3+
4+
publish {
5+
userOrg = 'amannirala13'
6+
groupId = 'com.asdev.PhoneEditText-Android'
7+
artifactId = 'PhoneEditText-Android'
8+
publishVersion = '1.0.2'
9+
repoName = 'PhoneEditText-Android'
10+
desc = 'Get automatic country code ready EditText for your Phone number field. This EditText detects country code automatically and sets it into the EditText.'
11+
website = 'https://github.com/amannirala13/PhoneEditText-Android'
12+
}
213

314
android {
415
compileSdkVersion 28
@@ -16,13 +27,17 @@ android {
1627

1728
buildTypes {
1829
release {
19-
minifyEnabled false
30+
minifyEnabled true
2031
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2132
}
33+
debug {
34+
minifyEnabled false
35+
}
2236
}
2337

2438
}
2539

40+
2641
dependencies {
2742
implementation fileTree(dir: 'libs', include: ['*.jar'])
2843

@@ -33,4 +48,5 @@ dependencies {
3348
implementation 'com.android.support:support-compat:28.0.0'
3449
implementation 'com.google.android.material:material:1.1.0-alpha09'
3550

51+
3652
}

phoneedittext/src/main/java/com/asdev/phoneedittext/PhoneEditText.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.asdev.phoneedittext;
22

33
import android.content.Context;
4+
import android.graphics.Rect;
45
import android.telephony.TelephonyManager;
56
import android.util.AttributeSet;
67

@@ -9,6 +10,9 @@
910
import com.google.android.material.textfield.TextInputEditText;
1011

1112
public class PhoneEditText extends TextInputEditText {
13+
14+
public String DIAL_CODE;
15+
1216
public PhoneEditText(Context context) {
1317
super(context);
1418
}
@@ -22,11 +26,10 @@ public PhoneEditText(Context context, AttributeSet attrs, int defStyleAttr) {
2226
}
2327

2428
@Override
25-
public OnFocusChangeListener getOnFocusChangeListener() {
26-
return super.getOnFocusChangeListener();
27-
29+
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
30+
super.onFocusChanged(focused, direction, previouslyFocusedRect);
31+
set_country_code(this);
2832
}
29-
3033
//Sets country code to the phone text
3134
private void set_country_code(TextInputEditText phoneText) {
3235
if (!new check().countryCodeExisting(phoneText)) {
@@ -35,6 +38,8 @@ private void set_country_code(TextInputEditText phoneText) {
3538
TelephonyManager tm = (TelephonyManager) this.getContext().getSystemService(Context.TELEPHONY_SERVICE);
3639
String countryCodeValue = tm.getNetworkCountryIso();
3740

41+
DIAL_CODE = "+" +(new countryCode().getDialCode(countryCodeValue));
42+
3843
if (phoneText.getText().length() <= 0)
3944
phoneText.setText("+" +(new countryCode().getDialCode(countryCodeValue)) + " ");
4045
else if (phoneText.getText().charAt(0) == '+')
@@ -47,4 +52,8 @@ else if (phoneText.getText().charAt(0) == '+')
4752

4853
}
4954
}
55+
56+
public String getDIAL_CODE() {
57+
return DIAL_CODE;
58+
}
5059
}

0 commit comments

Comments
 (0)