Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Brabenetz committed Jul 1, 2021
2 parents a6ddbc2 + 00d5c75 commit d81cb7a
Show file tree
Hide file tree
Showing 71 changed files with 413 additions and 477 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Thumbs.db
google-services.json
agconnect-services.json
hms.properties
keystore
17 changes: 8 additions & 9 deletions ChoiceSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ buildscript {
}
project.ext.buildNumber = buildNumber

project.ext.sdkVersionName = "0.1.6"
project.ext.sdkVersionName = "0.2.0"
project.ext.appVersionName = "${project.sdkVersionName}.${project.buildNumber}"
project.ext.versionCode = 7
project.ext.versionCode = 8
project.ext.groupId = "at.bluesource.choicesdk"

ext.kotlin_version = "1.4.32"
ext.kotlin_version = "1.5.20"

repositories {
google()
Expand All @@ -22,25 +22,24 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'com.android.tools.build:gradle:4.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

classpath 'com.jaredsburrows:gradle-license-plugin:0.8.80'

// GMS
classpath 'com.google.gms:google-services:4.3.5'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.0'
classpath 'com.google.gms:google-services:4.3.8'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1'

// HMS
classpath 'com.huawei.agconnect:agcp:1.5.0.300'
classpath 'com.huawei.hms.plugin:analytics:5.0.1.300'
classpath 'com.huawei.agconnect:agcp:1.5.2.300'

}
}

plugins {
id("org.jetbrains.dokka") version "1.4.0"
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
}

