Skip to content

Commit 7fff273

Browse files
committed
feat: setup package visibility restrictions for certain libs
Only expose the public interface to accessor, leaving the implementation details to be handled via DI Signed-off-by: Brandon McAnsh <[email protected]>
1 parent b4f57c8 commit 7fff273

File tree

53 files changed

+573
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+573
-43
lines changed

apps/codeApp/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ android {
112112

113113
dependencies {
114114
// libs (not included with services)
115-
implementation(project(":libs:locale"))
116-
implementation(project(":libs:vibrator"))
115+
implementation(project(":libs:locale:public"))
116+
implementation(project(":libs:vibrator:public"))
117117
implementation(project(":libs:messaging"))
118-
implementation(project(":libs:permissions"))
118+
implementation(project(":libs:permissions:public"))
119119
implementation(project(":libs:quickresponse"))
120120
implementation(project(":libs:requests"))
121121

apps/flipchatApp/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ dependencies {
118118
implementation(project(":services:flipchat:sdk"))
119119

120120
implementation(project(":libs:datetime"))
121-
implementation(project(":libs:locale"))
122-
implementation(project(":libs:vibrator"))
121+
implementation(project(":libs:locale:public"))
122+
implementation(project(":libs:vibrator:public"))
123123
implementation(project(":libs:encryption:ed25519"))
124124
implementation(project(":libs:encryption:keys"))
125125
implementation(project(":libs:encryption:mnemonic"))
@@ -129,9 +129,9 @@ dependencies {
129129
implementation(project(":libs:logging"))
130130
implementation(project(":libs:messaging"))
131131
implementation(project(":libs:network:exchange"))
132-
implementation(project(":libs:network:connectivity"))
132+
implementation(project(":libs:network:connectivity:public"))
133133
implementation(project(":libs:opengraph"))
134-
implementation(project(":libs:permissions"))
134+
implementation(project(":libs:permissions:public"))
135135
implementation(project(":libs:quickresponse"))
136136
implementation(project(":libs:requests"))
137137
implementation(project(":ui:components"))
File renamed without changes.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
plugins {
2+
id(Plugins.android_library)
3+
id(Plugins.kotlin_android)
4+
id(Plugins.kotlin_serialization)
5+
id(Plugins.kotlin_kapt)
6+
id(Plugins.hilt)
7+
}
8+
9+
android {
10+
namespace = "${Android.codeNamespace}.util.locale"
11+
compileSdk = Android.compileSdkVersion
12+
defaultConfig {
13+
minSdk = Android.minSdkVersion
14+
targetSdk = Android.targetSdkVersion
15+
buildToolsVersion = Android.buildToolsVersion
16+
testInstrumentationRunner = Android.testInstrumentationRunner
17+
}
18+
19+
kotlinOptions {
20+
jvmTarget = Versions.java
21+
freeCompilerArgs += listOf(
22+
"-opt-in=kotlin.ExperimentalUnsignedTypes",
23+
"-opt-in=kotlin.RequiresOptIn"
24+
)
25+
}
26+
27+
java {
28+
toolchain {
29+
languageVersion.set(JavaLanguageVersion.of(Versions.java))
30+
}
31+
}
32+
}
33+
34+
dependencies {
35+
implementation(project(":libs:locale:impl"))
36+
api(project(":libs:locale:public"))
37+
38+
implementation(Libs.hilt)
39+
kapt(Libs.hilt_android_compiler)
40+
kapt(Libs.hilt_compiler)
41+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.getcode.util.locale
2+
3+
import dagger.Binds
4+
import dagger.Module
5+
import dagger.hilt.InstallIn
6+
import dagger.hilt.components.SingletonComponent
7+
import javax.inject.Singleton
8+
9+
@Module
10+
@InstallIn(SingletonComponent::class)
11+
abstract class LocaleModule {
12+
13+
@Binds
14+
@Singleton
15+
abstract fun bindLocaleHelper(impl: AndroidLocale): LocaleHelper
16+
}
File renamed without changes.

libs/locale/build.gradle.kts renamed to libs/locale/impl/build.gradle.kts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id(Plugins.android_library)
33
id(Plugins.kotlin_android)
44
id(Plugins.kotlin_serialization)
5+
id(Plugins.kotlin_kapt)
56
}
67

78
android {
@@ -14,13 +15,6 @@ android {
1415
testInstrumentationRunner = Android.testInstrumentationRunner
1516
}
1617

17-
buildFeatures {
18-
compose = true
19-
}
20-
21-
composeOptions {
22-
kotlinCompilerExtensionVersion = Versions.compose_compiler
23-
}
2418

2519
kotlinOptions {
2620
jvmTarget = Versions.java
@@ -38,14 +32,15 @@ android {
3832
}
3933

4034
dependencies {
35+
api(project(":libs:locale:public"))
4136
implementation(project(":libs:datetime"))
4237
implementation(project(":libs:currency"))
4338
api(Libs.androidx_annotation)
4439
api(Libs.kotlin_stdlib)
4540
api(Libs.kotlinx_coroutines_core)
4641
api(Libs.kotlinx_coroutines_rx3)
4742

48-
implementation(platform(Libs.compose_bom))
49-
implementation(Libs.compose_ui)
50-
implementation(Libs.compose_foundation)
43+
implementation(Libs.hilt)
44+
kapt(Libs.hilt_android_compiler)
45+
kapt(Libs.hilt_compiler)
5146
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.getcode.util.locale
2+
3+
import android.content.Context
4+
import com.getcode.model.Currency
5+
import dagger.hilt.android.qualifiers.ApplicationContext
6+
import javax.inject.Inject
7+
8+
class AndroidLocale @Inject constructor(
9+
@ApplicationContext private val context: Context,
10+
private val currencyUtils: com.getcode.utils.CurrencyUtils,
11+
): LocaleHelper {
12+
override fun getDefaultCurrencyName(): String {
13+
return LocaleUtils.getDefaultCurrency(context)
14+
}
15+
16+
override fun getDefaultCurrency(): Currency? {
17+
return currencyUtils.getCurrency(getDefaultCurrencyName())
18+
}
19+
20+
override fun getDefaultCountry(): String {
21+
return LocaleUtils.getDefaultCountry(context)
22+
}
23+
}

libs/locale/public/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
.gradle/
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
plugins {
2+
id(Plugins.android_library)
3+
id(Plugins.kotlin_android)
4+
id(Plugins.kotlin_serialization)
5+
}
6+
7+
android {
8+
namespace = "${Android.codeNamespace}.util.locale"
9+
compileSdk = Android.compileSdkVersion
10+
defaultConfig {
11+
minSdk = Android.minSdkVersion
12+
targetSdk = Android.targetSdkVersion
13+
buildToolsVersion = Android.buildToolsVersion
14+
testInstrumentationRunner = Android.testInstrumentationRunner
15+
}
16+
17+
kotlinOptions {
18+
jvmTarget = Versions.java
19+
freeCompilerArgs += listOf(
20+
"-opt-in=kotlin.ExperimentalUnsignedTypes",
21+
"-opt-in=kotlin.RequiresOptIn"
22+
)
23+
}
24+
25+
java {
26+
toolchain {
27+
languageVersion.set(JavaLanguageVersion.of(Versions.java))
28+
}
29+
}
30+
}
31+
32+
dependencies {
33+
implementation(project(":libs:datetime"))
34+
implementation(project(":libs:currency"))
35+
api(Libs.androidx_annotation)
36+
api(Libs.kotlin_stdlib)
37+
api(Libs.kotlinx_coroutines_core)
38+
api(Libs.kotlinx_coroutines_rx3)
39+
}

0 commit comments

Comments
 (0)