Skip to content

Commit

Permalink
Merge pull request #815 from QuickBlox/rc-1.3.0-ui-kit
Browse files Browse the repository at this point in the history
1.3.0-ui-kit
  • Loading branch information
vdovbnya-qb committed Sep 4, 2023
2 parents 81dfeaa + 1af6b69 commit 265d686
Show file tree
Hide file tree
Showing 11 changed files with 547 additions and 150 deletions.
57 changes: 42 additions & 15 deletions android-ui-kit-sample/README.md
@@ -1,14 +1,20 @@
# Overview

The QuickBlox UIKit for Android is a comprehensive user interface kit specifically designed for building chat applications. It provides a collection of pre-built components, modules, and utilities that simplify the process of creating chat applications.
The QuickBlox UIKit for Android is a comprehensive user interface kit specifically designed for building chat
applications. It provides a collection of pre-built components, modules, and utilities that simplify the process of
creating chat applications.

The main goal of the QuickBlox UIKit for Android is to offer developers a streamlined and efficient way to implement chat functionality within their Android applications.
The main goal of the QuickBlox UIKit for Android is to offer developers a streamlined and efficient way to implement
chat functionality within their Android applications.

The QuickBlox UIKit for Android offers modules that encapsulate complex chat functionalities, such as dialogs and chat management and real-time updates. These modules provide a simplified interface for integrating chat features into applications without the need for extensive knowledge of the underlying protocols or server-side infrastructure.
The QuickBlox UIKit for Android offers modules that encapsulate complex chat functionalities, such as dialogs and chat
management and real-time updates. These modules provide a simplified interface for integrating chat features into
applications without the need for extensive knowledge of the underlying protocols or server-side infrastructure.

# Features

QuickBlox UIKit for Android provides next functionality:

- List of dialogs
- Create dialog(Private or Group)
- Dialog screen
Expand All @@ -18,33 +24,44 @@ QuickBlox UIKit for Android provides next functionality:

# Send your first message

The QuickBlox UIKit for Android comprises a collection of pre-assembled UI components that enable effortless creation of an in-app chat equipped with all the necessary messaging functionalities. Our development kit encompasses light and dark themes, colors, and various other features. These components can be personalized to fashion an engaging messaging interface that reflects your brand's distinct identity.
The QuickBlox UIKit for Android comprises a collection of pre-assembled UI components that enable effortless creation of
an in-app chat equipped with all the necessary messaging functionalities. Our development kit encompasses light and dark
themes, colors, and various other features. These components can be personalized to fashion an engaging messaging
interface that reflects your brand's distinct identity.

The QuickBlox UIKit fully supports both private and group dialogs. To initiate the process of sending a message from the ground up using Java or Kotlin, please refer to the instructions provided in the guide below.
The QuickBlox UIKit fully supports both private and group dialogs. To initiate the process of sending a message from the
ground up using Java or Kotlin, please refer to the instructions provided in the guide below.

## Requirements

The minimum requirements for QuickBlox UIKit for Android are:

- Android 5.0 (API level 21) or higher
- Java 8 or higher
- Android Gradle plugin 4.0.1 or higher

## Before you begin

