Skip to content

Commit 265d686

Browse files
authored
Merge pull request #815 from QuickBlox/rc-1.3.0-ui-kit
1.3.0-ui-kit
2 parents 81dfeaa + 1af6b69 commit 265d686

File tree

11 files changed

+547
-150
lines changed

11 files changed

+547
-150
lines changed

android-ui-kit-sample/README.md

+42-15
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
# Overview
22

3-
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.
3+
The QuickBlox UIKit for Android is a comprehensive user interface kit specifically designed for building chat
4+
applications. It provides a collection of pre-built components, modules, and utilities that simplify the process of
5+
creating chat applications.
46

5-
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.
7+
The main goal of the QuickBlox UIKit for Android is to offer developers a streamlined and efficient way to implement
8+
chat functionality within their Android applications.
69

7-
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.
10+
The QuickBlox UIKit for Android offers modules that encapsulate complex chat functionalities, such as dialogs and chat
11+
management and real-time updates. These modules provide a simplified interface for integrating chat features into
12+
applications without the need for extensive knowledge of the underlying protocols or server-side infrastructure.
813

914
# Features
1015

1116
QuickBlox UIKit for Android provides next functionality:
17+
1218
- List of dialogs
1319
- Create dialog(Private or Group)
1420
- Dialog screen
@@ -18,33 +24,44 @@ QuickBlox UIKit for Android provides next functionality:
1824

1925
# Send your first message
2026

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

23-
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.
32+
The QuickBlox UIKit fully supports both private and group dialogs. To initiate the process of sending a message from the
33+
ground up using Java or Kotlin, please refer to the instructions provided in the guide below.
2434

2535
## Requirements
2636

2737
The minimum requirements for QuickBlox UIKit for Android are:
38+
2839
- Android 5.0 (API level 21) or higher
2940
- Java 8 or higher
3041
- Android Gradle plugin 4.0.1 or higher
3142

3243
## Before you begin
3344

