Skip to content
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

Updated SDK version to 33 #140

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ buildscript {
}

plugins {
id 'com.android.application' version '4.2.0' apply false
id 'com.android.library' version '4.2.0' apply false
id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
id 'com.android.application' version '7.4.2' apply false
id 'com.android.library' version '7.4.2' apply false
id 'org.jetbrains.kotlin.android' version '1.8.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
Expand Down
3 changes: 2 additions & 1 deletion commonmodule/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

android {
compileSdk 32
compileSdk 33

defaultConfig {
minSdk 26
Expand Down Expand Up @@ -42,6 +42,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:$androidxAppcompatVersion"
implementation "com.google.android.material:material:$googleMaterialVersion"
implementation "androidx.constraintlayout:constraintlayout:$constraintlayoutVersion"
implementation "androidx.activity:activity:$androidxCoreKtxVersion"

//sendbird
implementation "com.sendbird.sdk:sendbird-chat:$sendbirdVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ class BaseSplashActivity : AppCompatActivity() {
startActivity(intent)
finish()
} else {
SendbirdChat.connect(userId) { _, e ->
if (e != null) {
showToast("$e")
SendbirdChat.connect(userId) { user, e ->
if (user != null) {
val intent = Intent("$packageName.MAIN")
startActivity(intent)
} else {
if (e != null) {
showToast("$e")
}
finish()
return@connect
}
val intent = Intent("$packageName.MAIN")
startActivity(intent)
finish()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.sendbird.chat.module.ui.base

import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
import android.view.MenuItem
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import com.sendbird.android.SendbirdChat
Expand All @@ -20,14 +19,11 @@ class BaseUserInfoActivity : AppCompatActivity() {
private var userNickname: String? = null
private var profileUri: Uri? = null

private val startForResult =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { data ->
private val pickMedia =
registerForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri ->
SendbirdChat.autoBackgroundDetection = true
if (data.resultCode == RESULT_OK) {
val uri = data.data?.data
profileUri = uri
binding.circularImageviewProfile.setImageUri(uri)
}
profileUri = uri
binding.circularImageviewProfile.setImageUri(uri)
}

override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -47,7 +43,7 @@ class BaseUserInfoActivity : AppCompatActivity() {

binding.circularImageviewEditProfile.setOnClickListener {
SendbirdChat.autoBackgroundDetection = false
FileUtils.selectFile(Constants.DATA_TYPE_ONLY_IMAGE, startForResult, this)
pickMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
}
binding.purpleButtonSave.setOnClickListener {
val nickname = binding.tagEdittextNickname.getText()
Expand Down Expand Up @@ -133,29 +129,4 @@ class BaseUserInfoActivity : AppCompatActivity() {
else -> super.onOptionsItemSelected(item)
}
}

override fun onRequestPermissionsResult(
requestCode: Int, permissions: Array<out String>, grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
when (requestCode) {
Constants.PERMISSION_REQUEST_CODE -> {
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
showToast(getString(R.string.permission_granted))
SendbirdChat.autoBackgroundDetection = false
FileUtils.selectFile(Constants.DATA_TYPE_ONLY_IMAGE, startForResult, this)
} else {
if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
requestPermissions(
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
Constants.PERMISSION_REQUEST_CODE
)
} else {
showToast(getString(R.string.permission_denied))
}
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,4 @@ object Constants {
const val CHANNEL_HANDLER_ID = "channel_handler_id"

const val CONNECTION_HANDLER_ID = "connection_handler_id"

const val PERMISSION_REQUEST_CODE = 10001

const val DATA_TYPE_ONLY_IMAGE = "image/*"
const val DATA_TYPE_IMAGE_AND_VIDEO = "image/* video/*"
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
package com.sendbird.chat.module.utils

import android.Manifest
import android.app.Activity
import android.content.ContentResolver
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.provider.MediaStore
import android.provider.OpenableColumns
import android.util.Log
import android.webkit.MimeTypeMap
import androidx.activity.result.ActivityResultLauncher
import androidx.core.app.ActivityCompat.requestPermissions
import androidx.core.content.ContextCompat
import java.io.File
import java.io.FileDescriptor
import java.io.FileInputStream
Expand All @@ -22,57 +14,6 @@ import java.io.FileOutputStream

object FileUtils {

fun selectFile(
type: String,
startForResult: ActivityResultLauncher<Intent>,
context: Context
) {
if (ContextCompat.checkSelfPermission(
context,
Manifest.permission.WRITE_EXTERNAL_STORAGE
) != PackageManager.PERMISSION_GRANTED
) {
requestStoragePermission(context)
} else {
val intent = Intent(Intent.ACTION_PICK)
intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, type)
startForResult.launch(intent)
}
}

fun selectFile(startForResult: ActivityResultLauncher<Intent>, context: Context) {
if (ContextCompat.checkSelfPermission(
context,
Manifest.permission.WRITE_EXTERNAL_STORAGE
) != PackageManager.PERMISSION_GRANTED
) {
requestStoragePermission(context)
} else {
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.type = "*/*"
intent.addCategory(Intent.CATEGORY_OPENABLE)
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true)
startForResult.launch(intent)
}
}

private fun requestStoragePermission(context: Context) {
context.showAlertDialog(
"Permission",
"Storage access permissions are required to upload/download files.",
"Accept",
"Cancel",
{
requestPermissions(
context as Activity,
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
10001
)
},
{}
)
}

data class FileResult(val file: File, val size: Int, val mime: String?, val name: String)

fun getFileInfo(uri: Uri, context: Context): FileResult? {
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Feb 17 09:30:44 KST 2022
#Thu Sep 07 16:17:09 KST 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
2 changes: 1 addition & 1 deletion groupchannel-add-remove-operators/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

android {
compileSdk 32
compileSdk 33

defaultConfig {
applicationId "com.sendbird.chat.sample.groupchannel.addremoveoperators"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.sendbird.chat.sample.groupchannel.addremoveoperators.ui.groupchannel

import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
Expand Down Expand Up @@ -41,14 +40,12 @@ class GroupChannelChatActivity : AppCompatActivity() {
private var channelTSHashMap = ConcurrentHashMap<String, Long>()
private var isCollectionInitialized = false

private val startForResultFile =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { data ->
private val pickMedia =
registerForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri ->
SendbirdChat.autoBackgroundDetection = true
if (data.resultCode == RESULT_OK) {
val uri = data.data?.data
sendFileMessage(uri)
}
uri?.let { sendFileMessage(it) }
}

private val startForResultInvite =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { data ->
if (data.resultCode == RESULT_OK) {
Expand Down Expand Up @@ -86,11 +83,7 @@ class GroupChannelChatActivity : AppCompatActivity() {

override fun onFileMessageSend() {
SendbirdChat.autoBackgroundDetection = false
FileUtils.selectFile(
Constants.DATA_TYPE_IMAGE_AND_VIDEO,
startForResultFile,
this@GroupChannelChatActivity
)
pickMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
}
})
}
Expand Down Expand Up @@ -598,32 +591,4 @@ class GroupChannelChatActivity : AppCompatActivity() {
}

}

override fun onRequestPermissionsResult(
requestCode: Int, permissions: Array<out String>, grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
when (requestCode) {
Constants.PERMISSION_REQUEST_CODE -> {
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
showToast(getString(R.string.permission_granted))
SendbirdChat.autoBackgroundDetection = false
FileUtils.selectFile(
Constants.DATA_TYPE_IMAGE_AND_VIDEO,
startForResultFile,
this
)
} else {
if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
requestPermissions(
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
Constants.PERMISSION_REQUEST_CODE
)
} else {
showToast(getString(R.string.permission_denied))
}
}
}
}
}
}
2 changes: 1 addition & 1 deletion groupchannel-admin-message/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

android {
compileSdk 32
compileSdk 33

defaultConfig {
applicationId "com.sendbird.chat.sample.groupchannel.admin"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.sendbird.chat.sample.groupchannel.admin.ui.groupchannel

import android.Manifest
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.activity.result.PickVisualMediaRequest
import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
Expand Down Expand Up @@ -41,6 +40,12 @@ class GroupChannelChatActivity : AppCompatActivity() {
private var channelTSHashMap = ConcurrentHashMap<String, Long>()
private var isCollectionInitialized = false

private val pickMedia =
registerForActivityResult(ActivityResultContracts.PickVisualMedia()) { uri ->
SendbirdChat.autoBackgroundDetection = true
uri?.let { sendFileMessage(it) }
}

private val startForResultFile =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { data ->
SendbirdChat.autoBackgroundDetection = true
Expand Down Expand Up @@ -86,11 +91,7 @@ class GroupChannelChatActivity : AppCompatActivity() {

override fun onFileMessageSend() {
SendbirdChat.autoBackgroundDetection = false
FileUtils.selectFile(
Constants.DATA_TYPE_IMAGE_AND_VIDEO,
startForResultFile,
this@GroupChannelChatActivity
)
pickMedia.launch(PickVisualMediaRequest(ActivityResultContracts.PickVisualMedia.ImageOnly))
}
})
}
Expand Down Expand Up @@ -598,32 +599,4 @@ class GroupChannelChatActivity : AppCompatActivity() {
}

}

override fun onRequestPermissionsResult(
requestCode: Int, permissions: Array<out String>, grantResults: IntArray
) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
when (requestCode) {
Constants.PERMISSION_REQUEST_CODE -> {
if (grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
showToast(getString(R.string.permission_granted))
SendbirdChat.autoBackgroundDetection = false
FileUtils.selectFile(
Constants.DATA_TYPE_IMAGE_AND_VIDEO,
startForResultFile,
this
)
} else {
if (shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
requestPermissions(
arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
Constants.PERMISSION_REQUEST_CODE
)
} else {
showToast(getString(R.string.permission_denied))
}
}
}
}
}
}
Loading