diff --git a/.gradle/5.4.1/executionHistory/executionHistory.bin b/.gradle/5.4.1/executionHistory/executionHistory.bin
index 165b5aa..e2ccaa0 100644
Binary files a/.gradle/5.4.1/executionHistory/executionHistory.bin and b/.gradle/5.4.1/executionHistory/executionHistory.bin differ
diff --git a/.gradle/5.4.1/executionHistory/executionHistory.lock b/.gradle/5.4.1/executionHistory/executionHistory.lock
index f47ee1a..fccf3c2 100644
Binary files a/.gradle/5.4.1/executionHistory/executionHistory.lock and b/.gradle/5.4.1/executionHistory/executionHistory.lock differ
diff --git a/.gradle/5.4.1/fileHashes/fileHashes.bin b/.gradle/5.4.1/fileHashes/fileHashes.bin
index 345f7ca..96affda 100644
Binary files a/.gradle/5.4.1/fileHashes/fileHashes.bin and b/.gradle/5.4.1/fileHashes/fileHashes.bin differ
diff --git a/.gradle/5.4.1/fileHashes/fileHashes.lock b/.gradle/5.4.1/fileHashes/fileHashes.lock
index d319e07..326aa65 100644
Binary files a/.gradle/5.4.1/fileHashes/fileHashes.lock and b/.gradle/5.4.1/fileHashes/fileHashes.lock differ
diff --git a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin
index fb84e90..2dd9656 100644
Binary files a/.gradle/5.4.1/fileHashes/resourceHashesCache.bin and b/.gradle/5.4.1/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/5.4.1/javaCompile/classAnalysis.bin b/.gradle/5.4.1/javaCompile/classAnalysis.bin
index 9615f02..7c93f03 100644
Binary files a/.gradle/5.4.1/javaCompile/classAnalysis.bin and b/.gradle/5.4.1/javaCompile/classAnalysis.bin differ
diff --git a/.gradle/5.4.1/javaCompile/jarAnalysis.bin b/.gradle/5.4.1/javaCompile/jarAnalysis.bin
index 47b0b75..15e75ff 100644
Binary files a/.gradle/5.4.1/javaCompile/jarAnalysis.bin and b/.gradle/5.4.1/javaCompile/jarAnalysis.bin differ
diff --git a/.gradle/5.4.1/javaCompile/javaCompile.lock b/.gradle/5.4.1/javaCompile/javaCompile.lock
index e4a17df..e87e60f 100644
Binary files a/.gradle/5.4.1/javaCompile/javaCompile.lock and b/.gradle/5.4.1/javaCompile/javaCompile.lock differ
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
index 9606aa6..e1549ce 100644
Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index ef32326..40cda36 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -11,6 +11,7 @@
+
@@ -18,8 +19,9 @@
-
-
+
+
+
@@ -45,11 +47,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -63,11 +99,35 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
@@ -79,18 +139,15 @@
-
+
- en
- Anh
- name_code="us"
English
countryc
50dp
@@ -104,7 +161,6 @@
bm
jm
ms
- vg
ag
do
gd
@@ -116,8 +172,12 @@
sx
tc
tt
- 1
vc
+ vg
+ 1
+ vi
+ mCountryPicked
+ mLanguageCode
@@ -142,7 +202,6 @@
-
@@ -153,16 +212,18 @@
-
-
+
+
+
+
-
+
@@ -178,10 +239,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -344,11 +438,11 @@
-
+
-
+
@@ -361,10 +455,10 @@
-
+
-
+
@@ -376,56 +470,68 @@
+
+
+
+
+ file://$PROJECT_DIR$/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt
+ 18
+
+
+
+
+ file://$PROJECT_DIR$/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt
+ 28
+
+
+
+
+
+
- mCountries
+ countryCodePicker.getCountry(Locale.getDefault().country)
kotlin
EXPRESSION
- getFlagMasterResID(country)
+ country
kotlin
EXPRESSION
- country
+ Locale.getDefault().country
kotlin
EXPRESSION
- "ccp_$languageCode"
+ mCountries
kotlin
EXPRESSION
- xmlPullParser.name
+ getFlagMasterResID(country)
kotlin
EXPRESSION
- xmlPullParser.
+ "ccp_$languageCode"
kotlin
EXPRESSION
- xmlPullParser.END_TAG
+ xmlPullParser.name
kotlin
EXPRESSION
- xmlPullParser.getAttributeValue(
- null,
- "country"
- )
+ xmlPullParser.
kotlin
EXPRESSION
- xmlPullParser.getAttributeValue(
- null,
- "phone_code"
- )
+ xmlPullParser.END_TAG
kotlin
EXPRESSION
@@ -505,14 +611,6 @@
-
-
-
-
-
-
-
-
@@ -520,20 +618,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -585,34 +669,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
+
+
+
+
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
-
-
+
+
diff --git a/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt b/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt
index 7666faa..4b48547 100644
--- a/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt
+++ b/app/src/main/java/com/ccc/countrycodepicker/MainActivity.kt
@@ -14,6 +14,8 @@ class MainActivity : AppCompatActivity(), OnCountryPickedListener {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
+ countryCodePicker.setLanguageCode(Locale.getDefault().language)
+ countryCodePicker.refreshDefaultData()
countryCodePicker.setCountryPicked(countryCodePicker.getCountry(Locale.getDefault().country))
}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index de952fc..fc9938e 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -14,7 +14,6 @@
android:layout_height="50dp"
app:flagHeight="24dp"
app:flagWidth="24dp"
- app:langCode="vi"
app:showPhoneCode="false"
android:onClick="onPickerClick"
/>
diff --git a/ccp/src/main/java/com/ccc/ccp/Country.kt b/ccp/src/main/java/com/ccc/ccp/Country.kt
index fe434fe..ee371ac 100644
--- a/ccp/src/main/java/com/ccc/ccp/Country.kt
+++ b/ccp/src/main/java/com/ccc/ccp/Country.kt
@@ -59,7 +59,7 @@ data class Country(
} catch (e: Exception) {
Log.e(TAG, "error", e)
}
- return countries.sortedBy { it.name }
+ return countries.sortedBy { it.name.removeAccent() }
}
fun getFlagMasterResID(countryCode: Country): Int {
diff --git a/ccp/src/main/java/com/ccc/ccp/StringExtension.kt b/ccp/src/main/java/com/ccc/ccp/StringExtension.kt
new file mode 100644
index 0000000..f0fb894
--- /dev/null
+++ b/ccp/src/main/java/com/ccc/ccp/StringExtension.kt
@@ -0,0 +1,11 @@
+package com.ccc.ccp
+
+import java.text.Normalizer
+import java.util.regex.Pattern
+
+fun String.removeAccent(): String {
+ val temp = Normalizer.normalize(this, Normalizer.Form.NFD)
+ val pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+")
+ return pattern.matcher(temp).replaceAll("").replace('đ', 'd')
+ .replace('Đ', 'D')
+}