Skip to content

Commit

Permalink
update ktlint and other deps
Browse files Browse the repository at this point in the history
  • Loading branch information
hbb20 committed Dec 30, 2023
1 parent 79bf923 commit e64ef2b
Show file tree
Hide file tree
Showing 59 changed files with 5,091 additions and 4,992 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

[*.kt]
# Recommended is 100 but some action names are very long that can not fit in the limit.
# 120 seems to be a sweet point for this project
# In general length should be 100 so added visual guide should help
max_line_length=120
ij_visual_guides =100,120
ktlint_function_naming_ignore_when_annotated_with=Composable
ktlint_standard_no-wildcard-imports = disabled


[*Test.kt]
max_line_length=off
ktlint_function_naming_ignore_when_annotated_with=Composable
ktlint_standard_no-wildcard-imports = disabled

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
not find required country in the preferred countries so that section is of no use when searching.
Although, preferred country will continue to show up in regular filtered list if matches for
query. @hbb20
- Add support to JetPack Compose @hbb20
- Out of box composables for Material2 @hbb20

## v0.0.7 2022-01

Expand Down
39 changes: 20 additions & 19 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,38 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = BuildData.appJavaVersion
targetCompatibility = BuildData.appJavaVersion
}

composeOptions {
kotlinCompilerExtensionVersion = Versions.COMPOSE_COMPILER
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = BuildData.appJavaVersion.toString()
}

