-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b77611
commit f334798
Showing
286 changed files
with
1,035 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# FastCountryCode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.github.dcendents.android-maven' | ||
version='1' | ||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion "30.0.3" | ||
|
||
defaultConfig { | ||
minSdkVersion 19 | ||
targetSdkVersion 30 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'androidx.appcompat:appcompat:1.3.0' | ||
implementation 'com.google.android.material:material:1.4.0' | ||
testImplementation 'junit:junit:4.+' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# 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 *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
26 changes: 26 additions & 0 deletions
26
fast_country_code/src/androidTest/java/com/fastcountrycode/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.fastcountrycode; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
assertEquals("com.fastcountrycode.test", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.fastcountrycode"> | ||
|
||
</manifest> |
100 changes: 100 additions & 0 deletions
100
fast_country_code/src/main/java/com/fastcountrycode/Adapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.fastcountrycode; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ImageView; | ||
import android.widget.LinearLayout; | ||
import android.widget.TextView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Locale; | ||
|
||
|
||
public class Adapter extends RecyclerView.Adapter<Adapter.Holder> { | ||
|
||
private List<Country> data; | ||
CountryPickerListener countryPickerListener; | ||
|
||
@SuppressWarnings("WeakerAccess") | ||
protected class Holder extends RecyclerView.ViewHolder { | ||
private View root; | ||
TextView code; | ||
|
||
Holder(View itemView) { | ||
super(itemView); | ||
root = itemView; | ||
|
||
code = itemView.findViewById(R.id.code); | ||
|
||
|
||
} | ||
} | ||
|
||
public Adapter(List<Country> data) { | ||
this.data = data; | ||
|
||
} | ||
|
||
@SuppressWarnings("WeakerAccess") | ||
public void setData(@Nullable List<Country> data) { | ||
this.data.addAll(data); | ||
notifyDataSetChanged(); | ||
} | ||
|
||
@Override | ||
public int getItemCount() { | ||
return (isEmpty()) ? 0 : data.size(); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | ||
return new Holder(LayoutInflater.from(parent.getContext()).inflate(R.layout.card_country_code, parent, false)); | ||
} | ||
|
||
private boolean isEmpty() { | ||
return data == null || data.isEmpty(); | ||
} | ||
|
||
@SuppressLint("SetTextI18n") | ||
@Override | ||
public void onBindViewHolder(@NonNull Holder holder, int position) { | ||
|
||
Country country = data.get(position); | ||
holder.code.setText(country.getName()); | ||
holder.root.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
if (countryPickerListener != null) { | ||
countryPickerListener.onSelectCountry(country); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
public void search(String text) { | ||
this.data.clear(); | ||
for (Country country : this.data) { | ||
if (country.getName().toLowerCase(Locale.ENGLISH).contains(text.toLowerCase())) { | ||
this.data.add(country); | ||
} | ||
} | ||
this.notifyDataSetChanged(); | ||
} | ||
|
||
public CountryPickerListener getCountryPickerListener() { | ||
return countryPickerListener; | ||
} | ||
|
||
public void setCountryPickerListener(CountryPickerListener countryPickerListener) { | ||
this.countryPickerListener = countryPickerListener; | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
fast_country_code/src/main/java/com/fastcountrycode/BottomSheetCountryCode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
package com.fastcountrycode; | ||
|
||
import android.content.Context; | ||
import android.os.Bundle; | ||
import android.text.Editable; | ||
import android.text.TextWatcher; | ||
import android.view.View; | ||
import android.widget.EditText; | ||
import android.widget.ImageView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.recyclerview.widget.LinearLayoutManager; | ||
import androidx.recyclerview.widget.RecyclerView; | ||
|
||
import com.google.android.material.bottomsheet.BottomSheetDialog; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Locale; | ||
|
||
public class BottomSheetCountryCode extends BottomSheetDialog { | ||
RecyclerView list_country_code; | ||
EditText search_country; | ||
Adapter adapter; | ||
List<Country> countriesList = new ArrayList<>(); | ||
List<Country> selectedCountriesList = new ArrayList<>(); | ||
ImageView close; | ||
|
||
public BottomSheetCountryCode(@NonNull Context context) { | ||
super(context, R.style.SheetDialog); | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.country_code_layout); | ||
setCountriesList(Country.getAllCountries()); | ||
init(); | ||
setAdapter(); | ||
} | ||
|
||
public void init() { | ||
list_country_code = findViewById(R.id.list_country_code); | ||
search_country = findViewById(R.id.search_country); | ||
close = findViewById(R.id.close); | ||
close.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
dismiss(); | ||
} | ||
}); | ||
|
||
} | ||
|
||
public void setAdapter() { | ||
this.selectedCountriesList = new ArrayList(this.countriesList.size()); | ||
this.selectedCountriesList.addAll(this.countriesList); | ||
adapter = new Adapter(selectedCountriesList); | ||
list_country_code.setLayoutManager(new LinearLayoutManager(getContext())); | ||
list_country_code.setAdapter(adapter); | ||
search_country.addTextChangedListener(new 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) { | ||
search(s.toString()); | ||
} | ||
}); | ||
|
||
} | ||
|
||
public Adapter getAdapter() { | ||
return adapter; | ||
} | ||
|
||
private void search(String text) { | ||
this.selectedCountriesList.clear(); | ||
for (Country country : this.countriesList) { | ||
if (country.getName().toLowerCase(Locale.ENGLISH).contains(text.toLowerCase())) { | ||
this.selectedCountriesList.add(country); | ||
} | ||
} | ||
|
||
this.adapter.notifyDataSetChanged(); | ||
} | ||
|
||
public void setCountriesList(List<Country> newCountries) { | ||
this.countriesList.clear(); | ||
this.countriesList.addAll(newCountries); | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.