Skip to content
This repository was archived by the owner on Jul 27, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
011f63e
- Added method to get country name.
Sep 27, 2015
7b6e515
- Remove unused Http import
Sep 27, 2015
1ccb7fb
- Fix bug
Sep 27, 2015
5d4788e
Remove ignored files
Sep 28, 2015
c019c33
Remove ignored files
Sep 28, 2015
896b45e
Added various helper methods
Feb 17, 2016
dce20c5
Update plugins
Aug 6, 2016
bd3a80f
Ignore /idea and *.iml
Aug 6, 2016
7c140a5
Merge branch 'master-upstream'
Aug 6, 2016
b1a1e8f
Fixed merging errors
Aug 6, 2016
efbfd78
Add round flag options (programatically)
Aug 6, 2016
44476ca
Downgrade gradle distribution.
Aug 6, 2016
8fc7887
Upgrade gradle version, add maven plugin.
Aug 6, 2016
ad244c2
ImageView: use srcCompat
Aug 7, 2016
67fedf4
Fix inflater
Aug 7, 2016
6f18dbc
Pass radius as parameter
Aug 8, 2016
af4bf97
Pass radius as parameter (fixed constructor in dialog)
Aug 8, 2016
6f2d23c
Test cropping
Aug 8, 2016
4bd720f
Enable radius input
Aug 8, 2016
960839a
Output bitmap size fix
Aug 8, 2016
d9c6ba5
New crop function
Aug 8, 2016
47628ee
Fix source region
Aug 8, 2016
c0c1fde
Fix source region #2
Aug 10, 2016
77c8578
Fix source region #3
Aug 10, 2016
67764f9
Fix source region #4
Aug 11, 2016
cd1f2c0
Remove unnecessary casting
Aug 11, 2016
dbc1890
Anti-aliasing, deprecate _r resources, remove unused imports.
Aug 11, 2016
3b2a474
Static radius
Aug 11, 2016
d50c4e2
Remove radius, fix adapter initializer.
Aug 11, 2016
30203cf
Remove round flag resources and getter method.
Aug 11, 2016
47cb407
Merge branch 'master-upstream'
Aug 24, 2016
4336f44
Merge branch 'master-upstream'
Oct 5, 2016
1cc4f5d
Update to latest support library and gradle & sdk build tools
Oct 5, 2016
4ce297d
Add recycler view adapter with callback,
Nov 19, 2016
5629e28
Remove old files.
Jun 1, 2017
3fda5a8
Directory restructuring & library updates.
Jun 1, 2017
79c91c2
Version update
Jun 1, 2017
cfe06fa
Call scrollToHeadingCountry during onStart.
Jun 1, 2017
a7b650d
Update readme
Jun 1, 2017
18627b9
Code formatting
Jun 1, 2017
8dbb7d6
Include "_flag" string as part of getFlagResId (renamed)
Jun 4, 2017
ecca530
getFlagResId throws exception
Jun 4, 2017
4bde4f3
Add missing ab_flag.png
Jun 4, 2017
9393bf0
Remove transparency and compress png's
Jun 4, 2017
2cab112
Implements new adapter with searching, refactored code. INCOMPATIBLE …
Jun 5, 2017
e38d005
Version bump
Jun 5, 2017
48ae52e
Update readme
Jun 5, 2017
17c63dd
Read me fix
Jun 5, 2017
3cb091e
Read me fix
Jun 5, 2017
95a95e8
Refactoring
Jun 5, 2017
ebe874d
Version bump
Jun 5, 2017
8a6d17f
Import fix
Jun 5, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ wear/wear.iml
android.iml
country-picker.iml
hs_err_pid*
Android-country-picker.iml
/.idea
.idea/
*.iml
23 changes: 5 additions & 18 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Android country picker
Android Country Picker
====================

## Features
Expand All @@ -12,26 +12,13 @@ See the example to see more detail.

## How to install

