diff --git a/sample-pushnotifications-kotlin/app/build.gradle b/sample-pushnotifications-kotlin/app/build.gradle index efd380e3a..f29c6e3a2 100644 --- a/sample-pushnotifications-kotlin/app/build.gradle +++ b/sample-pushnotifications-kotlin/app/build.gradle @@ -1,19 +1,16 @@ buildscript { repositories { google() - jcenter() - maven { url 'https://maven.fabric.io/public' } + mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinGradlePluginVersion" - classpath "io.fabric.tools:gradle:$fabricToolsVersion" } } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' -apply plugin: 'io.fabric' apply from: "../artifacts.gradle" apply plugin: 'com.google.gms.google-services' @@ -23,27 +20,25 @@ androidExtensions { repositories { google() - jcenter() + mavenCentral() maven { url "https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/" } - maven { url 'https://maven.fabric.io/public' } - flatDir { dirs 'libs' } } android { def versionQACode = 1 - compileSdkVersion 28 - buildToolsVersion "28.0.3" + compileSdkVersion 31 + buildToolsVersion "31.0.0" flavorDimensions dimensionDefault defaultConfig { applicationId "com.quickblox.sample.pushnotifications.kotlin" - minSdkVersion 14 - targetSdkVersion 28 - versionCode 401000 - versionName '4.0.1-kotlin' + minSdkVersion 21 + targetSdkVersion 31 + versionCode 402000 + versionName '4.0.2-kotlin' multiDexEnabled true } @@ -97,14 +92,9 @@ android { } dependencies { - implementation("com.quickblox:quickblox-android-sdk-messages:$qbSdkVersion") implementation "com.google.firebase:firebase-core:$firebaseCoreVersion" implementation("com.google.android.material:material:$materialVersion") implementation("com.github.johnkil.android-robototextview:robototextview:$robotoTextViewVersion") - implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinGradlePluginVersion") - implementation("com.crashlytics.sdk.android:crashlytics:$crashlyticsVersion@aar") { - transitive = true - } } \ No newline at end of file diff --git a/sample-pushnotifications-kotlin/app/google-services.json b/sample-pushnotifications-kotlin/app/google-services.json index 542e3ac38..c2c8a1420 100644 --- a/sample-pushnotifications-kotlin/app/google-services.json +++ b/sample-pushnotifications-kotlin/app/google-services.json @@ -1,154 +1,29 @@ { "project_info": { - "project_number": "247738611464", - "firebase_url": "https://qb-prod-samples.firebaseio.com", - "project_id": "qb-prod-samples", - "storage_bucket": "qb-prod-samples.appspot.com" + "project_number": "Put here your value", + "firebase_url": "https://qb-samples.firebaseio.com", + "project_id": "qb-samples", + "storage_bucket": "qb-samples.appspot.com" }, "client": [ { "client_info": { - "mobilesdk_app_id": "1:247738611464:android:beb270faa2c3a789", - "android_client_info": { - "package_name": "com.quickblox.sample.chat.java" - } - }, - "oauth_client": [], - "api_key": [ - { - "current_key": "AIzaSyBFXAfVr6kkFJdDNOm8U-c7iju0qIUkc_A" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "247738611464-v2nvd29bmqum7niosnfuh28oq3beh9f6.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:247738611464:android:1cdc72e9ffd29448", - "android_client_info": { - "package_name": "com.quickblox.sample.chat.kotlin" - } - }, - "oauth_client": [], - "api_key": [ - { - "current_key": "AIzaSyBFXAfVr6kkFJdDNOm8U-c7iju0qIUkc_A" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "247738611464-v2nvd29bmqum7niosnfuh28oq3beh9f6.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:247738611464:android:06cb0de4c719ad84", - "android_client_info": { - "package_name": "com.quickblox.sample.pushnotifications.java" - } - }, - "oauth_client": [], - "api_key": [ - { - "current_key": "AIzaSyBFXAfVr6kkFJdDNOm8U-c7iju0qIUkc_A" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "247738611464-v2nvd29bmqum7niosnfuh28oq3beh9f6.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:247738611464:android:c2749661061637f0", + "mobilesdk_app_id": "Put here your value", "android_client_info": { "package_name": "com.quickblox.sample.pushnotifications.kotlin" } }, - "oauth_client": [], - "api_key": [ - { - "current_key": "AIzaSyBFXAfVr6kkFJdDNOm8U-c7iju0qIUkc_A" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "247738611464-v2nvd29bmqum7niosnfuh28oq3beh9f6.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:247738611464:android:99e5b55a490c901c", - "android_client_info": { - "package_name": "com.quickblox.sample.videochat.java" - } - }, - "oauth_client": [], - "api_key": [ + "oauth_client": [ { - "current_key": "AIzaSyBFXAfVr6kkFJdDNOm8U-c7iju0qIUkc_A" + "client_id": "Put here your value", + "client_type": 3 } ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "247738611464-v2nvd29bmqum7niosnfuh28oq3beh9f6.apps.googleusercontent.com", - "client_type": 3 - } - ] - } - } - }, - { - "client_info": { - "mobilesdk_app_id": "1:247738611464:android:ac22e0d1b3a3e86b", - "android_client_info": { - "package_name": "com.quickblox.sample.videochat.kotlin" - } - }, - "oauth_client": [], "api_key": [ { - "current_key": "AIzaSyBFXAfVr6kkFJdDNOm8U-c7iju0qIUkc_A" - } - ], - "services": { - "appinvite_service": { - "other_platform_oauth_client": [ - { - "client_id": "247738611464-v2nvd29bmqum7niosnfuh28oq3beh9f6.apps.googleusercontent.com", - "client_type": 3 - } - ] + "current_key": "Put here your value" } - } + ] } ], "configuration_version": "1" diff --git a/sample-pushnotifications-kotlin/app/proguard-rules.pro b/sample-pushnotifications-kotlin/app/proguard-rules.pro index f1dd7da4b..be6afe8c2 100755 --- a/sample-pushnotifications-kotlin/app/proguard-rules.pro +++ b/sample-pushnotifications-kotlin/app/proguard-rules.pro @@ -1,13 +1,11 @@ # Add project specific ProGuard rules here. # By default, the flags in this file are appended to flags specified -# in /home/tereha/Android/sdk/tools/proguard/proguard-android.txt + # You can edit the include path and order by changing the proguardFiles # directive in build.gradle. # # For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: +# 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 @@ -23,48 +21,16 @@ ##---------------Begin: proguard configuration for Gson ---------- # Gson uses generic type information stored in a class file when working with fields. Proguard # removes such information by default, so configure it to keep all of it. +-keepattributes EnclosingMethod +-keepattributes InnerClasses -keepattributes Signature +-keepattributes Exceptions # For using GSON @Expose annotation -keepattributes *Annotation* -# Gson specific classes --keep class sun.misc.Unsafe { *; } -#-keep class com.google.gson.stream.** { *; } - -# Application classes that will be serialized/deserialized over Gson - -keep class com.quickblox.core.account.model.** { *; } - - -##---------------End: proguard configuration for Gson ---------- -#quickblox sample chat - --keep class com.quickblox.auth.parsers.** { *; } --keep class com.quickblox.auth.model.** { *; } --keep class com.quickblox.core.parser.** { *; } --keep class com.quickblox.core.model.** { *; } --keep class com.quickblox.core.server.** { *; } --keep class com.quickblox.core.rest.** { *; } --keep class com.quickblox.core.error.** { *; } --keep class com.quickblox.core.Query { *; } - --keep class com.quickblox.users.parsers.** { *; } --keep class com.quickblox.users.model.** { *; } - --keep class com.quickblox.chat.parser.** { *; } --keep class com.quickblox.chat.model.** { *; } - --keep class com.quickblox.messages.parsers.** { *; } --keep class com.quickblox.messages.model.** { *; } - --keep class com.quickblox.content.parsers.** { *; } --keep class com.quickblox.content.model.** { *; } - --keep class org.jivesoftware.** { *; } - -#sample chat --keep class android.support.v7.** { *; } --keep class com.bumptech.** { *; } +#quickblox sdk +-keep class com.quickblox.** { *; } --dontwarn org.jivesoftware.smackx.** --dontwarn android.support.v4.app.** \ No newline at end of file +#google gms +-keep class com.google.android.gms.** { *; } \ No newline at end of file diff --git a/sample-pushnotifications-kotlin/app/src/main/AndroidManifest.xml b/sample-pushnotifications-kotlin/app/src/main/AndroidManifest.xml index d5dd021b1..da3b2caa3 100644 --- a/sample-pushnotifications-kotlin/app/src/main/AndroidManifest.xml +++ b/sample-pushnotifications-kotlin/app/src/main/AndroidManifest.xml @@ -17,6 +17,7 @@ @@ -45,13 +46,17 @@ - + - + diff --git a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/App.kt b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/App.kt index 9109c4a42..5c60a349c 100644 --- a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/App.kt +++ b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/App.kt @@ -2,7 +2,6 @@ package com.quickblox.sample.pushnotifications.kotlin import android.app.Application import android.util.Log -import com.crashlytics.android.Crashlytics import com.google.android.gms.common.GoogleApiAvailability import com.quickblox.auth.session.QBSession import com.quickblox.auth.session.QBSessionManager @@ -11,15 +10,14 @@ import com.quickblox.auth.session.QBSettings import com.quickblox.messages.services.QBPushManager import com.quickblox.sample.pushnotifications.kotlin.utils.ActivityLifecycle import com.quickblox.sample.pushnotifications.kotlin.utils.shortToast -import io.fabric.sdk.android.Fabric -//App Credentials +// app credentials private const val APPLICATION_ID = "" private const val AUTH_KEY = "" private const val AUTH_SECRET = "" private const val ACCOUNT_KEY = "" -//Default user config +// default user config const val DEFAULT_USER_PASSWORD = "quickblox" class App : Application() { @@ -38,7 +36,6 @@ class App : Application() { checkConfig() initCredentials() initQBSessionManager() - initFabric() initPushManager() } @@ -53,7 +50,7 @@ class App : Application() { QBSettings.getInstance().init(applicationContext, APPLICATION_ID, AUTH_KEY, AUTH_SECRET) QBSettings.getInstance().accountKey = ACCOUNT_KEY - // Uncomment and put your Api and Chat servers endpoints if you want to point the sample + // uncomment and put your Api and Chat servers endpoints if you want to point the sample // against your own server. // // QBSettings.getInstance().setEndpoints("https://your_api_endpoint.com", "your_chat_endpoint", ServiceZone.PRODUCTION); @@ -109,10 +106,4 @@ class App : Application() { } }) } - - private fun initFabric() { - if (!BuildConfig.DEBUG) { - Fabric.with(this, Crashlytics()) - } - } } \ No newline at end of file diff --git a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/AppInfoActivity.kt b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/AppInfoActivity.kt index 5118ad6ca..f57eb961e 100644 --- a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/AppInfoActivity.kt +++ b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/AppInfoActivity.kt @@ -15,7 +15,6 @@ import com.quickblox.sample.pushnotifications.kotlin.BuildConfig import com.quickblox.sample.pushnotifications.kotlin.R class AppInfoActivity : BaseActivity() { - private lateinit var appVersionTextView: TextView private lateinit var sdkVersionTextView: TextView private lateinit var appIDTextView: TextView diff --git a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/BaseActivity.kt b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/BaseActivity.kt index 9329082a5..47b4f8e98 100644 --- a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/BaseActivity.kt +++ b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/BaseActivity.kt @@ -16,16 +16,16 @@ abstract class BaseActivity : AppCompatActivity() { protected fun showProgressDialog(@StringRes messageId: Int) { if (progressDialog == null) { progressDialog = ProgressDialog(this) - progressDialog!!.isIndeterminate = true - progressDialog!!.setCancelable(false) - progressDialog!!.setCanceledOnTouchOutside(false) + progressDialog?.isIndeterminate = true + progressDialog?.setCancelable(false) + progressDialog?.setCanceledOnTouchOutside(false) - // Disable the back button + // disable the back button val keyListener = DialogInterface.OnKeyListener { dialog, keyCode, event -> keyCode == KeyEvent.KEYCODE_BACK } - progressDialog!!.setOnKeyListener(keyListener) + progressDialog?.setOnKeyListener(keyListener) } - progressDialog!!.setMessage(getString(messageId)) - progressDialog!!.show() + progressDialog?.setMessage(getString(messageId)) + progressDialog?.show() } override fun onPause() { @@ -34,8 +34,8 @@ abstract class BaseActivity : AppCompatActivity() { } protected fun hideProgressDialog() { - if (progressDialog != null && progressDialog!!.isShowing) { - progressDialog!!.dismiss() + if (progressDialog?.isShowing == true) { + progressDialog?.dismiss() } } @@ -46,8 +46,8 @@ abstract class BaseActivity : AppCompatActivity() { } } - override fun onOptionsItemSelected(item: MenuItem?): Boolean { - if (item?.itemId == android.R.id.home) { + override fun onOptionsItemSelected(item: MenuItem): Boolean { + if (item.itemId == android.R.id.home) { finish() return true } diff --git a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/LoginActivity.kt b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/LoginActivity.kt index b6e659362..983b13df4 100644 --- a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/LoginActivity.kt +++ b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/LoginActivity.kt @@ -9,7 +9,6 @@ import android.widget.Button import android.widget.EditText import com.quickblox.core.QBEntityCallback import com.quickblox.core.exception.QBResponseException -import com.quickblox.sample.pushnotifications.kotlin.App import com.quickblox.sample.pushnotifications.kotlin.DEFAULT_USER_PASSWORD import com.quickblox.sample.pushnotifications.kotlin.R import com.quickblox.sample.pushnotifications.kotlin.utils.EXTRA_FCM_MESSAGE @@ -43,15 +42,15 @@ class LoginActivity : BaseActivity() { val extras = intent.extras if (extras != null) { - message = intent.extras!!.getString(EXTRA_FCM_MESSAGE) + message = intent.extras?.getString(EXTRA_FCM_MESSAGE) } buttonLogin = findViewById(R.id.btn_login) editTextLogin = findViewById(R.id.et_login) - buttonLogin!!.setOnClickListener { + buttonLogin?.setOnClickListener { val patternLogin = Pattern.compile("^[a-zA-Z][a-zA-Z0-9]{2," + (MAX_LOGIN_LENGTH - 1) + "}+$") - val matcherLogin = patternLogin.matcher(editTextLogin!!.text.toString().trim { it <= ' ' }) + val matcherLogin = patternLogin.matcher(editTextLogin?.text.toString().trim { it <= ' ' }) if (matcherLogin.matches()) { signIn() @@ -62,31 +61,31 @@ class LoginActivity : BaseActivity() { } override fun onBackPressed() { - + // empty } private fun signIn() { showProgressDialog(R.string.dlg_sign_in) - val login = editTextLogin!!.text.toString().trim { it <= ' ' } + val login = editTextLogin?.text.toString().trim { it <= ' ' } val qbUser = QBUser(login, DEFAULT_USER_PASSWORD) qbUser.fullName = login QBUsers.signIn(qbUser).performAsync(object : QBEntityCallback { override fun onSuccess(user: QBUser?, bundle: Bundle?) { - Log.d(TAG, "SignIn Success: " + qbUser.id!!.toString()) + Log.d(TAG, "SignIn Success: " + qbUser.id.toString()) SharedPrefsHelper.saveQbUser(qbUser) hideProgressDialog() MessagesActivity.start(this@LoginActivity, message) finish() } - override fun onError(e: QBResponseException?) { - Log.d(TAG, "SignIn Error: " + e?.localizedMessage) - if (e?.httpStatusCode == UNAUTHORIZED) { + override fun onError(exception: QBResponseException?) { + Log.d(TAG, "SignIn Error: " + exception?.localizedMessage) + if (exception?.httpStatusCode == UNAUTHORIZED) { signUp(qbUser) } else { - e?.let { - showErrorSnackbar(R.string.splash_signin_error, e, View.OnClickListener { + exception?.let { + showErrorSnackbar(R.string.splash_signin_error, exception, View.OnClickListener { signIn() }) } @@ -99,14 +98,14 @@ class LoginActivity : BaseActivity() { showProgressDialog(R.string.dlg_sign_up) QBUsers.signUp(qbUser).performAsync(object : QBEntityCallback { override fun onSuccess(qbUser: QBUser?, bundle: Bundle?) { - Log.d(TAG, "SignUp Success: " + qbUser?.id!!.toString()) + Log.d(TAG, "SignUp Success: " + qbUser?.id.toString()) signIn() } - override fun onError(e: QBResponseException?) { - Log.d(TAG, "SignUp Error: " + e?.message) - e?.let { - showErrorSnackbar(R.string.splash_signup_error, e, View.OnClickListener { + override fun onError(exception: QBResponseException?) { + Log.d(TAG, "SignUp Error: " + exception?.message) + exception?.let { + showErrorSnackbar(R.string.splash_signup_error, exception, View.OnClickListener { signIn() }) } diff --git a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/MessagesActivity.kt b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/MessagesActivity.kt index 5b3b3c446..d5043e62a 100644 --- a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/MessagesActivity.kt +++ b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/MessagesActivity.kt @@ -60,7 +60,7 @@ class MessagesActivity : BaseActivity() { message = EMPTY_FCM_MESSAGE } Log.i(TAG, "Receiving event $ACTION_NEW_FCM_EVENT with data: $message") - retrieveMessage(message) + message?.let { retrieveMessage(it) } } } @@ -95,8 +95,8 @@ class MessagesActivity : BaseActivity() { return true } - override fun onOptionsItemSelected(item: MenuItem?): Boolean { - when (item?.itemId) { + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { R.id.menu_send_message -> { item.isEnabled = false sendPushMessage() @@ -178,11 +178,9 @@ class MessagesActivity : BaseActivity() { return } - // Send Push: create QuickBlox Push Notification Event val qbEvent = QBEvent() qbEvent.notificationType = QBNotificationType.PUSH qbEvent.environment = QBEnvironment.DEVELOPMENT - // Generic push - will be delivered to all platforms (Android, iOS, WP, Blackberry..) qbEvent.message = outMessage val userIds = StringifyArrayList() @@ -198,9 +196,9 @@ class MessagesActivity : BaseActivity() { invalidateOptionsMenu() } - override fun onError(e: QBResponseException?) { - e?.let { - showErrorSnackbar(R.string.sending_error, e, View.OnClickListener { + override fun onError(exception: QBResponseException?) { + exception?.let { + showErrorSnackbar(R.string.sending_error, exception, View.OnClickListener { sendPushMessage() }) } @@ -220,11 +218,11 @@ class MessagesActivity : BaseActivity() { } override fun beforeTextChanged(string: CharSequence?, start: Int, count: Int, after: Int) { - + // empty } override fun onTextChanged(string: CharSequence?, start: Int, before: Int, count: Int) { - + // empty } } @@ -232,11 +230,11 @@ class MessagesActivity : BaseActivity() { if (QBPushManager.getInstance().isSubscribedToPushes) { QBPushManager.getInstance().addListener(object : QBPushManager.QBSubscribeListener { override fun onSubscriptionCreated() { - + // empty } override fun onSubscriptionError(e: Exception?, i: Int) { - + // empty } override fun onSubscriptionDeleted(success: Boolean) { diff --git a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/SplashActivity.kt b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/SplashActivity.kt index e74d7a93f..50fc79c95 100644 --- a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/SplashActivity.kt +++ b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/activities/SplashActivity.kt @@ -23,20 +23,17 @@ class SplashActivity : BaseActivity() { } catch (e: PackageManager.NameNotFoundException) { throw RuntimeException("Could not get package name: $e") } - } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_splash) - if (supportActionBar != null) { - supportActionBar!!.hide() - } + supportActionBar?.hide() val extras = intent.extras if (extras != null) { - message = intent.extras!!.getString(EXTRA_FCM_MESSAGE) + message = intent.extras?.getString(EXTRA_FCM_MESSAGE) } fillUI() startNextScreen() @@ -63,6 +60,5 @@ class SplashActivity : BaseActivity() { finish() }, SPLASH_DELAY.toLong()) } - } } \ No newline at end of file diff --git a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/fcm/PushListenerService.kt b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/fcm/PushListenerService.kt index e2e617703..248d41d0a 100644 --- a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/fcm/PushListenerService.kt +++ b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/fcm/PushListenerService.kt @@ -10,7 +10,6 @@ import com.quickblox.sample.pushnotifications.kotlin.utils.showNotification private const val NOTIFICATION_ID = 1 class PushListenerService : QBFcmPushListenerService() { - private val TAG = PushListenerService::class.java.simpleName override fun sendPushMessage(data: MutableMap?, from: String?, message: String?) { @@ -20,7 +19,7 @@ class PushListenerService : QBFcmPushListenerService() { if (ActivityLifecycle.isBackground()) { showNotification(this, SplashActivity::class.java, - getString(R.string.notification_title), message!!, + getString(R.string.notification_title), message, R.mipmap.ic_notification, NOTIFICATION_ID) } } diff --git a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/ActivityLifecycle.kt b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/ActivityLifecycle.kt index 07d321121..4ae7daadf 100644 --- a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/ActivityLifecycle.kt +++ b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/ActivityLifecycle.kt @@ -13,11 +13,11 @@ object ActivityLifecycle : Application.ActivityLifecycleCallbacks { } override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { - + // empty } override fun onActivityStarted(activity: Activity) { - + // empty } override fun onActivityResumed(activity: Activity) { @@ -32,11 +32,11 @@ object ActivityLifecycle : Application.ActivityLifecycleCallbacks { } - override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle?) { - + override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) { + // empty } override fun onActivityDestroyed(activity: Activity) { - + // empty } } \ No newline at end of file diff --git a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/NotificationUtils.kt b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/NotificationUtils.kt index e6feaf4c7..d6abdced4 100644 --- a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/NotificationUtils.kt +++ b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/NotificationUtils.kt @@ -10,12 +10,11 @@ import androidx.annotation.DrawableRes import androidx.annotation.RequiresApi import androidx.core.app.NotificationCompat -// The id of the channel. private const val CHANNEL_ONE_ID = "com.quickblox.samples.ONE" private const val CHANNEL_ONE_NAME = "Channel One" fun showNotification(context: Context, activityClass: Class, - title: String, message: String, @DrawableRes icon: Int, + title: String, message: String?, @DrawableRes icon: Int, notificationId: Int) { val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager @@ -41,7 +40,7 @@ private fun createChannelIfNotExist(notificationManager: NotificationManager) { } private fun buildNotification(context: Context, activityClass: Class, - title: String, message: String, @DrawableRes icon: Int): Notification { + title: String, message: String?, @DrawableRes icon: Int): Notification { val defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION) return NotificationCompat.Builder(context, CHANNEL_ONE_ID) .setSmallIcon(icon) @@ -53,7 +52,7 @@ private fun buildNotification(context: Context, activityClass: Class, message: String): PendingIntent { +private fun buildContentIntent(context: Context, activityClass: Class, message: String?): PendingIntent { val intent = Intent(context, activityClass) intent.putExtra(EXTRA_FCM_MESSAGE, message) intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) diff --git a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/SharedPrefsHelper.kt b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/SharedPrefsHelper.kt index a6095bccb..c30fea731 100644 --- a/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/SharedPrefsHelper.kt +++ b/sample-pushnotifications-kotlin/app/src/main/java/com/quickblox/sample/pushnotifications/kotlin/utils/SharedPrefsHelper.kt @@ -18,7 +18,7 @@ private const val QB_USER_TAGS = "qb_user_tags" object SharedPrefsHelper { private var sharedPreferences: SharedPreferences = App.getInstance().getSharedPreferences(SHARED_PREFS_NAME, Context.MODE_PRIVATE) - fun save(key: String, value: Any?) { + private fun save(key: String, value: Any?) { val editor = sharedPreferences.edit() when { value is Boolean -> editor.putBoolean(key, (value as Boolean?)!!) @@ -32,7 +32,7 @@ object SharedPrefsHelper { editor.apply() } - fun delete(key: String) { + private fun delete(key: String) { if (sharedPreferences.contains(key)) { getEditor().remove(key).commit() } @@ -58,7 +58,7 @@ object SharedPrefsHelper { delete(QB_USER_TAGS) } - fun hasQbUser(): Boolean { + private fun hasQbUser(): Boolean { return has(QB_USER_LOGIN) && has(QB_USER_PASSWORD) } diff --git a/sample-pushnotifications-kotlin/build.gradle b/sample-pushnotifications-kotlin/build.gradle index bbed1bf92..6cd2517aa 100644 --- a/sample-pushnotifications-kotlin/build.gradle +++ b/sample-pushnotifications-kotlin/build.gradle @@ -1,22 +1,19 @@ buildscript { repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.0' - classpath 'com.google.gms:google-services:4.1.0' + classpath 'com.android.tools.build:gradle:4.2.2' + classpath 'com.google.gms:google-services:4.3.10' } } allprojects { repositories { google() - jcenter() - maven { - url "https://github.com/QuickBlox/quickblox-android-sdk-releases/raw/master/" - } + mavenCentral() } } @@ -25,23 +22,17 @@ ext { dimensionDefault = 'default' // QuickBlox SDK version - qbSdkVersion = '3.9.4' + qbSdkVersion = '3.9.16' - //Kotlin - kotlinGradlePluginVersion = '1.2.71' + // Kotlin + kotlinGradlePluginVersion = '1.5.31' - //Fabric - fabricToolsVersion = '1.27.0' + // Firebase + firebaseCoreVersion = '21.0.0' - //Firebase - firebaseCoreVersion = '16.0.8' + // Material + materialVersion = '1.6.0' - //Material - materialVersion = '1.0.0' - - //RobotoTextView + // RobotoTextView robotoTextViewVersion = '4.0.0' - - //Crashlytics - crashlyticsVersion = '2.9.5' } \ No newline at end of file diff --git a/sample-pushnotifications-kotlin/gradle/wrapper/gradle-wrapper.properties b/sample-pushnotifications-kotlin/gradle/wrapper/gradle-wrapper.properties index 9a4163a4f..4d9ca1649 100644 --- a/sample-pushnotifications-kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/sample-pushnotifications-kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists