Skip to content

Commit d1293bd

Browse files
authored
Merge pull request #56 from GetStream/feature/4.17.2
Update tutorial for 4.17.2
2 parents 34a1ba1 + 704ca7b commit d1293bd

File tree

15 files changed

+78
-83
lines changed

15 files changed

+78
-83
lines changed

.github/workflows/pull-request.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ jobs:
99

1010
steps:
1111
- uses: actions/checkout@v2
12-
- name: set up JDK 1.8
13-
uses: actions/setup-java@v1
12+
- name: Set up JDK 11
13+
uses: actions/setup-java@v2
1414
with:
15-
java-version: 1.8
15+
distribution: adopt
16+
java-version: 11
1617
- name: Build app
1718
run: ./gradlew assembleDebug

build.gradle

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
11
buildscript {
2-
ext.kotlin_version = "1.5.10"
32
repositories {
43
google()
54
mavenCentral()
65
}
76
dependencies {
8-
classpath "com.android.tools.build:gradle:4.2.1"
9-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
10-
}
11-
}
12-
13-
allprojects {
14-
repositories {
15-
google()
16-
mavenCentral()
17-
maven { url "https://jitpack.io" }
7+
classpath "com.android.tools.build:gradle:7.0.1"
8+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"
189
}
1910
}
2011

samplejava/build.gradle

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ plugins {
33
}
44

55
android {
6-
compileSdkVersion 30
7-
buildToolsVersion "30.0.3"
6+
compileSdk 31
87

98
defaultConfig {
109
applicationId "com.example.chattutorial"
11-
minSdkVersion 21
12-
targetSdkVersion 30
10+
minSdk 21
11+
targetSdk 31
1312
versionCode 1
1413
versionName "1.0"
1514

@@ -31,13 +30,13 @@ android {
3130

3231
dependencies {
3332
// Add new dependencies
34-
implementation "io.getstream:stream-chat-android-ui-components:4.12.1"
35-
implementation 'io.coil-kt:coil:1.2.1'
33+
implementation "io.getstream:stream-chat-android-ui-components:4.17.2"
34+
implementation 'io.coil-kt:coil:1.3.2'
3635

37-
implementation 'androidx.appcompat:appcompat:1.3.0'
38-
implementation 'com.google.android.material:material:1.3.0'
39-
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
36+
implementation 'androidx.appcompat:appcompat:1.3.1'
37+
implementation 'com.google.android.material:material:1.4.0'
38+
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
4039
testImplementation 'junit:junit:4.+'
41-
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
42-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
43-
}
40+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
41+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
42+
}

samplejava/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
android:roundIcon="@mipmap/ic_launcher_round"
1010
android:supportsRtl="true"
1111
android:theme="@style/Theme.ChatTutorial">
12-
<activity android:name=".MainActivity">
12+
<activity
13+
android:name=".MainActivity"
14+
android:exported="true">
1315
<intent-filter>
1416
<action android:name="android.intent.action.MAIN" />
1517

samplejava/src/main/java/com/example/chattutorial/ChannelActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
8989
MessageListHeaderView.OnClickListener backHandler = () -> {
9090
messageListViewModel.onEvent(MessageListViewModel.Event.BackButtonPressed.INSTANCE);
9191
};
92-
9392
binding.messageListHeaderView.setBackButtonClickListener(backHandler);
94-
9593
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
9694
@Override
9795
public void handleOnBackPressed() {

samplejava/src/main/java/com/example/chattutorial/ChannelActivity2.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,21 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7676
}
7777
});
7878

79-
// Step 4 - Handle navigate up state
79+
// Step 4 - Let the message input know when we are editing a message
80+
binding.messageListView.setMessageEditHandler(messageInputViewModel::postMessageToEdit);
81+
82+
// Step 5 - Handle navigate up state
8083
messageListViewModel.getState().observe(this, state -> {
8184
if (state instanceof NavigateUp) {
8285
finish();
8386
}
8487
});
8588

86-
// Step 5 - Let the message input know when we are editing a message
87-
binding.messageListView.setMessageEditHandler(messageInputViewModel::postMessageToEdit);
88-
8989
// Step 6 - Handle back button behaviour correctly when you're in a thread
9090
MessageListHeaderView.OnClickListener backHandler = () -> {
9191
messageListViewModel.onEvent(MessageListViewModel.Event.BackButtonPressed.INSTANCE);
9292
};
93-
9493
binding.messageListHeaderView.setBackButtonClickListener(backHandler);
95-
9694
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
9795
@Override
9896
public void handleOnBackPressed() {

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import com.getstream.sdk.chat.viewmodel.messages.MessageListViewModel.Mode.Thread;
1919
import com.getstream.sdk.chat.viewmodel.messages.MessageListViewModel.State.NavigateUp;
2020

21-
import java.util.ArrayList;
21+
import java.util.LinkedList;
2222
import java.util.List;
2323

2424
import io.getstream.chat.android.client.models.Channel;
@@ -84,16 +84,16 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
8484
}
8585
});
8686

87-
// Step 4 - Handle navigate up state
87+
// Step 4 - Let the message input know when we are editing a message
88+
binding.messageListView.setMessageEditHandler(messageInputViewModel::postMessageToEdit);
89+
90+
// Step 5 - Handle navigate up state
8891
messageListViewModel.getState().observe(this, state -> {
8992
if (state instanceof NavigateUp) {
9093
finish();
9194
}
9295
});
9396

