Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 54eb1c0

Browse files
JoseAlcerrecaGerrit Code Review
authored and
Gerrit Code Review
committedJun 11, 2020
Merge "[Jetchat] Adds ktlint" into jetapps
2 parents 4076ba3 + a844c64 commit 54eb1c0

File tree

12 files changed

+45
-22
lines changed

12 files changed

+45
-22
lines changed
 

‎JetChat/app/build.gradle

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ android {
5959

6060
}
6161

62+
configurations {
63+
ktlint
64+
}
65+
6266
dependencies {
6367

6468
// TODO: Tidy up
@@ -91,4 +95,19 @@ dependencies {
9195
androidTestImplementation("androidx.ui:ui-core:$compose_version")
9296
androidTestImplementation("androidx.ui:ui-test:$compose_version")
9397

94-
}
98+
ktlint "com.pinterest:ktlint:0.37.0"
99+
}
100+
101+
task ktlint(type: JavaExec, group: "verification") {
102+
description = "Check Kotlin code style."
103+
main = "com.pinterest.ktlint.Main"
104+
classpath = configurations.ktlint
105+
args "src/**/*.kt"
106+
}
107+
check.dependsOn ktlint
108+
task ktlintFormat(type: JavaExec, group: "formatting") {
109+
description = "Fix Kotlin code style deviations."
110+
main = "com.pinterest.ktlint.Main"
111+
classpath = configurations.ktlint
112+
args "-F", "src/**/*.kt"
113+
}

‎JetChat/app/src/androidTest/java/com/example/compose/jetchat/ConversationTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ class ConversationTest {
3333
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
3434
assertEquals("com.example.compose.jetchat", appContext.packageName)
3535
}
36-
}
36+
}

‎JetChat/app/src/main/java/com/example/compose/jetchat/NavActivity.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class NavActivity : AppCompatActivity() {
4848
appBarConfiguration = AppBarConfiguration(
4949
setOf(
5050
R.id.nav_home, R.id.nav_profile
51-
), drawerLayout
51+
),
52+
drawerLayout
5253
)
5354
navView.setupWithNavController(navController)
5455
}

‎JetChat/app/src/main/java/com/example/compose/jetchat/UiExtras.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import androidx.ui.material.AlertDialog
2222
import androidx.ui.material.MaterialTheme
2323
import androidx.ui.material.TextButton
2424