Register a new account following [this link](https://admin.quickblox.com/signup). Type in your email and password to sign in. You can also sign in with your Google or Github accounts.
Register a new account following [this link](https://admin.quickblox.com/signup). Type in your email and password to
sign in. You can also sign in with your Google or Github accounts.
Create the app clicking New app button.
Configure the app. Type in the information about your organization into corresponding fields and click Add button.
Go to Dashboard => YOUR_APP => Overview section and copy your Application ID, Authorization Key, Authorization Secret, and Account Key .
Go to Dashboard => YOUR_APP => Overview section and copy your Application ID, Authorization Key, Authorization Secret,
and Account Key .

## Install QuickBlox UIKit

There are several ways to install to QuickBlox UIKit from:

- Repository
- Local source

### Install QuickBlox UIKit from repository

To install QuickBlox UIKit to your app, import QuickBlox UIKit and QuickBlox SDK dependencies via build.gradle file.
Include reference to SDK repository in your **project-level build.gradle** file at the root directory or to **settings.gradle** file. Specify the URL of QuickBlox repository where the files are stored. Following this URL, gradle finds SDK artifacts.
Include reference to SDK repository in your **project-level build.gradle** file at the root directory or to **
settings.gradle** file. Specify the URL of QuickBlox repository where the files are stored. Following this URL, gradle
finds SDK artifacts.

```
repositories {
Expand All @@ -60,11 +77,12 @@ repositories {
}
```

Then need to add implementation of QuickBlox UIKit and QuickBlox SDK to dependencies in your module-level(App) **build.gradle** file.
Then need to add implementation of QuickBlox UIKit and QuickBlox SDK to dependencies in your module-level(App) **
build.gradle** file.

```
dependencies {
implementation "com.quickblox:android-ui-kit:0.2.1"
implementation "com.quickblox:android-ui-kit:0.2.3"
implementation 'com.quickblox:quickblox-android-sdk-messages:4.1.1'
implementation 'com.quickblox:quickblox-android-sdk-chat:4.1.1'
Expand All @@ -73,8 +91,11 @@ dependencies {
```

### Install QuickBlox UIKit from local source

To connect QuickBlox SDK to your app, import QuickBlox SDK dependencies via build.gradle file.
Include reference to SDK repository in your **project-level build.gradle** file at the root directory or to **settings.gradle** file. Specify the URL of QuickBlox repository where the files are stored. Following this URL, gradle finds SDK artifacts.
Include reference to SDK repository in your **project-level build.gradle** file at the root directory or to **
settings.gradle** file. Specify the URL of QuickBlox repository where the files are stored. Following this URL, gradle
finds SDK artifacts.

```
repositories {
Expand All @@ -86,7 +107,8 @@ repositories {
}
```

Then need to download the QuickBlox UIKit from the GitHub repository at [this link](https://github.com/QuickBlox/android-ui-kit) to include UIKit locally in your project.
Then need to download the QuickBlox UIKit from the GitHub repository
at [this link](https://github.com/QuickBlox/android-ui-kit) to include UIKit locally in your project.

Specify the path of the UIKit project in **settings.gradle** file.

Expand All @@ -105,8 +127,10 @@ dependencies {

## Init QuickBlox SDK

To init QuickBlox SDK you need to pass Application ID, Authorization Key, Authorization Secret, and Account Key to the init() method.
To init QuickBlox SDK you need to pass Application ID, Authorization Key, Authorization Secret, and Account Key to the
init() method.
How to get credentials is described in the [Before you begin](#before-you-begin) section.

```
private const val APPLICATION_ID = "67895"
private const val AUTH_KEY = "lkjdueksu7392kj"
Expand All @@ -118,9 +142,11 @@ QBSDK.init(applicationContext, APPLICATION_ID, AUTH_KEY, AUTH_SECRET, ACCOUNT_KE

## Authentication and start QuickBlox UIKit

Before sending your first message you need to authenticate users in the QuickBlox system. You can read more about different ways of authentication by [this link](https://docs.quickblox.com/docs/android-authentication).
Before sending your first message you need to authenticate users in the QuickBlox system. You can read more about
different ways of authentication by [this link](https://docs.quickblox.com/docs/android-authentication).
In our example we show how to authenticate user with login and password.
After successfully sign-in, you need to initialize the QuickBlox UIKit by invoke **init(applicationContext)** method of the **QuickBloxUiKit** and start Dialogs screen by invoke **show()** method of the **DialogActivity**.
After successfully sign-in, you need to initialize the QuickBlox UIKit by invoke **init(applicationContext)** method of
the **QuickBloxUiKit** and start Dialogs screen by invoke **show()** method of the **DialogActivity**.

```
val user = QBUser()
Expand Down Expand Up @@ -159,6 +185,7 @@ QuickBloxUiKit.setTheme(DarkUiKitTheme())
## Use your own theme

There are two options how you can create your own theme:

- Customize current theme
- Create your own theme

Expand Down
6 changes: 3 additions & 3 deletions android-ui-kit-sample/app/build.gradle
Expand Up @@ -12,7 +12,7 @@ android {
minSdk 21
targetSdk 33
versionCode 1
versionName "1.2.0"
versionName "1.3.0"
}

buildTypes {
Expand Down Expand Up @@ -40,7 +40,7 @@ android {
}

dependencies {
implementation "com.quickblox:android-ui-kit:0.2.1"
implementation "com.quickblox:android-ui-kit:0.2.3"

implementation 'com.quickblox:quickblox-android-sdk-messages:4.1.1'
implementation 'com.quickblox:quickblox-android-sdk-chat:4.1.1'
Expand All @@ -50,5 +50,5 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.activity:activity-ktx:1.7.1'
implementation 'androidx.activity:activity-ktx:1.7.2'
}
5 changes: 5 additions & 0 deletions android-ui-kit-sample/app/src/main/AndroidManifest.xml
Expand Up @@ -22,5 +22,10 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".SignUpActivity"
android:configChanges="keyboard|orientation|screenSize"
android:launchMode="singleTop" />
</application>
</manifest>
Expand Up @@ -7,6 +7,7 @@ package com.example.android_ui_kit_sample

import android.content.Context
import android.os.Bundle
import android.util.Log
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.Toast
Expand All @@ -22,6 +23,8 @@ import com.quickblox.users.QBUsers
import com.quickblox.users.model.QBUser

class LoginActivity : AppCompatActivity() {
private val TAG = LoginActivity::class.java.simpleName

private lateinit var binding: ActivityLoginBinding

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -31,24 +34,59 @@ class LoginActivity : AppCompatActivity() {

setThemeQBUiKit(DarkUiKitTheme())

loginClickListener()
signupClickListener()
}

override fun onResume() {
super.onResume()
signOut()
}

private fun setThemeQBUiKit(theme: UiKitTheme) {
QuickBloxUiKit.setTheme(theme)
}

private fun loginClickListener() {
binding.btnLogin.setOnClickListener {
hideKeyboard(it)

binding.progressBar.visibility = View.VISIBLE
binding.btnLogin.isEnabled = false

val user = buildUser()
QBUsers.signIn(user).performAsync(object : QBEntityCallback<QBUser> {
override fun onSuccess(user: QBUser?, bundle: Bundle?) {
binding.progressBar.visibility = View.GONE
binding.btnLogin.isEnabled = true
initAndShowQBUiKit()
}

override fun onError(exception: QBResponseException) {
binding.progressBar.visibility = View.GONE
binding.btnLogin.isEnabled = true
Toast.makeText(this@LoginActivity, exception.message, Toast.LENGTH_LONG).show()
}
})
}
}

private fun setThemeQBUiKit(theme: UiKitTheme) {
QuickBloxUiKit.setTheme(theme)
private fun signupClickListener() {
binding.btnSignUp.setOnClickListener {
SignUpActivity.show(this)
}
}

private fun signOut() {
QBUsers.signOut().performAsync(object : QBEntityCallback<Void?> {
override fun onSuccess(aVoid: Void?, bundle: Bundle) {
Log.d(TAG, "onSuccess: signOut")
}

override fun onError(exception: QBResponseException) {
Log.d(TAG, "onError: signOut")
}
})
}

private fun buildUser(): QBUser {
Expand Down
@@ -0,0 +1,122 @@
/*
* Created by Injoit on 6.7.2023.
* Copyright © 2023 Quickblox. All rights reserved.
*
*/

package com.example.android_ui_kit_sample

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.MenuItem
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AppCompatActivity
import com.example.android_ui_kit_sample.databinding.ActivitySignupBinding
import com.quickblox.android_ui_kit.QuickBloxUiKit
import com.quickblox.android_ui_kit.presentation.screens.dialogs.DialogsActivity
import com.quickblox.core.QBEntityCallback
import com.quickblox.core.exception.QBResponseException
import com.quickblox.users.QBUsers
import com.quickblox.users.model.QBUser

class SignUpActivity : AppCompatActivity() {
private lateinit var binding: ActivitySignupBinding

companion object {
fun show(context: Context) {
val intent = Intent(context, SignUpActivity::class.java)
context.startActivity(intent)
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

binding = ActivitySignupBinding.inflate(layoutInflater)
setContentView(binding.root)

configureToolbar()
onBackPressedClickListener()

signUpClickListener()
}

private fun configureToolbar() {
setSupportActionBar(binding.toolbar)
if (supportActionBar != null) {
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
supportActionBar?.title = getString(R.string.signup)
}
}

private fun onBackPressedClickListener() {
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
})
}

private fun signUpClickListener() {
binding.btnSignUp.setOnClickListener {
binding.btnSignUp.isEnabled = false

val user = buildUser()
signUp(user)
}
}

private fun buildUser(): QBUser {
val user = QBUser()
user.login = binding.etLogin.text.toString().trim()
user.fullName = binding.etDisplayName.text.toString().trim()
user.password = binding.etPassword.text.toString().trim()
return user
}

private fun signUp(user: QBUser) {
QBUsers.signUp(user).performAsync(object : QBEntityCallback<QBUser> {
override fun onSuccess(userFromRest: QBUser, bundle: Bundle) {
logIn(user)
}

override fun onError(exception: QBResponseException) {
Toast.makeText(this@SignUpActivity, exception.message, Toast.LENGTH_LONG).show()
binding.btnSignUp.isEnabled = true
}
})
}

private fun logIn(user: QBUser) {
QBUsers.signIn(user).performAsync(object : QBEntityCallback<QBUser> {
override fun onSuccess(user: QBUser?, bundle: Bundle?) {
binding.btnSignUp.isEnabled = true
initAndShowQBUiKit()
finish()
}

override fun onError(exception: QBResponseException) {
binding.btnSignUp.isEnabled = true
Toast.makeText(this@SignUpActivity, exception.message, Toast.LENGTH_LONG).show()
}
})
}

private fun initAndShowQBUiKit() {
QuickBloxUiKit.init(applicationContext)
DialogsActivity.show(this)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
finish()
true
}
else -> super.onOptionsItemSelected(item)
}
}
}

0 comments on commit 265d686

Please sign in to comment.