packagingOptions {
packaging {
jniLibs {
excludes += setOf("META-INF/licenses/**")
}
resources {
excludes += setOf(
"META-INF/DEPENDENCIES",
"META-INF/LICENSE",
"META-INF/LICENSE.txt",
"META-INF/license.txt",
"META-INF/licenses/**",
"META-INF/NOTICE",
"META-INF/NOTICE.txt",
"META-INF/notice.txt",
"META-INF/ASL2.0",
"META-INF/AL2.0",
"META-INF/*.kotlin_module",
"META-INF/LGPL2.1",
"**/attach_hotspot_windows.dll"
)
excludes +=
setOf(
"META-INF/DEPENDENCIES",
"META-INF/LICENSE",
"META-INF/LICENSE.txt",
"META-INF/license.txt",
"META-INF/licenses/**",
"META-INF/NOTICE",
"META-INF/NOTICE.txt",
"META-INF/notice.txt",
"META-INF/ASL2.0",
"META-INF/AL2.0",
"META-INF/*.kotlin_module",
"META-INF/LGPL2.1",
"**/attach_hotspot_windows.dll",
)
}
}
namespace = "com.hbb20.androidcountrypicker"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.hbb20.countrypicker.view.prepareCustomCountryPickerView

class CountryPickerViewDemoActivity : AppCompatActivity() {
lateinit var binding: ActivityCountryPickerViewDemoBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityCountryPickerViewDemoBinding.inflate(layoutInflater)
Expand All @@ -41,8 +42,8 @@ class CountryPickerViewDemoActivity : AppCompatActivity() {
binding.cpFlagPack.changeFlagProvider(
CPFlagImageProvider(
FlagPack1.alpha2ToFlag,
FlagPack1.missingFlagPlaceHolder
)
FlagPack1.missingFlagPlaceHolder,
),
)
binding.cpNoFlag.changeFlagProvider(null)
}
Expand All @@ -58,7 +59,7 @@ class CountryPickerViewDemoActivity : AppCompatActivity() {
containerViewGroup = customCPContainer,
tvSelectedCountryInfo = customCPSelectedCountryTextView,
tvSelectedCountryEmojiFlag = customCPEmojiTextView,
initialSelection = CPViewConfig.InitialSelection.AutoDetectCountry()
initialSelection = CPViewConfig.InitialSelection.AutoDetectCountry(),
) { selectedCountry: CPCountry? ->
// listen to change through callback
// your code to handle selected country
Expand All @@ -74,19 +75,20 @@ class CountryPickerViewDemoActivity : AppCompatActivity() {
val customCPSelectedCountryTextView = findViewById<TextView>(R.id.tvSelectedCountry)
val customCPEmojiTextView = findViewById<TextView>(R.id.tvSelectedCountryEmojiFlag)

val cpViewHelper = prepareCustomCountryPickerView(
containerViewGroup = customCPContainer,
tvSelectedCountryInfo = customCPSelectedCountryTextView,
tvSelectedCountryEmojiFlag = customCPEmojiTextView
)
val cpViewHelper =
prepareCustomCountryPickerView(
containerViewGroup = customCPContainer,
tvSelectedCountryInfo = customCPSelectedCountryTextView,
tvSelectedCountryEmojiFlag = customCPEmojiTextView,
)

// observe live data
cpViewHelper.selectedCountry.observe(
lifecycleOwner,
{ selectedCountry: CPCountry? ->
// observe live data
// your code to handle selected country
}
},
)

// Modify CPViewConfig if you need. Access cpViewConfig through `cpViewHelper`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.hbb20.countrypicker.recyclerview.loadCountries

class CustomRecyclerViewActivity : AppCompatActivity() {
lateinit var binding: ActivityCustomRecyclerViewBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityCustomRecyclerViewBinding.inflate(layoutInflater)
Expand All @@ -22,7 +23,6 @@ class CustomRecyclerViewActivity : AppCompatActivity() {
}

private fun setupRecyclerView() {

val primaryTextGenerator = { cpCountry: CPCountry ->
"${cpCountry.name} (${cpCountry.alpha3})"
}
Expand All @@ -35,21 +35,22 @@ class CustomRecyclerViewActivity : AppCompatActivity() {
"+${cpCountry.phoneCode}"
}

val cpListConfig = CPListConfig(
preferredCountryCodes = "IN,US,NZ,AU"
)
val cpListConfig =
CPListConfig(
preferredCountryCodes = "IN,US,NZ,AU",
)

binding.recyclerView.loadCountries { selectedCountry: CPCountry ->
// your code to handle selected country
}

binding.recyclerView.loadCountries(
preferredCountryCodes = "IN,US,NZ,AU"
preferredCountryCodes = "IN,US,NZ,AU",
) { selectedCountry ->
Toast.makeText(this, selectedCountry.name, Toast.LENGTH_SHORT).show()
}

val dataFileReader = CPDataStoreGenerator.defaultCountryFileReader
val dataFileReader = CPDataStoreGenerator.DEFAULT_FILE_READER
val customFlagImageProvider = CPRowConfig.defaultFlagProvider

// binding.recyclerView.loadCountries { selectedCountry: CPCountry ->
Expand Down Expand Up @@ -80,13 +81,17 @@ class CustomRecyclerViewActivity : AppCompatActivity() {
// See CPDataStore for available configuration
val cpDataStore = CPDataStoreGenerator.generate(this)

val cpRecyclerViewHelper = CPRecyclerViewHelper(
cpDataStore = cpDataStore, // required
cpListConfig = cpListConfig, // Default: CPListConfig()
cpRowConfig = cpRowConfig // Default: CPRowConfig()
) { selectedCountry: CPCountry ->
// required: handle selected country
}
val cpRecyclerViewHelper =
CPRecyclerViewHelper(
// required
cpDataStore = cpDataStore,
// Default: CPListConfig()
cpListConfig = cpListConfig,
// Default: CPRowConfig()
cpRowConfig = cpRowConfig,
) { selectedCountry: CPCountry ->
// required: handle selected country
}

// attach recyclerView to show list in recyclerView
cpRecyclerViewHelper.attachRecyclerView(binding.recyclerView)
Expand All @@ -107,13 +112,17 @@ class CustomRecyclerViewActivity : AppCompatActivity() {
// Check CPRowConfig for available configuration
val cpRowConfig: CPRowConfig = CPRowConfig()

val cpRecyclerViewHelper = CPRecyclerViewHelper(
cpDataStore = cpDataStore, // required
cpListConfig = cpListConfig, // Default: CPListConfig()
cpRowConfig = cpRowConfig // Default: CPRowConfig()
) { selectedCountry: CPCountry ->
// required: handle selected country
}
val cpRecyclerViewHelper =
CPRecyclerViewHelper(
// required
cpDataStore = cpDataStore,
// Default: CPListConfig()
cpListConfig = cpListConfig,
// Default: CPRowConfig()
cpRowConfig = cpRowConfig,
) { selectedCountry: CPCountry ->
// required: handle selected country
}

// attach recyclerView to show list in recyclerView
cpRecyclerViewHelper.attachRecyclerView(binding.recyclerView)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.hbb20.androidcountrypicker

import android.app.Application
import timber.log.Timber

class DemoApplication : Application() {

override fun onCreate() {
super.onCreate()
// if (BuildConfig.DEBUG) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.hbb20.countrypicker.models.CPCountry

class MainActivity : AppCompatActivity() {
lateinit var binding: ActivityMainBinding

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
Expand All @@ -30,8 +31,8 @@ class MainActivity : AppCompatActivity() {
countryPicker.changeFlagProvider(
CPFlagImageProvider(
FlagPack1.alpha2ToFlag,
FlagPack1.missingFlagPlaceHolder
)
FlagPack1.missingFlagPlaceHolder,
),
)
}

Expand Down
Loading

0 comments on commit e64ef2b

Please sign in to comment.