-
Notifications
You must be signed in to change notification settings - Fork 625
Initial commit for Firebase Sessions SDK #4713
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
716a300
Initial commit for Firebase Sessions SDK
mrober c1dc7a2
Add copyright notice
mrober ab05718
Remove redundant dependency
mrober 8dedf36
Revert 'Remove redundant dependency' to avoid using api
mrober c9fb592
Generate api.txt file
mrober 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 hidden or 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,19 @@ | ||
// Signature format: 2.0 | ||
package com.google.firebase.sessions { | ||
|
||
public final class FirebaseSessions { | ||
method @NonNull public static com.google.firebase.sessions.FirebaseSessions getInstance(); | ||
method @NonNull public static com.google.firebase.sessions.FirebaseSessions getInstance(@NonNull com.google.firebase.FirebaseApp app); | ||
method @Discouraged(message="This will be replaced with a real API.") @NonNull public String greeting(); | ||
property @NonNull public static final com.google.firebase.sessions.FirebaseSessions instance; | ||
field @NonNull public static final com.google.firebase.sessions.FirebaseSessions.Companion Companion; | ||
} | ||
|
||
public static final class FirebaseSessions.Companion { | ||
method @NonNull public com.google.firebase.sessions.FirebaseSessions getInstance(); | ||
method @NonNull public com.google.firebase.sessions.FirebaseSessions getInstance(@NonNull com.google.firebase.FirebaseApp app); | ||
property @NonNull public final com.google.firebase.sessions.FirebaseSessions instance; | ||
} | ||
|
||
} | ||
|
This file contains hidden or 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,54 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
plugins { | ||
id("firebase-library") | ||
id("kotlin-android") | ||
} | ||
|
||
firebaseLibrary { | ||
testLab.enabled = true | ||
publishSources = true | ||
} | ||
|
||
android { | ||
val targetSdkVersion: Int by rootProject | ||
compileSdk = targetSdkVersion | ||
defaultConfig { | ||
minSdk = 16 | ||
targetSdk = targetSdkVersion | ||
multiDexEnabled = true | ||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { jvmTarget = "1.8" } | ||
testOptions.unitTests.isIncludeAndroidResources = true | ||
} | ||
|
||
dependencies { | ||
implementation(project(":firebase-common")) | ||
implementation(project(":firebase-common:ktx")) | ||
implementation(project(":firebase-components")) | ||
implementation(libs.androidx.annotation) | ||
|
||
testImplementation(libs.junit) | ||
testImplementation(libs.truth) | ||
|
||
androidTestImplementation(libs.androidx.test.junit) | ||
androidTestImplementation(libs.androidx.test.runner) | ||
androidTestImplementation(libs.truth) | ||
} |
This file contains hidden or 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,15 @@ | ||
# Copyright 2023 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
version=0.1.0 |
54 changes: 54 additions & 0 deletions
54
...ase-sessions/src/androidTest/kotlin/com/google/firebase/sessions/FirebaseSessionsTests.kt
This file contains hidden or 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,54 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.firebase.sessions | ||
|
||
import androidx.test.core.app.ApplicationProvider | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import com.google.common.truth.Truth.assertThat | ||
import com.google.firebase.FirebaseApp | ||
import com.google.firebase.FirebaseOptions | ||
import com.google.firebase.ktx.Firebase | ||
import com.google.firebase.ktx.initialize | ||
import org.junit.After | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class FirebaseSessionsTests { | ||
@Before | ||
fun setUp() { | ||
Firebase.initialize( | ||
ApplicationProvider.getApplicationContext(), | ||
FirebaseOptions.Builder().setApplicationId("APP_ID").build() | ||
) | ||
} | ||
|
||
@After | ||
fun cleanUp() { | ||
FirebaseApp.clearInstancesForTest() | ||
} | ||
|
||
@Test | ||
fun mattDoesDayHi() { | ||
// This will be replaced with real tests. | ||
assertThat(FirebaseSessions.instance.greeting()).isEqualTo("Matt says hi!") | ||
} | ||
} |
This file contains hidden or 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,29 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2023 Google LLC --> | ||
<!-- --> | ||
<!-- Licensed under the Apache License, Version 2.0 (the "License"); --> | ||
<!-- you may not use this file except in compliance with the License. --> | ||
<!-- You may obtain a copy of the License at --> | ||
<!-- --> | ||
<!-- http://www.apache.org/licenses/LICENSE-2.0 --> | ||
<!-- --> | ||
<!-- Unless required by applicable law or agreed to in writing, software --> | ||
<!-- distributed under the License is distributed on an "AS IS" BASIS, --> | ||
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --> | ||
<!-- See the License for the specific language governing permissions and --> | ||
<!-- limitations under the License. --> | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.google.firebase.sessions"> | ||
<!--Although the *SdkVersion is captured in gradle build files, this is required for non gradle builds--> | ||
<!--<uses-sdk android:minSdkVersion="16"/>--> | ||
|
||
<application> | ||
<service android:name="com.google.firebase.components.ComponentDiscoveryService" | ||
android:exported="false"> | ||
<meta-data | ||
android:name="com.google.firebase.components:com.google.firebase.sessions.FirebaseSessionsRegistrar" | ||
android:value="com.google.firebase.components.ComponentRegistrar" /> | ||
</service> | ||
</application> | ||
</manifest> |
34 changes: 34 additions & 0 deletions
34
firebase-sessions/src/main/kotlin/com/google/firebase/sessions/FirebaseSessions.kt
This file contains hidden or 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,34 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.firebase.sessions | ||
|
||
import androidx.annotation.Discouraged | ||
import com.google.firebase.FirebaseApp | ||
import com.google.firebase.ktx.Firebase | ||
import com.google.firebase.ktx.app | ||
|
||
class FirebaseSessions internal constructor() { | ||
@Discouraged(message = "This will be replaced with a real API.") | ||
fun greeting(): String = "Matt says hi!" | ||
|
||
companion object { | ||
@JvmStatic | ||
val instance: FirebaseSessions | ||
get() = getInstance(Firebase.app) | ||
|
||
@JvmStatic | ||
fun getInstance(app: FirebaseApp): FirebaseSessions = app.get(FirebaseSessions::class.java) | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
firebase-sessions/src/main/kotlin/com/google/firebase/sessions/FirebaseSessionsRegistrar.kt
This file contains hidden or 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,41 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.firebase.sessions | ||
|
||
import androidx.annotation.Keep | ||
import com.google.firebase.components.Component | ||
import com.google.firebase.components.ComponentRegistrar | ||
import com.google.firebase.platforminfo.LibraryVersionComponent | ||
|
||
/** | ||
* [ComponentRegistrar] for setting up [FirebaseSessions]. | ||
* | ||
* @hide | ||
*/ | ||
@Keep | ||
internal class FirebaseSessionsRegistrar : ComponentRegistrar { | ||
override fun getComponents() = | ||
listOf( | ||
Component.builder(FirebaseSessions::class.java) | ||
.name(LIBRARY_NAME) | ||
.factory { FirebaseSessions() } | ||
.build(), | ||
LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME) | ||
) | ||
|
||
companion object { | ||
private const val LIBRARY_NAME = "fire-ses" | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
firebase-sessions/src/test/kotlin/com/google/firebase/sessions/FirebaseSessionsTest.kt
This file contains hidden or 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 @@ | ||
// Copyright 2023 Google LLC | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.firebase.sessions | ||
|
||
import com.google.common.truth.Truth.assertThat | ||
import org.junit.Test | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class FirebaseSessionsTest { | ||
@Test | ||
fun mattDoesDayHi() { | ||
// This will be replaced with real tests. | ||
assertThat(FirebaseSessions().greeting()).isEqualTo("Matt says hi!") | ||
} | ||
} |
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.