allprojects {
Expand Down
9 changes: 4 additions & 5 deletions ChoiceSDK/choicesdk-analytics/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ android {
dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.core:core-ktx:1.6.0'

// RX
api 'io.reactivex.rxjava3:rxjava:3.0.3'
api 'io.reactivex.rxjava3:rxjava:3.0.13'
api 'io.reactivex.rxjava3:rxandroid:3.0.0'

// RxRelay
Expand All @@ -60,15 +60,14 @@ dependencies {
api project(":choicesdk-core")

// GMS
implementation platform('com.google.firebase:firebase-bom:26.5.0')
implementation platform('com.google.firebase:firebase-bom:28.2.0')
implementation 'com.google.firebase:firebase-analytics-ktx'

// HMS
implementation 'com.huawei.hms:hianalytics:5.0.1.300'
implementation 'com.huawei.hms:hianalytics:6.0.0.300'
}



dokkaHtml {
outputDirectory.set(file("$buildDir/dokka"))
dokkaSourceSets {
Expand Down
4 changes: 0 additions & 4 deletions ChoiceSDK/choicesdk-analytics/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="at.bluesource.choicesdk.analytics">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<queries>
<intent>
<action android:name="com.huawei.hms.core.aidlservice" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.annotation.RequiresPermission
import at.bluesource.choicesdk.analytics.common.Analytics
import at.bluesource.choicesdk.analytics.gms.FirebaseAnalytics
import at.bluesource.choicesdk.analytics.hms.HuaweiAnalytics
import at.bluesource.choicesdk.core.MobileService
import at.bluesource.choicesdk.core.MobileServicesDetector

/**
Expand All @@ -19,39 +20,22 @@ import at.bluesource.choicesdk.core.MobileServicesDetector
*/
class AnalyticsFactory {
companion object {
private const val EXCEPTION_MESSAGE = "Missing underlying GMS/HMS API."

@Throws(UnsupportedOperationException::class)
@RequiresPermission(allOf = ["android.permission.ACCESS_NETWORK_STATE", "android.permission.INTERNET", "android.permission.WAKE_LOCK"])
fun getAnalytics(context: Context): Analytics {

return when {
MobileServicesDetector.isGmsAvailable() -> {
FirebaseAnalytics.getInstance(context)
}
MobileServicesDetector.isHmsAvailable() -> {
HuaweiAnalytics.getInstance(context)
}
else -> {
throw UnsupportedOperationException(EXCEPTION_MESSAGE)
}
return when (MobileServicesDetector.getAvailableMobileService()) {
MobileService.GMS -> FirebaseAnalytics.getInstance(context)
MobileService.HMS -> HuaweiAnalytics.getInstance(context)
}
}

@Throws(UnsupportedOperationException::class)
@RequiresPermission(allOf = ["android.permission.ACCESS_NETWORK_STATE", "android.permission.INTERNET", "android.permission.WAKE_LOCK"])
fun getAnalytics(activity: Activity): Analytics {

return when {
MobileServicesDetector.isGmsAvailable() -> {
FirebaseAnalytics.getInstance(activity)
}
MobileServicesDetector.isHmsAvailable() -> {
HuaweiAnalytics.getInstance(activity)
}
else -> {
throw UnsupportedOperationException(EXCEPTION_MESSAGE)
}
return when (MobileServicesDetector.getAvailableMobileService()) {
MobileService.GMS -> FirebaseAnalytics.getInstance(activity)
MobileService.HMS -> HuaweiAnalytics.getInstance(activity)
}
}
}
Expand Down
20 changes: 9 additions & 11 deletions ChoiceSDK/choicesdk-app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.huawei.agconnect'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.huawei.hms.plugin.analytics'
apply plugin: 'com.jaredsburrows.license'
apply from: "../licenseCheck.gradle"

Expand All @@ -18,7 +18,7 @@ def hmsProperties = new Properties()
hmsProperties.load(new FileInputStream(hmsPropertiesFile))

android {
compileSdkVersion 29
compileSdkVersion 30

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -28,7 +28,7 @@ android {
defaultConfig {
applicationId "com.bluesource.choicesdk_app"
minSdkVersion 19
targetSdkVersion 29
targetSdkVersion 30
versionCode project.versionCode
versionName project.appVersionName
multiDexEnabled true
Expand Down Expand Up @@ -90,8 +90,8 @@ android {
dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.android.support:multidex:1.0.3'

Expand All @@ -102,21 +102,19 @@ dependencies {
implementation project(":choicesdk-signin")

// for HMS map clustering
implementation 'com.huawei.hms:maps:5.0.5.301'

// hms plugin version of analytics needs to have a dependency
// in the gradle file where the plugin is applied
implementation 'com.huawei.hms:hianalytics:5.0.1.300'
implementation 'com.huawei.hms:maps:5.3.0.300'

// Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"

// HTTP Lib
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation 'com.squareup.retrofit2:converter-scalars:2.9.0'

implementation "androidx.biometric:biometric:1.1.0"

implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"

}

afterEvaluate {
Expand Down
1 change: 0 additions & 1 deletion ChoiceSDK/choicesdk-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:name=".ChoiceSdkApp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import at.bluesource.choicesdk.core.MobileService
import at.bluesource.choicesdk.core.MobileServicesDetector
import com.bluesource.choicesdk_app.analytics.AnalyticsActivity
import com.bluesource.choicesdk_app.biometrics.BiometricsActivity
Expand Down Expand Up @@ -35,10 +36,13 @@ class MainActivity : AppCompatActivity() {
val crashBtn: Button = findViewById(R.id.btn_crash_it)
val txtVersion: TextView = findViewById(R.id.txt_version)

txtView.text = when {
MobileServicesDetector.isGmsAvailable() -> "GMS detected | GMS demo"
MobileServicesDetector.isHmsAvailable() -> "HMS detected | HMS demo"
else -> "No GMS nor HMS service detected!"
txtView.text = try {
when (MobileServicesDetector.getAvailableMobileService()) {
MobileService.GMS -> "GMS detected | GMS demo"
MobileService.HMS -> "HMS detected | HMS demo"
}
} catch (e: UnsupportedOperationException) {
"No GMS nor HMS service detected!"
}

locationBtn.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.appcompat.app.AppCompatActivity
import at.bluesource.choicesdk.analytics.common.Analytics
import at.bluesource.choicesdk.analytics.factory.AnalyticsFactory
import com.bluesource.choicesdk_app.R
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.observers.DisposableObserver

Expand Down Expand Up @@ -55,7 +56,7 @@ class AnalyticsActivity : AppCompatActivity() {
}
disposables.add(observer)

analytics.getAppInstanceIdObservable().subscribeWith(observer)
analytics.getAppInstanceIdObservable().observeOn(AndroidSchedulers.mainThread()).subscribeWith(observer)
}

override fun onDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import at.bluesource.choicesdk.core.MobileServicesDetector
import at.bluesource.choicesdk.location.common.FusedLocationProviderClient
import at.bluesource.choicesdk.location.factory.FusedLocationProviderFactory
Expand All @@ -36,12 +34,11 @@ class MapActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_map)

val fragmentManager: FragmentManager = supportFragmentManager
val fragmentTransaction: FragmentTransaction = fragmentManager.beginTransaction()

mapFragment = MapFragment.newInstance()
fragmentTransaction.add(R.id.mapContainer, mapFragment)
fragmentTransaction.commit()
supportFragmentManager.beginTransaction().apply {
mapFragment = MapFragment.newInstance()
add(R.id.mapContainer, mapFragment)
commit()
}

if (!hasPermissions(this)) {
ActivityCompat.requestPermissions(this, PERMISSIONS, 3)
Expand Down Expand Up @@ -328,7 +325,6 @@ class MapActivity : AppCompatActivity() {
private const val TAG = "MapActivity"

private val PERMISSIONS = arrayOf(
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.lifecycle.lifecycleScope
import at.bluesource.choicesdk.core.MobileService
import at.bluesource.choicesdk.core.MobileServicesDetector
import at.bluesource.choicesdk.messaging.common.MessagingService
import at.bluesource.choicesdk.messaging.common.RemoteMessage
Expand All @@ -23,7 +25,6 @@ import com.bluesource.choicesdk_app.R
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.disposables.CompositeDisposable
import io.reactivex.rxjava3.observers.DisposableObserver
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import okhttp3.OkHttpClient
import retrofit2.Retrofit
Expand Down Expand Up @@ -84,9 +85,8 @@ class MessagesActivity : AppCompatActivity() {

disposables.addAll(tokenObserver, messageObserver)

messagingService.getNewTokenObservable().subscribeWith(tokenObserver)
messagingService.getMessageReceivedObservable().observeOn(AndroidSchedulers.mainThread())
.subscribeWith(messageObserver)
messagingService.getNewTokenObservable().observeOn(AndroidSchedulers.mainThread()).subscribeWith(tokenObserver)
messagingService.getMessageReceivedObservable().observeOn(AndroidSchedulers.mainThread()).subscribeWith(messageObserver)
}


Expand All @@ -100,10 +100,13 @@ class MessagesActivity : AppCompatActivity() {
textViewPush.movementMethod = ScrollingMovementMethod()

val txtPushServiceType = findViewById<TextView>(R.id.textView_push_service_type)
txtPushServiceType.text = when {
MobileServicesDetector.isGmsAvailable() -> "Using GSM Push Service"
MobileServicesDetector.isHmsAvailable() -> "Using HSM Push Service"
else -> ""
txtPushServiceType.text = try {
when (MobileServicesDetector.getAvailableMobileService()) {
MobileService.GMS -> "Using GMS Push Service"
MobileService.HMS -> "Using HMS Push Service"
}
} catch (e: UnsupportedOperationException) {
""
}

btnToken.setOnClickListener { getToken() }
Expand Down Expand Up @@ -169,16 +172,18 @@ class MessagesActivity : AppCompatActivity() {
}

private fun getServiceType(): String {
if (MobileServicesDetector.isGmsAvailable()) {
return "google"
} else if (MobileServicesDetector.isHmsAvailable()) {
return "huawei"
return try {
when (MobileServicesDetector.getAvailableMobileService()) {
MobileService.GMS -> "google"
MobileService.HMS -> "huawei"
}
} catch (e: UnsupportedOperationException) {
""
}
return ""
}

private fun triggerNotification() {
GlobalScope.launch {
lifecycleScope.launch {
try {
val response: String = notificationApi.triggerNotification(getServiceType(), token)
Log.d("ChoiceSDK", "Response: $response")
Expand Down
4 changes: 2 additions & 2 deletions ChoiceSDK/choicesdk-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ android {
dependencies {

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.core:core-ktx:1.6.0'

// GMS
implementation 'com.google.android.gms:play-services-base:17.6.0'

// HMS
implementation "com.huawei.hms:base:5.0.5.300"
implementation "com.huawei.hms:base:5.3.0.301"

}

Expand Down
Loading

0 comments on commit d81cb7a

Please sign in to comment.