-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2ce7bae
feat:set up android module barebone
qingzhuozhen 61cf644
feat: re-structure and rename main to core module
qingzhuozhen 5f1f963
patch: rename
qingzhuozhen 8347264
patch: resolve comments
qingzhuozhen 6480859
patch: resolve comment
qingzhuozhen 3fe03d7
patch: resolve comments
qingzhuozhen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() { | ||
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) | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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