You can install this dependency by downloading the source code or directly via gradle
with the help of [jitpack](https://jitpack.io/private#heetch/Android-country-picker/1.0.6)
`compile 'io.xsor:countrypicker:0.3'`

## How to use

To show CountryPicker as a dialog:

```java
CountryPickerDialog countryPicker =
new CountryPickerDialog(mContext, new CountryPickerCallbacks() {
@Override
public void onCountrySelected(Country country, int flagResId) {
// TODO handle callback
}
});
countryPicker.show();
```
See [sample app main activity](https://github.com/xsorifc28/CountryPicker/blob/master/sample/src/main/java/io/xsor/countrypickersample/MainActivity.java).

If you want to retrieve a flag res outside of the country picker dialog
use `Utils.getMipmapResId(Context context, String drawableName)` where
the drawable have to be formatted as follow: `countryIsoCodeInLowerCase_flag`.
For example:
`Utils.getMipmapResId(mContext, "fr_flag")`
the drawable have to be formatted as follow: `countryIsoCodeInLowerCase`.
`Utils.getMipmapResId(mContext, "fr")`
36 changes: 11 additions & 25 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,33 +1,19 @@
apply plugin: 'com.github.ben-manes.versions'

buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}

apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
minSdkVersion 10
targetSdkVersion 22
versionCode 106
versionName "1.0.6"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
allprojects {
repositories {
jcenter()
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
}
1 change: 1 addition & 0 deletions countrypicker/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
114 changes: 114 additions & 0 deletions countrypicker/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: "com.jfrog.bintray"

version = "0.4"

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 14
targetSdkVersion 25
versionCode 4
versionName version

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.github.wrdlbrnft:sorted-list-adapter:0.2.0.19'
}

def siteUrl = 'https://github.com/xsorifc28/CountryPicker' // Homepage URL of the library
def gitUrl = 'https://github.com/xsorifc28/CountryPicker.git' // Git repository URL
group = "io.xsor" // Maven Group ID for the artifact

install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'

// Add your description here
name 'io.xsor.countrypicker'
description = 'Country Picker Library'
url siteUrl

// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'xsor'
name 'Samed Ozdemir'
email '[email protected]'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")

configurations = ['archives']
pkg {
repo = "countrypicker"
name = "countrypicker"
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
version {
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password")
//Optional. The passphrase for GPG signing'
}
}
}
}
17 changes: 17 additions & 0 deletions countrypicker/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in C:\Users\Samed\AppData\Local\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 *;
#}
11 changes: 11 additions & 0 deletions countrypicker/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.xsor.countrypicker">

<application
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true">

</application>

</manifest>
Binary file added countrypicker/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions countrypicker/src/main/java/io/xsor/countrypicker/Country.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package io.xsor.countrypicker;


import android.support.annotation.NonNull;
import com.github.wrdlbrnft.sortedlistadapter.SortedListAdapter;
import java.util.Locale;

@SuppressWarnings("unused")
public class Country implements SortedListAdapter.ViewModel {

private String isoCode;
private String dialingCode = "-1";

public Country() {}

public Country(String isoCode, String dialingCode) {
this.isoCode = isoCode.toLowerCase();
this.dialingCode = dialingCode;
}

public String getIsoCode() {
return isoCode;
}

public void setIsoCode(String isoCode) {
this.isoCode = isoCode;
}

public String getDialingCode() {
return dialingCode;
}

public void setDialingCode(String dialingCode) {
this.dialingCode = dialingCode;
}

public int getDialingCodeInt() {
return Integer.parseInt(dialingCode);
}

public String getCountryName() {
return new Locale(Locale.getDefault().getLanguage(), this.getIsoCode()).getDisplayCountry();

}

@Override
public <T> boolean isSameModelAs(@NonNull T item) {
if (item instanceof Country) {
final Country other = (Country) item;
return other.getIsoCode().equals(isoCode);
}
return false;
}

@Override
public <T> boolean isContentTheSameAs(@NonNull T item) {
if (item instanceof Country) {
final Country other = (Country) item;
return isoCode != null ? isoCode.equals(other.getIsoCode()) : other.getIsoCode() == null &&
dialingCode != null ? getDialingCodeInt() == other.getDialingCodeInt() : other
.getDialingCodeInt() > -1;
}
return false;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

Country country = (Country) o;

return isoCode.equals(country.getIsoCode());

}

@Override
public int hashCode() {
return isoCode.hashCode();
}
}
Loading