25-
2625
@Composable
2726
fun FunctionalityNotAvailablePopup(onDismiss: () -> Unit) {
2827
AlertDialog(

‎JetChat/app/src/main/java/com/example/compose/jetchat/conversation/Conversation.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ fun Messages(
199199
}
200200

201201
// Scroll to last message
202-
if (!userScrolled // Don't scroll if the user triggered the scrolling
203-
&& scrollerPosition.atBottom() // Don't scroll if already at the bottom
202+
if (!userScrolled && // Don't scroll if the user triggered the scrolling
203+
scrollerPosition.atBottom() // Don't scroll if already at the bottom
204204
) {
205205
// Scroll smoothly after the first scroll
206206
scrollerPosition.smoothScrollTo(scrollerPosition.maxPosition)
@@ -239,7 +239,7 @@ fun Messages(
239239
// Apply the threshold:
240240
val jumpToBottomButtonEnabled = (
241241
scrollerPosition.value < scrollerPosition.maxPosition - jumpThreshold
242-
)
242+
)
243243

244244
JumpToBottom(
245245
// Only show if the scroller is not at the bottom
@@ -250,7 +250,6 @@ fun Messages(
250250
},
251251
modifier = Modifier.gravity(Alignment.BottomCenter)
252252
)
253-
254253
}
255254
}
256255

@@ -299,7 +298,9 @@ fun AuthorAndTextMessage(
299298
Column(modifier = modifier) {
300299
Row {
301300
ProvideEmphasis(emphasis = EmphasisAmbient.current.high) {
302-
Text(text = msg.author, style = MaterialTheme.typography.subtitle1,
301+
Text(
302+
text = msg.author,
303+
style = MaterialTheme.typography.subtitle1,
303304
modifier = Modifier.alignWithSiblings(LastBaseline)
304305
)
305306
}

‎JetChat/app/src/main/java/com/example/compose/jetchat/conversation/ConversationFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ import com.example.compose.jetchat.theme.JetchatTheme
3434
class ConversationFragment : Fragment() {
3535

3636
override fun onCreateView(
37-
inflater: LayoutInflater, container: ViewGroup?,
37+
inflater: LayoutInflater,
38+
container: ViewGroup?,
3839
savedInstanceState: Bundle?
3940
): View? {
4041
return FrameLayout(requireContext()).apply {

‎JetChat/app/src/main/java/com/example/compose/jetchat/conversation/ConversationUiState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ val exampleUiState = ConversationUiState(
8989
initialMessages = initialMessages,
9090
channelName = "#composers",
9191
channelMembers = 42
92-
)
92+
)

‎JetChat/app/src/main/java/com/example/compose/jetchat/conversation/JumpToBottom.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private enum class Visibility {
5656
/**
5757
* Shows a button that lets the user scroll to the bottom.
5858
*/
59-
//TODO: when a new message is added, the button shows up while the scroll is animating.
59+
// TODO: when a new message is added, the button shows up while the scroll is animating.
6060
@Composable
6161
fun JumpToBottom(
6262
enabled: Boolean,
@@ -84,7 +84,7 @@ fun JumpToBottom(
8484
contentColor = MaterialTheme.colors.primary,
8585
modifier = modifier
8686
.padding(bottom = transition[bottomPadding]) // TODO: Replace with:
87-
//.offset(x = 0.dp, y = -transition[bottomPadding]) // b/155868092
87+
// .offset(x = 0.dp, y = -transition[bottomPadding]) // b/155868092
8888
.preferredHeight(36.dp)
8989
) {
9090
Row(modifier = Modifier.padding(vertical = 10.dp, horizontal = 16.dp)) {

‎JetChat/app/src/main/java/com/example/compose/jetchat/conversation/UserInput.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private fun SelectorExpanded(
136136
onCloseRequested: () -> Unit,
137137
onTextAdded: (String) -> Unit
138138
) {
139-
when(currentSelector) {
139+
when (currentSelector) {
140140
InputSelector.MAP -> MapSelector()
141141
InputSelector.THUMBS_UP -> StickerSelector()
142142
InputSelector.EMOJI -> EmojiSelector(onTextAdded)
@@ -298,12 +298,14 @@ fun EmojiSelector(
298298
onClick = { onTextAdded(emoji) },
299299
modifier = Modifier
300300
.preferredSize(42.dp, 42.dp)
301-
.ripple()) {
301+
.ripple()
302+
) {
302303
Text(
303304
text = emoji,
304305
style = currentTextStyle().copy(
305306
fontSize = 18.sp,
306-
textAlign = TextAlign.Center)
307+
textAlign = TextAlign.Center
308+
)
307309
)
308310
}
309311
}

‎JetChat/app/src/main/java/com/example/compose/jetchat/profile/Profile.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ fun ProfileScreen(userData: ProfileScreenState) {
8181
)
8282
ProfileButtonsRow()
8383
UserInfoFields(userData)
84-
8584
}
8685
}
8786
}

‎JetChat/app/src/main/java/com/example/compose/jetchat/profile/ProfileFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class ProfileFragment : Fragment() {
4242
}
4343

4444
override fun onCreateView(
45-
inflater: LayoutInflater, container: ViewGroup?,
45+
inflater: LayoutInflater,
46+
container: ViewGroup?,
4647
savedInstanceState: Bundle?
4748
): View? {
4849

‎Jetsnack/app/src/main/java/com/example/jetsnack/ui/theme/Shape.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.example.jetsnack.ui.theme
17+
package com.example.compose.jetchat.theme
1818

1919
import androidx.ui.foundation.shape.corner.RoundedCornerShape
2020
import androidx.ui.material.Shapes
2121
import androidx.ui.unit.dp
2222

23-
val Shapes = Shapes(
24-
small = RoundedCornerShape(4.dp),
25-
medium = RoundedCornerShape(4.dp),
23+
val JetchatShapes = Shapes(
24+
small = RoundedCornerShape(28.dp),
25+
medium = RoundedCornerShape(8.dp),
2626
large = RoundedCornerShape(0.dp)
2727
)

0 commit comments

Comments
 (0)