94-
// Step 5 - Let the message input know when we are editing a message
95-
binding.messageListView.setMessageEditHandler(messageInputViewModel::postMessageToEdit);
96-
9797
// Step 6 - Handle back button behaviour correctly when you're in a thread
9898
MessageListHeaderView.OnClickListener backHandler = () -> {
9999
messageListViewModel.onEvent(MessageListViewModel.Event.BackButtonPressed.INSTANCE);
@@ -119,12 +119,11 @@ public void handleOnBackPressed() {
119119

120120
// Observe typing users
121121
channelController.getTyping().observe(this, typingState -> {
122-
final List<User> users = typingState.getUsers();
123-
if (users.isEmpty()) {
122+
if (typingState.getUsers().isEmpty()) {
124123
typingHeaderView.setText(nobodyTyping);
125124
} else {
126-
List<String> userNames = new ArrayList<>(users.size());
127-
for (User user : users) {
125+
List<String> userNames = new LinkedList<>();
126+
for (User user : typingState.getUsers()) {
128127
userNames.add((String) user.getExtraData().get("name"));
129128
}
130129
String typing = "typing: " + TextUtils.join(", ", userNames);

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
7373
MessageListViewModelBinding.bind(messageListViewModel, binding.messageListView, this);
7474
MessageInputViewModelBinding.bind(messageInputViewModel, binding.messageInputView, this);
7575

76-
// Step 3 - Let both message list header and message input know when we open a thread
76+
// Step 3 - Let both MessageListHeaderView and MessageInputView know when we open a thread
7777
messageListViewModel.getMode().observe(this, mode -> {
7878
if (mode instanceof Thread) {
7979
Message parentMessage = ((Thread) mode).getParentMessage();
@@ -85,23 +85,21 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
8585
}
8686
});
8787

88-
// Step 4 - Handle navigate up state
88+
// Step 4 - Let the message input know when we are editing a message
89+
binding.messageListView.setMessageEditHandler(messageInputViewModel::postMessageToEdit);
90+
91+
// Step 5 - Handle navigate up state
8992
messageListViewModel.getState().observe(this, state -> {
9093
if (state instanceof NavigateUp) {
9194
finish();
9295
}
9396
});
9497

95-
// Step 5 - Let the message input know when we are editing a message
96-
binding.messageListView.setMessageEditHandler(messageInputViewModel::postMessageToEdit);
97-
9898
// Step 6 - Handle back button behaviour correctly when you're in a thread
9999
MessageListHeaderView.OnClickListener backHandler = () -> {
100100
messageListViewModel.onEvent(MessageListViewModel.Event.BackButtonPressed.INSTANCE);
101101
};
102-
103102
binding.messageListHeaderView.setBackButtonClickListener(backHandler);
104-
105103
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
106104
@Override
107105
public void handleOnBackPressed() {

samplejava/src/main/java/com/example/chattutorial/MainActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
6666
// Step 4 - Connect the ChannelListViewModel to the ChannelListView, loose
6767
// coupling makes it easy to customize
6868
ChannelListViewModelBinding.bind(channelsViewModel, binding.channelListView, this);
69-
binding.channelListView.setChannelItemClickListener(channel -> {
70-
startActivity(ChannelActivity4.newIntent(this, channel));
71-
});
69+
binding.channelListView.setChannelItemClickListener(
70+
channel -> startActivity(ChannelActivity4.newIntent(this, channel))
71+
);
7272
}
7373
}

samplekotlin/build.gradle

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ plugins {
44
}
55

66
android {
7-
compileSdkVersion 30
8-
buildToolsVersion "30.0.3"
7+
compileSdk 31
98

109
defaultConfig {
1110
applicationId "com.example.chattutorial"
12-
minSdkVersion 21
13-
targetSdkVersion 30
11+
minSdk 21
12+
targetSdk 31
1413
versionCode 1
1514
versionName "1.0"
1615

@@ -32,16 +31,15 @@ android {
3231

3332
dependencies {
3433
// Add new dependencies
35-
implementation "io.getstream:stream-chat-android-ui-components:4.12.1"
36-
implementation 'io.coil-kt:coil:1.2.1'
37-
implementation "androidx.activity:activity-ktx:1.2.3"
34+
implementation "io.getstream:stream-chat-android-ui-components:4.17.2"
35+
implementation 'io.coil-kt:coil:1.3.2'
36+
implementation "androidx.activity:activity-ktx:1.3.1"
3837

39-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
40-
implementation 'androidx.core:core-ktx:1.5.0'
41-
implementation 'androidx.appcompat:appcompat:1.3.0'
42-
implementation 'com.google.android.material:material:1.3.0'
43-
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
38+
implementation 'androidx.core:core-ktx:1.6.0'
39+
implementation 'androidx.appcompat:appcompat:1.3.1'
40+
implementation 'com.google.android.material:material:1.4.0'
41+
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
4442
testImplementation 'junit:junit:4.+'
45-
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
46-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
43+
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
44+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
4745
}

0 commit comments

Comments
 (0)