-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set up android module bare bone (#7)
* feat:set up android module barebone * feat: re-structure and rename main to core module * patch: rename * patch: resolve comments
- Loading branch information
1 parent
341fcf1
commit a8a8dc9
Showing
45 changed files
with
398 additions
and
125 deletions.
There are no files selected for viewing
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,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 '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' | ||
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2' | ||
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' | ||
} |
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
android/src/androidTest/java/com/amplitude/android/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.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()); | ||
} | ||
} |
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.amplitude.android"> | ||
|
||
</manifest> |
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,13 @@ | ||
package com.amplitude.android | ||
|
||
import com.amplitude.core.Amplitude | ||
import com.amplitude.core.platform.plugins.AmplitudeDestination | ||
|
||
open class Amplitude( | ||
configuration: Configuration | ||
): Amplitude(configuration) { | ||
|
||
override fun build() { | ||
add(AmplitudeDestination()) | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
android/src/main/java/com/amplitude/android/Configuration.kt
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,24 @@ | ||
package com.amplitude.android | ||
|
||
import android.content.Context | ||
import com.amplitude.core.Configuration | ||
import com.amplitude.core.LoggerProvider | ||
import com.amplitude.core.StorageProvider | ||
import com.amplitude.android.utilities.AndroidLoggerProvider | ||
import com.amplitude.android.utilities.AndroidStorageProvider | ||
import com.amplitude.core.events.BaseEvent | ||
|
||
class Configuration( | ||
apiKey: String, | ||
context: Context, | ||
flushQueueSize: Int = FLUSH_QUEUE_SIZE, | ||
flushIntervalMillis: Int = 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) |
14 changes: 14 additions & 0 deletions
14
android/src/main/java/com/amplitude/android/plugins/AndroidContextPlugin.kt
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,14 @@ | ||
package com.amplitude.android.plugins | ||
|
||
import com.amplitude.core.Amplitude | ||
import com.amplitude.core.events.BaseEvent | ||
import com.amplitude.core.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 | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
android/src/main/java/com/amplitude/android/plugins/AndroidLifecyclePlugin.kt
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,9 @@ | ||
package com.amplitude.android.plugins | ||
|
||
import com.amplitude.core.Amplitude | ||
import com.amplitude.core.platform.Plugin | ||
|
||
class AndroidLifecyclePlugin : Plugin { | ||
override val type: Plugin.Type = Plugin.Type.Utility | ||
override lateinit var amplitude: Amplitude | ||
} |
31 changes: 31 additions & 0 deletions
31
android/src/main/java/com/amplitude/android/utilities/AndroidLogger.kt
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,31 @@ | ||
package com.amplitude.android.utilities | ||
|
||
import com.amplitude.core.Amplitude | ||
import com.amplitude.core.Logger | ||
import com.amplitude.core.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() | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
android/src/main/java/com/amplitude/android/utilities/AndroidStorage.kt
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,28 @@ | ||
package com.amplitude.android.utilities | ||
|
||
import com.amplitude.core.Amplitude | ||
import com.amplitude.core.Storage | ||
import com.amplitude.core.StorageProvider | ||
import com.amplitude.core.events.BaseEvent | ||
|
||
class AndroidStorage( | ||
val amplitude: Amplitude | ||
) : Storage { | ||
override fun write(event: BaseEvent) { | ||
TODO("Not yet implemented") | ||
} | ||
|
||
override fun rollover() { | ||
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) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
android/src/test/java/com/amplitude/android/ExampleUnitTest.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,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); | ||
} | ||
} |
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
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
Oops, something went wrong.