34-
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.
45+
Register a new account following [this link](https://admin.quickblox.com/signup). Type in your email and password to
46+
sign in. You can also sign in with your Google or Github accounts.
3547
Create the app clicking New app button.
3648
Configure the app. Type in the information about your organization into corresponding fields and click Add button.
37-
Go to Dashboard => YOUR_APP => Overview section and copy your Application ID, Authorization Key, Authorization Secret, and Account Key .
49+
Go to Dashboard => YOUR_APP => Overview section and copy your Application ID, Authorization Key, Authorization Secret,
50+
and Account Key .
3851

3952
## Install QuickBlox UIKit
4053

4154
There are several ways to install to QuickBlox UIKit from:
55+
4256
- Repository
4357
- Local source
4458

4559
### Install QuickBlox UIKit from repository
60+
4661
To install QuickBlox UIKit to your app, import QuickBlox UIKit and QuickBlox SDK dependencies via build.gradle file.
47-
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.
62+
Include reference to SDK repository in your **project-level build.gradle** file at the root directory or to **
63+
settings.gradle** file. Specify the URL of QuickBlox repository where the files are stored. Following this URL, gradle
64+
finds SDK artifacts.
4865

4966
```
5067
repositories {
@@ -60,11 +77,12 @@ repositories {
6077
}
6178
```
6279

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

6583
```
6684
dependencies {
67-
implementation "com.quickblox:android-ui-kit:0.2.1"
85+
implementation "com.quickblox:android-ui-kit:0.2.3"
6886
6987
implementation 'com.quickblox:quickblox-android-sdk-messages:4.1.1'
7088
implementation 'com.quickblox:quickblox-android-sdk-chat:4.1.1'
@@ -73,8 +91,11 @@ dependencies {
7391
```
7492

7593
### Install QuickBlox UIKit from local source
94+
7695
To connect QuickBlox SDK to your app, import QuickBlox SDK dependencies via build.gradle file.
77-
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.
96+
Include reference to SDK repository in your **project-level build.gradle** file at the root directory or to **
97+
settings.gradle** file. Specify the URL of QuickBlox repository where the files are stored. Following this URL, gradle
98+
finds SDK artifacts.
7899

79100
```
80101
repositories {
@@ -86,7 +107,8 @@ repositories {
86107
}
87108
```
88109

89-
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.
110+
Then need to download the QuickBlox UIKit from the GitHub repository
111+
at [this link](https://github.com/QuickBlox/android-ui-kit) to include UIKit locally in your project.
90112

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

@@ -105,8 +127,10 @@ dependencies {
105127

106128
## Init QuickBlox SDK
107129

108-
To init QuickBlox SDK you need to pass Application ID, Authorization Key, Authorization Secret, and Account Key to the init() method.
130+
To init QuickBlox SDK you need to pass Application ID, Authorization Key, Authorization Secret, and Account Key to the
131+
init() method.
109132
How to get credentials is described in the [Before you begin](#before-you-begin) section.
133+
110134
```
111135
private const val APPLICATION_ID = "67895"
112136
private const val AUTH_KEY = "lkjdueksu7392kj"
@@ -118,9 +142,11 @@ QBSDK.init(applicationContext, APPLICATION_ID, AUTH_KEY, AUTH_SECRET, ACCOUNT_KE
118142

119143
## Authentication and start QuickBlox UIKit
120144

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

125151
```
126152
val user = QBUser()
@@ -159,6 +185,7 @@ QuickBloxUiKit.setTheme(DarkUiKitTheme())
159185
## Use your own theme
160186

161187
There are two options how you can create your own theme:
188+
162189
- Customize current theme
163190
- Create your own theme
164191

android-ui-kit-sample/app/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ android {
1212
minSdk 21
1313
targetSdk 33
1414
versionCode 1
15-
versionName "1.2.0"
15+
versionName "1.3.0"
1616
}
1717

1818
buildTypes {
@@ -40,7 +40,7 @@ android {
4040
}
4141

4242
dependencies {
43-
implementation "com.quickblox:android-ui-kit:0.2.1"
43+
implementation "com.quickblox:android-ui-kit:0.2.3"
4444

4545
implementation 'com.quickblox:quickblox-android-sdk-messages:4.1.1'
4646
implementation 'com.quickblox:quickblox-android-sdk-chat:4.1.1'
@@ -50,5 +50,5 @@ dependencies {
5050
implementation 'androidx.appcompat:appcompat:1.6.1'
5151
implementation 'com.google.android.material:material:1.9.0'
5252
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
53-
implementation 'androidx.activity:activity-ktx:1.7.1'
53+
implementation 'androidx.activity:activity-ktx:1.7.2'
5454
}

android-ui-kit-sample/app/src/main/AndroidManifest.xml

+5
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,10 @@
2222
<category android:name="android.intent.category.LAUNCHER" />
2323
</intent-filter>
2424
</activity>
25+
26+
<activity
27+
android:name=".SignUpActivity"
28+
android:configChanges="keyboard|orientation|screenSize"
29+
android:launchMode="singleTop" />
2530
</application>
2631
</manifest>

android-ui-kit-sample/app/src/main/java/com/example/android_ui_kit_sample/LoginActivity.kt

+40-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package com.example.android_ui_kit_sample
77

88
import android.content.Context
99
import android.os.Bundle
10+
import android.util.Log
1011
import android.view.View
1112
import android.view.inputmethod.InputMethodManager
1213
import android.widget.Toast
@@ -22,6 +23,8 @@ import com.quickblox.users.QBUsers
2223
import com.quickblox.users.model.QBUser
2324

2425
class LoginActivity : AppCompatActivity() {
26+
private val TAG = LoginActivity::class.java.simpleName
27+
2528
private lateinit var binding: ActivityLoginBinding
2629

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

3235
setThemeQBUiKit(DarkUiKitTheme())
3336

37+
loginClickListener()
38+
signupClickListener()
39+
}
40+
41+
override fun onResume() {
42+
super.onResume()
43+
signOut()
44+
}
45+
46+
private fun setThemeQBUiKit(theme: UiKitTheme) {
47+
QuickBloxUiKit.setTheme(theme)
48+
}
49+
50+
private fun loginClickListener() {
3451
binding.btnLogin.setOnClickListener {
3552
hideKeyboard(it)
3653

54+
binding.progressBar.visibility = View.VISIBLE
55+
binding.btnLogin.isEnabled = false
56+
3757
val user = buildUser()
3858
QBUsers.signIn(user).performAsync(object : QBEntityCallback<QBUser> {
3959
override fun onSuccess(user: QBUser?, bundle: Bundle?) {
60+
binding.progressBar.visibility = View.GONE
61+
binding.btnLogin.isEnabled = true
4062
initAndShowQBUiKit()
4163
}
4264

4365
override fun onError(exception: QBResponseException) {
66+
binding.progressBar.visibility = View.GONE
67+
binding.btnLogin.isEnabled = true
4468
Toast.makeText(this@LoginActivity, exception.message, Toast.LENGTH_LONG).show()
4569
}
4670
})
4771
}
4872
}
4973

50-
private fun setThemeQBUiKit(theme: UiKitTheme) {
51-
QuickBloxUiKit.setTheme(theme)
74+
private fun signupClickListener() {
75+
binding.btnSignUp.setOnClickListener {
76+
SignUpActivity.show(this)
77+
}
78+
}
79+
80+
private fun signOut() {
81+
QBUsers.signOut().performAsync(object : QBEntityCallback<Void?> {
82+
override fun onSuccess(aVoid: Void?, bundle: Bundle) {
83+
Log.d(TAG, "onSuccess: signOut")
84+
}
85+
86+
override fun onError(exception: QBResponseException) {
87+
Log.d(TAG, "onError: signOut")
88+
}
89+
})
5290
}
5391

5492
private fun buildUser(): QBUser {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* Created by Injoit on 6.7.2023.
3+
* Copyright © 2023 Quickblox. All rights reserved.
4+
*
5+
*/
6+
7+
package com.example.android_ui_kit_sample
8+
9+
import android.content.Context
10+
import android.content.Intent
11+
import android.os.Bundle
12+
import android.view.MenuItem
13+
import android.widget.Toast
14+
import androidx.activity.OnBackPressedCallback
15+
import androidx.appcompat.app.AppCompatActivity
16+
import com.example.android_ui_kit_sample.databinding.ActivitySignupBinding
17+
import com.quickblox.android_ui_kit.QuickBloxUiKit
18+
import com.quickblox.android_ui_kit.presentation.screens.dialogs.DialogsActivity
19+
import com.quickblox.core.QBEntityCallback
20+
import com.quickblox.core.exception.QBResponseException
21+
import com.quickblox.users.QBUsers
22+
import com.quickblox.users.model.QBUser
23+
24+
class SignUpActivity : AppCompatActivity() {
25+
private lateinit var binding: ActivitySignupBinding
26+
27+
companion object {
28+
fun show(context: Context) {
29+
val intent = Intent(context, SignUpActivity::class.java)
30+
context.startActivity(intent)
31+
}
32+
}
33+
34+
override fun onCreate(savedInstanceState: Bundle?) {
35+
super.onCreate(savedInstanceState)
36+
37+
binding = ActivitySignupBinding.inflate(layoutInflater)
38+
setContentView(binding.root)
39+
40+
configureToolbar()
41+
onBackPressedClickListener()
42+
43+
signUpClickListener()
44+
}
45+
46+
private fun configureToolbar() {
47+
setSupportActionBar(binding.toolbar)
48+
if (supportActionBar != null) {
49+
supportActionBar?.setDisplayHomeAsUpEnabled(true)
50+
supportActionBar?.setDisplayShowHomeEnabled(true)
51+
supportActionBar?.title = getString(R.string.signup)
52+
}
53+
}
54+
55+
private fun onBackPressedClickListener() {
56+
onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
57+
override fun handleOnBackPressed() {
58+
finish()
59+
}
60+
})
61+
}
62+
63+
private fun signUpClickListener() {
64+
binding.btnSignUp.setOnClickListener {
65+
binding.btnSignUp.isEnabled = false
66+
67+
val user = buildUser()
68+
signUp(user)
69+
}
70+
}
71+
72+
private fun buildUser(): QBUser {
73+
val user = QBUser()
74+
user.login = binding.etLogin.text.toString().trim()
75+
user.fullName = binding.etDisplayName.text.toString().trim()
76+
user.password = binding.etPassword.text.toString().trim()
77+
return user
78+
}
79+
80+
private fun signUp(user: QBUser) {
81+
QBUsers.signUp(user).performAsync(object : QBEntityCallback<QBUser> {
82+
override fun onSuccess(userFromRest: QBUser, bundle: Bundle) {
83+
logIn(user)
84+
}
85+
86+
override fun onError(exception: QBResponseException) {
87+
Toast.makeText(this@SignUpActivity, exception.message, Toast.LENGTH_LONG).show()
88+
binding.btnSignUp.isEnabled = true
89+
}
90+
})
91+
}
92+
93+
private fun logIn(user: QBUser) {
94+
QBUsers.signIn(user).performAsync(object : QBEntityCallback<QBUser> {
95+
override fun onSuccess(user: QBUser?, bundle: Bundle?) {
96+
binding.btnSignUp.isEnabled = true
97+
initAndShowQBUiKit()
98+
finish()
99+
}
100+
101+
override fun onError(exception: QBResponseException) {
102+
binding.btnSignUp.isEnabled = true
103+
Toast.makeText(this@SignUpActivity, exception.message, Toast.LENGTH_LONG).show()
104+
}
105+
})
106+
}
107+
108+
private fun initAndShowQBUiKit() {
109+
QuickBloxUiKit.init(applicationContext)
110+
DialogsActivity.show(this)
111+
}
112+
113+
override fun onOptionsItemSelected(item: MenuItem): Boolean {
114+
return when (item.itemId) {
115+
android.R.id.home -> {
116+
finish()
117+
true
118+
}
119+
else -> super.onOptionsItemSelected(item)
120+
}
121+
}
122+
}

0 commit comments

Comments
 (0)