Skip to content

Commit 3533853

Browse files
committed
Fix some minor bits in code, update build scripts from newly generated projects
1 parent 21c88db commit 3533853

File tree

7 files changed

+52
-50
lines changed

7 files changed

+52
-50
lines changed

build.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
21
buildscript {
3-
ext.kotlin_version = '1.4.10'
2+
ext.kotlin_version = "1.4.30"
43
repositories {
54
google()
65
jcenter()
7-
maven { url "https://jitpack.io" }
86
}
97
dependencies {
10-
classpath "com.android.tools.build:gradle:4.1.0"
8+
classpath "com.android.tools.build:gradle:4.1.2"
119
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1210
}
1311
}
1412

1513
allprojects {
1614
repositories {
1715
google()
18-
jcenter()
16+
mavenCentral()
1917
maven { url "https://jitpack.io" }
18+
jcenter()
2019
}
2120
}
2221

2322
task clean(type: Delete) {
2423
delete rootProject.buildDir
25-
}
24+
}

samplejava/build.gradle

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
2-
apply plugin: 'com.android.application'
3-
apply plugin: 'kotlin-android'
4-
apply plugin: 'kotlin-android-extensions'
1+
plugins {
2+
id 'com.android.application'
3+
}
54

65
android {
76
compileSdkVersion 30
7+
buildToolsVersion "30.0.2"
8+
89
defaultConfig {
910
applicationId "com.example.chattutorial"
1011
minSdkVersion 21
1112
targetSdkVersion 30
1213
versionCode 1
1314
versionName "1.0"
14-
ndkVersion "21.3.6528147"
15+
1516
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1617
}
1718

@@ -21,27 +22,26 @@ android {
2122
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2223
}
2324
}
24-
2525
compileOptions {
2626
sourceCompatibility JavaVersion.VERSION_1_8
2727
targetCompatibility JavaVersion.VERSION_1_8
2828
}
2929

30+
// Enable ViewBinding
3031
buildFeatures {
3132
viewBinding true
3233
}
33-
34-
packagingOptions {
35-
exclude 'META-INF/*.kotlin_module'
36-
}
3734
}
3835

3936
dependencies {
37+
// Add new dependencies
4038
implementation "io.getstream:stream-chat-android-ui-components:4.5.3"
4139
implementation 'io.coil-kt:coil:1.1.1'
4240

43-
implementation "androidx.recyclerview:recyclerview:1.1.0"
44-
implementation "androidx.appcompat:appcompat:1.2.0"
45-
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
46-
implementation "com.google.android.material:material:1.3.0"
41+
implementation 'androidx.appcompat:appcompat:1.2.0'
42+
implementation 'com.google.android.material:material:1.3.0'
43+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
44+
testImplementation 'junit:junit:4.+'
45+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
46+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
4747
}

samplejava/src/main/java/com/example/chattutorialjava/ChannelActivity3.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.getstream.sdk.chat.viewmodel.messages.MessageListViewModel.Mode.Thread;
2121
import com.getstream.sdk.chat.viewmodel.messages.MessageListViewModel.State.NavigateUp;
2222

23-
import java.util.LinkedList;
23+
import java.util.ArrayList;
2424
import java.util.List;
2525

2626
import io.getstream.chat.android.client.models.Channel;
@@ -31,7 +31,6 @@
3131
import io.getstream.chat.android.ui.messages.header.MessagesHeaderView;
3232
import io.getstream.chat.android.ui.messages.view.MessageListViewModelBinding;
3333
import io.getstream.chat.android.ui.textinput.MessageInputViewModelBinding;
34-
import kotlin.Unit;
3534

