Skip to content

Commit dcd27e2

Browse files
committed
detach specific dependency and just put map for external flag provider
1 parent b4a7ebd commit dcd27e2

File tree

28 files changed

+73
-132
lines changed

28 files changed

+73
-132
lines changed

CHANGELOG.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

4-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
6+
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
67

78
## [Next Release]
9+
10+
## v0.0.4 2021-07-14
11+
12+
- Option to include flagPack
13+
814
## v0.0.3 2021-06-23
15+
916
- Fix crash on non-material theme
1017

1118
## v0.0.2 2021-04-13
12-
- Publish to MavenCentral with artifact id `android-country-picker`
13-
- Remove `jCenter()` usage
1419

20+
- Publish to MavenCentral with artifact id `android-country-picker`
21+
- Remove `jCenter()` usage
1522

1623
## v0.0.1
1724
- Basic functionality

app/src/main/java/com/hbb20/androidcountrypicker/MainActivity.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity
77
import com.hbb20.CountryPickerView
88
import com.hbb20.androidcountrypicker.databinding.ActivityMainBinding
99
import com.hbb20.contrypicker.flagpack1.FlagPack1
10+
import com.hbb20.countrypicker.flagprovider.CPFlagImageProvider
1011
import com.hbb20.countrypicker.models.CPCountry
1112

