├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── example │ │ └── matyoudemo │ │ ├── Colors.kt │ │ ├── MainActivity.kt │ │ └── MessagesActivity.kt │ └── res │ ├── drawable-v24 │ └── ic_launcher_foreground.xml │ ├── drawable │ └── ic_launcher_background.xml │ ├── mipmap-anydpi-v26 │ ├── ic_launcher.xml │ └── ic_launcher_round.xml │ ├── mipmap-hdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-mdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xxhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── mipmap-xxxhdpi │ ├── ic_launcher.webp │ └── ic_launcher_round.webp │ ├── values-night │ └── themes.xml │ └── values │ ├── colors.xml │ ├── strings.xml │ └── themes.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | .cxx 10 | local.properties 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Stream.io Inc 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Material You & Jetpack Compose & Stream Chat 2 | 3 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdk 31 8 | 9 | defaultConfig { 10 | applicationId "com.example.chattutorial" 11 | minSdk 21 12 | targetSdk 31 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 17 | vectorDrawables { 18 | useSupportLibrary true 19 | } 20 | } 21 | 22 | buildTypes { 23 | release { 24 | minifyEnabled false 25 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 26 | } 27 | } 28 | compileOptions { 29 | sourceCompatibility JavaVersion.VERSION_1_8 30 | targetCompatibility JavaVersion.VERSION_1_8 31 | } 32 | kotlinOptions { 33 | jvmTarget = '1.8' 34 | useIR = true 35 | } 36 | buildFeatures { 37 | compose true 38 | } 39 | composeOptions { 40 | kotlinCompilerExtensionVersion compose_version 41 | } 42 | packagingOptions { 43 | resources { 44 | excludes += '/META-INF/{AL2.0,LGPL2.1}' 45 | } 46 | } 47 | } 48 | 49 | dependencies { 50 | def stream_version = "4.23.0" 51 | implementation "io.getstream:stream-chat-android-compose:$stream_version-beta" 52 | 53 | implementation 'androidx.compose.material3:material3:1.0.0-alpha02' 54 | 55 | implementation "androidx.compose.material:material-icons-extended:$compose_version" 56 | 57 | implementation 'androidx.core:core-ktx:1.6.0' 58 | implementation 'androidx.appcompat:appcompat:1.3.1' 59 | implementation 'com.google.android.material:material:1.4.0' 60 | implementation "androidx.compose.ui:ui:$compose_version" 61 | implementation "androidx.compose.material:material:$compose_version" 62 | implementation "androidx.compose.ui:ui-tooling-preview:$compose_version" 63 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' 64 | implementation 'androidx.activity:activity-compose:1.3.1' 65 | testImplementation 'junit:junit:4.13.2' 66 | androidTestImplementation 'androidx.test.ext:junit:1.1.3' 67 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 68 | androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" 69 | debugImplementation "androidx.compose.ui:ui-tooling:$compose_version" 70 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 21 | 25 | 29 | 33 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/matyoudemo/Colors.kt: -------------------------------------------------------------------------------- 1 | package com.example.matyoudemo 2 | 3 | import android.os.Build 4 | import androidx.compose.foundation.isSystemInDarkTheme 5 | import androidx.compose.material3.ColorScheme 6 | import androidx.compose.material3.dynamicDarkColorScheme 7 | import androidx.compose.material3.dynamicLightColorScheme 8 | import androidx.compose.runtime.Composable 9 | import androidx.compose.ui.platform.LocalContext 10 | import io.getstream.chat.android.compose.ui.theme.StreamColors 11 | 12 | @Composable 13 | fun createStreamColors(): StreamColors { 14 | val isInDarkMode = isSystemInDarkTheme() 15 | return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { 16 | val scheme = when { 17 | isInDarkMode -> dynamicDarkColorScheme(LocalContext.current) 18 | else -> dynamicLightColorScheme(LocalContext.current) 19 | } 20 | return adapt(scheme) 21 | } else { 22 | when { 23 | isInDarkMode -> StreamColors.defaultDarkColors() 24 | else -> StreamColors.defaultColors() 25 | } 26 | } 27 | } 28 | 29 | @Composable 30 | private fun adapt(scheme: ColorScheme) = StreamColors( 31 | textHighEmphasis = scheme.onPrimaryContainer, 32 | textLowEmphasis = scheme.onSecondaryContainer, 33 | disabled = scheme.inversePrimary, 34 | borders = scheme.outline, 35 | inputBackground = scheme.surfaceVariant, 36 | appBackground = scheme.background, 37 | barsBackground = scheme.secondaryContainer, 38 | linkBackground = scheme.primaryContainer, 39 | overlay = scheme.surface.copy(alpha = 0.5f), 40 | overlayDark = scheme.inverseSurface.copy(alpha = 0.5f), 41 | primaryAccent = scheme.primary, 42 | errorAccent = scheme.error, 43 | infoAccent = scheme.secondary, 44 | highlight = scheme.inversePrimary, 45 | ownMessagesBackground = scheme.secondaryContainer, 46 | otherMessagesBackground = scheme.tertiaryContainer, 47 | deletedMessagesBackground = scheme.onError, 48 | threadSeparatorGradientStart = scheme.background, 49 | threadSeparatorGradientEnd = scheme.surfaceVariant, 50 | ) 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/matyoudemo/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.matyoudemo 2 | 3 | import android.os.Bundle 4 | import androidx.activity.compose.setContent 5 | import androidx.appcompat.app.AppCompatActivity 6 | import androidx.compose.ui.res.stringResource 7 | import io.getstream.chat.android.client.ChatClient 8 | import io.getstream.chat.android.client.logger.ChatLogLevel 9 | import io.getstream.chat.android.client.models.User 10 | import io.getstream.chat.android.compose.ui.channel.ChannelsScreen 11 | import io.getstream.chat.android.compose.ui.theme.ChatTheme 12 | import io.getstream.chat.android.offline.ChatDomain 13 | 14 | class MainActivity : AppCompatActivity() { 15 | 16 | override fun onCreate(savedInstanceState: Bundle?) { 17 | super.onCreate(savedInstanceState) 18 | 19 | val client = ChatClient.Builder("b67pax5b2wdq", applicationContext) 20 | .logLevel(ChatLogLevel.ALL) 21 | .build() 22 | ChatDomain.Builder(client, applicationContext).build() 23 | 24 | val user = User( 25 | id = "tutorial-droid", 26 | extraData = mutableMapOf( 27 | "name" to "Tutorial Droid", 28 | "image" to "https://bit.ly/2TIt8NR", 29 | ), 30 | ) 31 | client.connectUser( 32 | user = user, 33 | token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidHV0b3JpYWwtZHJvaWQifQ.NhEr0hP9W9nwqV7ZkdShxvi02C5PR7SJE7Cs4y7kyqg" 34 | ).enqueue() 35 | 36 | setContent { 37 | ChatTheme(colors = createStreamColors()) { 38 | ChannelsScreen( 39 | title = stringResource(id = R.string.app_name), 40 | onItemClick = { channel -> 41 | startActivity(MessagesActivity.getIntent(this, channel.cid)) 42 | }, 43 | onBackPressed = this::finish, 44 | ) 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/src/main/java/com/example/matyoudemo/MessagesActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.matyoudemo 2 | 3 | import android.content.Context 4 | import android.content.Intent 5 | import android.os.Bundle 6 | import androidx.activity.compose.setContent 7 | import androidx.appcompat.app.AppCompatActivity 8 | import io.getstream.chat.android.compose.ui.messages.MessagesScreen 9 | import io.getstream.chat.android.compose.ui.theme.ChatTheme 10 | 11 | class MessagesActivity : AppCompatActivity() { 12 | 13 | override fun onCreate(savedInstanceState: Bundle?) { 14 | super.onCreate(savedInstanceState) 15 | val channelId = intent.getStringExtra(KEY_CHANNEL_ID) 16 | 17 | if (channelId == null) { 18 | finish() 19 | return 20 | } 21 | 22 | setContent { 23 | ChatTheme(colors = createStreamColors()) { 24 | MessagesScreen( 25 | channelId = channelId, 26 | messageLimit = 30, 27 | onBackPressed = { finish() } 28 | ) 29 | } 30 | } 31 | } 32 | 33 | companion object { 34 | private const val KEY_CHANNEL_ID = "channelId" 35 | 36 | fun getIntent(context: Context, channelId: String): Intent { 37 | return Intent(context, MessagesActivity::class.java).apply { 38 | putExtra(KEY_CHANNEL_ID, channelId) 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsmb13/MaterialYouChatDemo/dd9f141a88cfc742339be9536987ce4f275f10ac/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsmb13/MaterialYouChatDemo/dd9f141a88cfc742339be9536987ce4f275f10ac/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsmb13/MaterialYouChatDemo/dd9f141a88cfc742339be9536987ce4f275f10ac/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsmb13/MaterialYouChatDemo/dd9f141a88cfc742339be9536987ce4f275f10ac/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsmb13/MaterialYouChatDemo/dd9f141a88cfc742339be9536987ce4f275f10ac/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsmb13/MaterialYouChatDemo/dd9f141a88cfc742339be9536987ce4f275f10ac/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsmb13/MaterialYouChatDemo/dd9f141a88cfc742339be9536987ce4f275f10ac/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsmb13/MaterialYouChatDemo/dd9f141a88cfc742339be9536987ce4f275f10ac/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsmb13/MaterialYouChatDemo/dd9f141a88cfc742339be9536987ce4f275f10ac/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsmb13/MaterialYouChatDemo/dd9f141a88cfc742339be9536987ce4f275f10ac/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Material You Compose Demo 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 21 | 22 |