-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: set up android module bare bone #7
Changes from 3 commits
2ce7bae
61cf644
5f1f963
8347264
6480859
3fe03d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'kotlin-android' | ||
} | ||
|
||
android { | ||
compileSdk 31 | ||
|
||
defaultConfig { | ||
multiDexEnabled true | ||
|
||
minSdk 16 | ||
targetSdk 31 | ||
versionCode 1 | ||
versionName "1.0" | ||
|
||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
coreLibraryDesugaringEnabled true | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
testOptions { | ||
unitTests { | ||
includeAndroidResources = true | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation project(':core') | ||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2' | ||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2' | ||
|
||
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2' | ||
qingzhuozhen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
testImplementation 'io.mockk:mockk:1.10.6' | ||
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.3' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' | ||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2' | ||
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.7.2' | ||
testImplementation 'org.robolectric:robolectric:4.7.3' | ||
testImplementation 'androidx.test:core:1.4.0' | ||
} |
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.amplitude.android; | ||
|
||
import android.content.Context; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
|
||
/** | ||
* 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.amplitude.android.test", appContext.getPackageName()); | ||
} | ||
} |
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.amplitude.android"> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.amplitude.android | ||
|
||
import android.content.Context | ||
import com.amplitude.Amplitude | ||
import com.amplitude.platform.plugins.AmplitudeDestination | ||
|
||
open class Amplitude( | ||
val context: Context, | ||
qingzhuozhen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
configuration: AndroidConfiguration | ||
): com.amplitude.Amplitude(configuration) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think would package this under There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean we want to include this Amplitude Android as part of the core package? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant the namespaces
I am concerned if users see There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @justin-fiedler just updated the namespace. We can do the jre later |
||
|
||
override fun build() { | ||
add(AmplitudeDestination()) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.amplitude.android | ||
|
||
import com.amplitude.Configuration | ||
import com.amplitude.Constants | ||
import com.amplitude.LoggerProvider | ||
import com.amplitude.StorageProvider | ||
import com.amplitude.android.utilities.AndroidLoggerProvider | ||
import com.amplitude.android.utilities.AndroidStorageProvider | ||
import com.amplitude.events.BaseEvent | ||
|
||
class AndroidConfiguration( | ||
apiKey: String, | ||
flushQueueSize: Int = Constants.FLUSH_QUEUE_SIZE, | ||
qingzhuozhen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
flushIntervalMillis: Int = Constants.FLUSH_INTERVAL_MILLIS, | ||
optOut: Boolean = false, | ||
storageProvider: StorageProvider = AndroidStorageProvider(), | ||
loggerProvider: LoggerProvider = AndroidLoggerProvider(), | ||
minIdLength: Int? = null, | ||
callback: ((BaseEvent) -> Unit)? = null, | ||
useAdvertisingIdForDeviceId: Boolean = false, | ||
useAppSetIdForDeviceId: Boolean = false, | ||
enableCoppaControl: Boolean = false | ||
) : Configuration(apiKey, flushQueueSize, flushIntervalMillis, optOut, storageProvider, loggerProvider, minIdLength, callback) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.amplitude.android.plugins | ||
|
||
import com.amplitude.Amplitude | ||
import com.amplitude.events.BaseEvent | ||
import com.amplitude.platform.Plugin | ||
|
||
class AndroidContextPlugin : Plugin { | ||
override val type: Plugin.Type = Plugin.Type.Before | ||
override lateinit var amplitude: Amplitude | ||
|
||
override fun execute(event: BaseEvent): BaseEvent? { | ||
return event | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.amplitude.android.plugins | ||
|
||
import com.amplitude.Amplitude | ||
import com.amplitude.platform.Plugin | ||
|
||
class AndroidLifecyclePlugin : Plugin { | ||
override val type: Plugin.Type = Plugin.Type.Utility | ||
override lateinit var amplitude: Amplitude | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.amplitude.android.utilities | ||
|
||
import com.amplitude.Amplitude | ||
import com.amplitude.Logger | ||
import com.amplitude.LoggerProvider | ||
|
||
class AndroidLogger() : Logger { | ||
override var logMode: Logger.LogMode = Logger.LogMode.INFO | ||
|
||
override fun debug(message: String) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun error(message: String) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun info(message: String) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun warn(message: String) { | ||
TODO("Not yet implemented") | ||
} | ||
} | ||
|
||
class AndroidLoggerProvider() : LoggerProvider { | ||
override fun getLogger(amplitude: Amplitude): Logger { | ||
return AndroidLogger() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.amplitude.android.utilities | ||
|
||
import com.amplitude.Amplitude | ||
import com.amplitude.Storage | ||
import com.amplitude.StorageProvider | ||
import com.amplitude.events.BaseEvent | ||
|
||
class AndroidStorage( | ||
val amplitude: Amplitude | ||
) : Storage { | ||
override fun write(event: BaseEvent) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun rollover() { | ||
justin-fiedler marked this conversation as resolved.
Show resolved
Hide resolved
|
||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun getEvents(): List<String> { | ||
TODO("Not yet implemented") | ||
} | ||
} | ||
|
||
class AndroidStorageProvider: StorageProvider { | ||
override fun getStorage(amplitude: Amplitude): Storage { | ||
return AndroidStorage(amplitude) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.amplitude.android; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
public class ExampleUnitTest { | ||
@Test | ||
public void addition_isCorrect() { | ||
assertEquals(4, 2 + 2); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ interface Plugin { | |
Before, | ||
Enrichment, | ||
Destination, | ||
Utility, | ||
Observe | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.amplitude | ||
|
||
import org.junit.jupiter.api.Assertions.assertTrue | ||
import org.junit.jupiter.api.Test | ||
|
||
internal class AmplitudeTest { | ||
|
||
@Test | ||
fun `test place holder` () { | ||
assertTrue(true) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.amplitude | ||
|
||
import org.junit.jupiter.api.Test | ||
|
||
import org.junit.jupiter.api.Assertions.* | ||
|
||
internal class ConfigurationTest { | ||
|
||
@Test | ||
fun isValid() { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 | ||
android.useAndroidX=true | ||
android.enableJetifier=true | ||
kotlin.code.style=official |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why disable the minify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this was auto generated, we can adjust this later