1213
class MainActivity : AppCompatActivity() {
@@ -25,7 +26,12 @@ class MainActivity : AppCompatActivity() {
2526
countryPicker.cpViewHelper.cpViewConfig.viewTextGenerator = { cpCountry: CPCountry ->
2627
cpCountry.alpha2
2728
}
28-
countryPicker.changeFlagProvider(FlagPack1)
29+
countryPicker.changeFlagProvider(
30+
CPFlagImageProvider(
31+
FlagPack1.alpha2ToFlag,
32+
FlagPack1.missingFlagPlaceHolder
33+
)
34+
)
2935
}
3036

3137
private fun refreshView() {

app/src/main/java/com/hbb20/androidcountrypicker/OpenDialogDirectlyActivity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ class OpenDialogDirectlyActivity : AppCompatActivity() {
1313
}
1414

1515
fun openCPDialog(view: View) {
16-
launchCountryPickerDialog { selectedCountry ->
16+
launchCountryPickerDialog(
17+
customMasterCountries = "IN,PK,US",
18+
allowSearch = false
19+
) { selectedCountry ->
1720
Toast.makeText(
1821
this,
1922
selectedCountry?.alpha2,

app/src/main/res/values/styles.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<resources>
22

33
<!-- Base application theme. -->
4-
<style name="AppTheme" parent="Theme.AppCompat.DayNight">
4+
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.Bridge">
55
<!-- Customize your theme here. -->
66
<item name="colorPrimary">@color/colorPrimary</item>
77
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
}
1111

1212
dependencies {
13-
classpath("com.android.tools.build:gradle:4.2.2")
13+
classpath("com.android.tools.build:gradle:7.0.0")
1414
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.KOTLIN_GRADLE}")
1515
classpath("org.jlleitschuh.gradle:ktlint-gradle:${Versions.KTLINT_GRADLE}")
1616
classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.0.0")

countrypicker/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,4 @@ dependencies {
3939
implementation(Deps.timber)
4040
implementEpoxy()
4141
implementTesting()
42-
apiProject("flagprovider")
4342
}

countrypicker/gradle.properties

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
GROUP=com.hbb20
21
POM_ARTIFACT_ID=android-country-picker
32
POM_NAME=AndroidCountryPicker
4-
POM_PACKAGING=aar
5-
POM_DESCRIPTION=Android Country Picker (CP) is an android library which provides an easy way to search and select country.
6-
POM_INCEPTION_YEAR=2021
7-
POM_URL=https://github.com/hbb20/AndroidCountryPicker
8-
POM_SCM_URL=https://github.com/hbb20/AndroidCountryPicker
9-
POM_SCM_CONNECTION=scm:[email protected]:hbb20/AndroidCountryPicker.git
10-
POM_SCM_DEV_CONNECTION=scm:[email protected]:hbb20/AndroidCountryPicker.git
11-
POM_LICENCE_NAME=MIT
12-
POM_LICENCE_URL=https://github.com/hbb20/AndroidCountryPicker/blob/develop/LICENSE
13-
POM_LICENCE_DIST=repo
14-
POM_DEVELOPER_ID=hbb20
15-
POM_DEVELOPER_NAME=Harsh Bhakta
16-
POM_DEVELOPER_URL=https://github.com/hbb20
17-
VERSION_NAME=0.0.3
18-
# ./gradlew countrypicker:uploadArchives --no-daemon --no-parallel -i
3+
POM_DESCRIPTION=Android Country Picker (CP) is an android library which provides an easy way to search and select country.

countrypicker/src/main/java/com/hbb20/CountryPickerView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import android.view.ViewGroup
77
import android.widget.ImageView
88
import android.widget.TextView
99
import androidx.constraintlayout.widget.ConstraintLayout
10-
import com.hbb20.contrypicker.flagprovider.CPFlagProvider
1110
import com.hbb20.countrypicker.R
1211
import com.hbb20.countrypicker.config.CPRowConfig
1312
import com.hbb20.countrypicker.datagenerator.CPDataStoreGenerator
13+
import com.hbb20.countrypicker.flagprovider.CPFlagProvider
1414
import com.hbb20.countrypicker.helper.readDialogConfigFromAttrs
1515
import com.hbb20.countrypicker.helper.readListConfigFromAttrs
1616
import com.hbb20.countrypicker.helper.readViewConfigFromAttrs

countrypicker/src/main/java/com/hbb20/countrypicker/config/CPRowConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.hbb20.countrypicker.config
22

3-
import com.hbb20.contrypicker.flagprovider.CPFlagProvider
4-
import com.hbb20.contrypicker.flagprovider.DefaultEmojiFlagProvider
3+
import com.hbb20.countrypicker.flagprovider.CPFlagProvider
4+
import com.hbb20.countrypicker.flagprovider.DefaultEmojiFlagProvider
55
import com.hbb20.countrypicker.models.CPCountry
66

77
data class CPRowConfig(

countrypicker/src/main/java/com/hbb20/countrypicker/config/CPViewConfig.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.hbb20.countrypicker.config
22

3-
import com.hbb20.contrypicker.flagprovider.CPFlagProvider
4-
import com.hbb20.contrypicker.flagprovider.DefaultEmojiFlagProvider
3+
import com.hbb20.countrypicker.flagprovider.CPFlagProvider
4+
import com.hbb20.countrypicker.flagprovider.DefaultEmojiFlagProvider
55
import com.hbb20.countrypicker.helper.CPCountryDetector.Source
66
import com.hbb20.countrypicker.models.CPCountry
77

countrypicker/src/main/java/com/hbb20/countrypicker/dialog/CPDialogExtension.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.hbb20.countrypicker.dialog
22

33
import android.content.Context
4-
import com.hbb20.contrypicker.flagprovider.CPFlagProvider
54
import com.hbb20.countrypicker.config.CPDialogConfig
65
import com.hbb20.countrypicker.config.CPDialogViewIds
76
import com.hbb20.countrypicker.config.CPListConfig
87
import com.hbb20.countrypicker.config.CPRowConfig
98
import com.hbb20.countrypicker.datagenerator.CPDataStoreGenerator
109
import com.hbb20.countrypicker.datagenerator.CountryFileReading
10+
import com.hbb20.countrypicker.flagprovider.CPFlagProvider
1111
import com.hbb20.countrypicker.models.CPCountry
1212
import com.hbb20.countrypicker.models.CPDataStore
1313
import com.hbb20.countrypicker.recyclerview.defaultDataStoreModifier

flagprovider/src/main/java/com/hbb20/contrypicker/flagprovider/CPFlagProvider.kt renamed to countrypicker/src/main/java/com/hbb20/countrypicker/flagprovider/CPFlagProvider.kt

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package com.hbb20.contrypicker.flagprovider
1+
package com.hbb20.countrypicker.flagprovider
22

33
import androidx.annotation.DrawableRes
44

5-
sealed class CPFlagProvider
5+
abstract class CPFlagProvider
66

77
/**
88
* If you wish to useEmojiCompat = true then make sure to enable emoji-compat in your app using
@@ -11,10 +11,16 @@ sealed class CPFlagProvider
1111
*/
1212
class DefaultEmojiFlagProvider(val useEmojiCompat: Boolean = false) : CPFlagProvider()
1313

14-
abstract class CPFlagImageProvider : CPFlagProvider() {
15-
16-
abstract val alpha2ToFlag: Map<String, Int>
17-
abstract val missingFlagPlaceHolder: Int
14+
/**
15+
* [alpha2ToFlag] is map of alpha 2 code to drawable res of flag
16+
* [missingFlagPlaceHolder] is shown for country for which flag is not found in [alpha2ToFlag].
17+
* Ideally [missingFlagPlaceHolder] should be transparent image and it's size should match size of
18+
* other flags in this pack to maintain visual symmetry.
19+
*/
20+
class CPFlagImageProvider(
21+
val alpha2ToFlag: Map<String, Int>,
22+
@DrawableRes val missingFlagPlaceHolder: Int
23+
) : CPFlagProvider() {
1824

1925
@DrawableRes
2026
fun getFlag(alpha2Code: String): Int {

countrypicker/src/main/java/com/hbb20/countrypicker/recyclerview/CPRecyclerViewExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package com.hbb20.countrypicker.recyclerview
22

33
import android.widget.EditText
44
import androidx.recyclerview.widget.RecyclerView
5-
import com.hbb20.contrypicker.flagprovider.CPFlagProvider
65
import com.hbb20.countrypicker.config.CPListConfig
76
import com.hbb20.countrypicker.config.CPRowConfig
87
import com.hbb20.countrypicker.datagenerator.CPDataStoreGenerator
98
import com.hbb20.countrypicker.datagenerator.CountryFileReading
9+
import com.hbb20.countrypicker.flagprovider.CPFlagProvider
1010
import com.hbb20.countrypicker.logger.logMethodEnd
1111
import com.hbb20.countrypicker.logger.onMethodBegin
1212
import com.hbb20.countrypicker.models.CPCountry

countrypicker/src/main/java/com/hbb20/countrypicker/recyclerview/CountryRow.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import com.airbnb.epoxy.AfterPropsSet
1010
import com.airbnb.epoxy.CallbackProp
1111
import com.airbnb.epoxy.ModelProp
1212
import com.airbnb.epoxy.ModelView
13-
import com.hbb20.contrypicker.flagprovider.CPFlagImageProvider
14-
import com.hbb20.contrypicker.flagprovider.DefaultEmojiFlagProvider
1513
import com.hbb20.countrypicker.R
1614
import com.hbb20.countrypicker.config.CPRowConfig
1715
import com.hbb20.countrypicker.databinding.CpCountryRowBinding
16+
import com.hbb20.countrypicker.flagprovider.CPFlagImageProvider
17+
import com.hbb20.countrypicker.flagprovider.DefaultEmojiFlagProvider
1818
import com.hbb20.countrypicker.models.CPCountry
1919

2020
@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_WRAP_HEIGHT)

countrypicker/src/main/java/com/hbb20/countrypicker/view/CPViewExtension.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import android.content.Context
44
import android.view.ViewGroup
55
import android.widget.ImageView
66
import android.widget.TextView
7-
import com.hbb20.contrypicker.flagprovider.CPFlagProvider
87
import com.hbb20.countrypicker.config.*
98
import com.hbb20.countrypicker.datagenerator.CPDataStoreGenerator
109
import com.hbb20.countrypicker.datagenerator.CountryFileReading
10+
import com.hbb20.countrypicker.flagprovider.CPFlagProvider
1111
import com.hbb20.countrypicker.models.CPCountry
1212
import com.hbb20.countrypicker.models.CPDataStore
1313
import com.hbb20.countrypicker.recyclerview.defaultDataStoreModifier

countrypicker/src/main/java/com/hbb20/countrypicker/view/CPViewHelper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import androidx.core.view.isVisible
88
import androidx.emoji.text.EmojiCompat
99
import androidx.lifecycle.LiveData
1010
import androidx.lifecycle.MutableLiveData
11-
import com.hbb20.contrypicker.flagprovider.CPFlagImageProvider
12-
import com.hbb20.contrypicker.flagprovider.DefaultEmojiFlagProvider
1311
import com.hbb20.countrypicker.config.CPDialogConfig
1412
import com.hbb20.countrypicker.config.CPListConfig
1513
import com.hbb20.countrypicker.config.CPRowConfig
1614
import com.hbb20.countrypicker.config.CPViewConfig
1715
import com.hbb20.countrypicker.datagenerator.CPDataStoreGenerator
1816
import com.hbb20.countrypicker.dialog.CPDialogHelper
17+
import com.hbb20.countrypicker.flagprovider.CPFlagImageProvider
18+
import com.hbb20.countrypicker.flagprovider.DefaultEmojiFlagProvider
1919
import com.hbb20.countrypicker.helper.CPCountryDetector
2020
import com.hbb20.countrypicker.models.CPCountry
2121
import com.hbb20.countrypicker.models.CPDataStore

flagpack1/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ dependencies {
3737
implementation(Deps.timber)
3838
implementEpoxy()
3939
implementTesting()
40-
implementProject("flagprovider")
4140
}

flagpack1/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
POM_ARTIFACT_ID=android-country-picker-flagpack1
2+
POM_NAME=AndroidCountryPickerFlagPack1
3+
POM_DESCRIPTION=Flag Pack that can be included with android country picker

flagpack1/src/main/java/com/hbb20/contrypicker/flagpack1/FlagPack1.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
package com.hbb20.contrypicker.flagpack1
22

33
import androidx.annotation.DrawableRes
4-
import com.hbb20.contrypicker.flagprovider.CPFlagImageProvider
54

6-
object FlagPack1 : CPFlagImageProvider() {
7-
override val missingFlagPlaceHolder: Int = R.drawable.flag_transparent
8-
override val alpha2ToFlag = mapOf<String, @DrawableRes Int>(
5+
object FlagPack1 {
6+
val missingFlagPlaceHolder: Int = R.drawable.flag_transparent
7+
val alpha2ToFlag = mapOf<String, @DrawableRes Int>(
98
"ad" to R.drawable.flag_andorra,
109
"ae" to R.drawable.flag_uae,
1110
"af" to R.drawable.flag_afghanistan,

flagprovider/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

flagprovider/build.gradle.kts

Lines changed: 0 additions & 40 deletions
This file was deleted.

flagprovider/consumer-rules.pro

Whitespace-only changes.

flagprovider/proguard-rules.pro

Lines changed: 0 additions & 21 deletions
This file was deleted.

flagprovider/src/main/AndroidManifest.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

flagprovider/src/test/java/com/hbb20/contrypicker/flagprovider/ExampleUnitTest.kt

Lines changed: 0 additions & 16 deletions
This file was deleted.

gradle.properties

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,20 @@ android.useAndroidX=true
1919
android.enableJetifier=true
2020
# Kotlin code style for this project: "official" or "obsolete":
2121
kotlin.code.style=official
22+
# artifact info
23+
GROUP=com.hbb20
24+
POM_PACKAGING=aar
25+
POM_INCEPTION_YEAR=2021
26+
POM_URL=https://github.com/hbb20/AndroidCountryPicker
27+
POM_SCM_URL=https://github.com/hbb20/AndroidCountryPicker
28+
POM_SCM_CONNECTION=scm:[email protected]:hbb20/AndroidCountryPicker.git
29+
POM_SCM_DEV_CONNECTION=scm:[email protected]:hbb20/AndroidCountryPicker.git
30+
POM_LICENCE_NAME=MIT
31+
POM_LICENCE_URL=https://github.com/hbb20/AndroidCountryPicker/blob/develop/LICENSE
32+
POM_LICENCE_DIST=repo
33+
POM_DEVELOPER_ID=hbb20
34+
POM_DEVELOPER_NAME=Harsh Bhakta
35+
POM_DEVELOPER_URL=https://github.com/hbb20
36+
VERSION_NAME=0.0.4
37+
# ./gradlew countrypicker:uploadArchives --no-daemon --no-parallel -i
38+
# ./gradlew flagpack1:uploadArchives --no-daemon --no-parallel -i

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https://services.gradle.org/distributions/gradle-6.7.1-all.zip
6+
distributionUrl=https://services.gradle.org/distributions/gradle-7.0.2-all.zip

settings.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
include ':app', ':countrypicker'
22
include ':flagpack1'
3-
include ':flagprovider'

0 commit comments

Comments
 (0)