3635
public class ChannelActivity3 extends AppCompatActivity {
3736

@@ -119,11 +118,12 @@ public void handleOnBackPressed() {
119118

120119
// Observe typing users
121120
channelController.getTyping().observe(this, typingState -> {
122-
if (typingState.getUsers().isEmpty()) {
121+
final List<User> users = typingState.getUsers();
122+
if (users.isEmpty()) {
123123
typingHeaderView.setText(nobodyTyping);
124124
} else {
125-
List<String> userNames = new LinkedList<>();
126-
for (User user : typingState.getUsers()) {
125+
List<String> userNames = new ArrayList<>(users.size());
126+
for (User user : users) {
127127
userNames.add((String) user.getExtraData().get("name"));
128128
}
129129
String typing = "typing: " + TextUtils.join(", ", userNames);

samplejava/src/main/java/com/example/chattutorialjava/ChannelActivity4.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import io.getstream.chat.android.ui.messages.header.MessagesHeaderView;
3333
import io.getstream.chat.android.ui.messages.view.MessageListViewModelBinding;
3434
import io.getstream.chat.android.ui.textinput.MessageInputViewModelBinding;
35-
import kotlin.Unit;
3635

3736
public class ChannelActivity4 extends AppCompatActivity {
3837

samplekotlin/build.gradle

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
apply plugin: 'com.android.application'
2-
apply plugin: 'kotlin-android'
1+
plugins {
2+
id 'com.android.application'
3+
id 'kotlin-android'
4+
}
35

46
android {
57
compileSdkVersion 30
8+
buildToolsVersion "30.0.2"
9+
610
defaultConfig {
7-
applicationId "com.example.chattutorial"
11+
applicationId "com.example.chattutorial0209"
812
minSdkVersion 21
913
targetSdkVersion 30
1014
versionCode 1
1115
versionName "1.0"
12-
ndkVersion "21.3.6528147"
16+
1317
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1418
}
1519

@@ -19,33 +23,30 @@ android {
1923
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2024
}
2125
}
22-
2326
compileOptions {
2427
sourceCompatibility JavaVersion.VERSION_1_8
2528
targetCompatibility JavaVersion.VERSION_1_8
2629
}
27-
2830
kotlinOptions {
29-
jvmTarget = JavaVersion.VERSION_1_8.toString()
31+
jvmTarget = '1.8'
3032
}
3133

3234
buildFeatures {
3335
viewBinding true
3436
}
35-
36-
packagingOptions {
37-
exclude 'META-INF/*.kotlin_module'
38-
}
3937
}
4038

4139
dependencies {
40+
// Add new dependencies
4241
implementation "io.getstream:stream-chat-android-ui-components:4.5.3"
4342
implementation 'io.coil-kt:coil:1.1.1'
4443

45-
implementation "androidx.recyclerview:recyclerview:1.1.0"
46-
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0-rc01'
47-
implementation "androidx.appcompat:appcompat:1.2.0"
48-
implementation "androidx.constraintlayout:constraintlayout:2.0.4"
49-
implementation 'androidx.activity:activity-ktx:1.1.0'
50-
implementation "com.google.android.material:material:1.3.0"
44+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
45+
implementation 'androidx.core:core-ktx:1.3.2'
46+
implementation 'androidx.appcompat:appcompat:1.2.0'
47+
implementation 'com.google.android.material:material:1.3.0'
48+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
49+
testImplementation 'junit:junit:4.+'
50+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
51+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
5152
}

samplekotlin/src/main/java/com/example/chattutorial/ChannelActivity4.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import io.getstream.chat.android.client.channel.subscribeFor
1919
import io.getstream.chat.android.client.events.TypingStartEvent
2020
import io.getstream.chat.android.client.events.TypingStopEvent
2121
import io.getstream.chat.android.client.models.Channel
22+
import io.getstream.chat.android.client.models.name
2223
import io.getstream.chat.android.ui.messages.header.bindView
2324
import io.getstream.chat.android.ui.messages.view.bindView
2425
import io.getstream.chat.android.ui.textinput.bindView
@@ -95,9 +96,8 @@ class ChannelActivity4 : AppCompatActivity() {
9596
this, TypingStartEvent::class, TypingStopEvent::class
9697
) { event ->
9798
when (event) {
98-
is TypingStartEvent -> currentlyTyping.add(event.user.extraData["name"] as String)
99-
is TypingStopEvent -> currentlyTyping.remove(event.user.extraData["name"] as String)
100-
else -> Unit
99+
is TypingStartEvent -> currentlyTyping.add(event.user.name)
100+
is TypingStopEvent -> currentlyTyping.remove(event.user.name)
101101
}
102102

103103
binding.typingHeaderView.text = when {

samplekotlin/src/main/java/com/example/chattutorial/MainActivity.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,13 @@ class MainActivity : AppCompatActivity() {
3333
ChatUI.Builder(applicationContext).build()
3434

3535
// Step 2 - Authenticate and connect the user
36-
val user = User("summer-brook-2").apply {
37-
extraData["name"] = "Paranoid Android"
38-
extraData["image"] = "https://bit.ly/2TIt8NR"
39-
}
36+
val user = User(
37+
id = "summer-brook-2",
38+
extraData = mutableMapOf(
39+
"name" to "Paranoid Android",
40+
"image" to "https://bit.ly/2TIt8NR",
41+
),
42+
)
4043
client.connectUser(
4144
user = user,
4245
token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoic3VtbWVyLWJyb29rLTIifQ.CzyOx8kgrc61qVbzWvhV1WD3KPEo5ZFZH-326hIdKz0"

0 commit comments

Comments
 (0)