Skip to content

Commit a124d88

Browse files
Lukas Dylanlukasdylan
authored andcommitted
Migrate Library UI to Jetpack Compose
1 parent 845f1d7 commit a124d88

38 files changed

+694
-774
lines changed

build.gradle

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22

33
buildscript {
4-
ext.kotlin_version = '1.5.20'
5-
ext.appVersionString = "1.0.14"
6-
ext.appVersionCode = 8
4+
ext.kotlin_version = '1.5.21'
5+
ext.appVersionString = "1.1.0"
6+
ext.appVersionCode = 18
77
repositories {
88
google()
9-
jcenter()
109
mavenCentral()
1110
}
1211
dependencies {
13-
classpath 'com.android.tools.build:gradle:4.1.3'
12+
classpath 'com.android.tools.build:gradle:7.1.0-alpha05'
1413
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1514
// NOTE: Do not place your application dependencies here; they belong
1615
// in the individual module build.gradle files
@@ -24,7 +23,6 @@ plugins {
2423
allprojects {
2524
repositories {
2625
google()
27-
jcenter()
2826
mavenCentral()
2927
}
3028
}

config/library.gradle

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ apply plugin: 'kotlin-android'
44

55
apply plugin: 'kotlin-kapt'
66

7-
apply plugin: 'kotlin-parcelize'
8-
97
android {
108
compileSdkVersion 30
11-
buildToolsVersion "29.0.3"
9+
buildToolsVersion "30.0.3"
1210
defaultConfig {
13-
minSdkVersion 16
11+
minSdkVersion 21
1412
targetSdkVersion 30
1513
versionCode 1
1614
versionName "1.0.0"
@@ -45,5 +43,21 @@ android {
4543
}
4644
}
4745

46+
kotlinOptions {
47+
jvmTarget = "1.8"
48+
}
49+
50+
buildFeatures {
51+
compose = true
52+
}
53+
54+
kapt {
55+
correctErrorTypes = true
56+
}
57+
58+
composeOptions {
59+
kotlinCompilerExtensionVersion '1.0.1'
60+
}
61+
4862
resourcePrefix 'protodroid_'
4963
}

config/publish.gradle

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
apply plugin: 'maven-publish'
2-
apply plugin: 'maven'
32
apply plugin: 'signing'
43

54
group = 'com.github.lukasdylan'
@@ -75,7 +74,6 @@ private String generateVersionName() {
7574
if (project.hasProperty("versionName")) {
7675
name = project.versionName
7776
}
78-
println("Version Name: " + name)
7977
return name
8078
}
8179

@@ -84,7 +82,6 @@ private Integer generateVersionCode() {
8482
if (project.hasProperty("versionCode")) {
8583
code = Integer.parseInt(versionCode)
8684
}
87-
println("Version Code: " + code)
8885
return code
8986
}
9087

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip

protodroid-no-op/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apply from: "$rootDir/config/library.gradle"
22
apply from: "$rootDir/config/publish.gradle"
33

44
dependencies {
5-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6-
implementation 'androidx.appcompat:appcompat:1.3.1'
75
implementation 'io.grpc:grpc-protobuf-lite:1.36.0'
6+
implementation 'androidx.activity:activity-compose:1.3.1'
7+
implementation 'androidx.compose.compiler:compiler:1.0.1'
88
testImplementation 'junit:junit:4.13.2'
99
}

protodroid/build.gradle

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ apply from: "$rootDir/config/library.gradle"
22
apply from: "$rootDir/config/publish.gradle"
33

44
dependencies {
5-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
6-
implementation 'androidx.appcompat:appcompat:1.3.1'
7-
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
85
implementation 'androidx.room:room-ktx:2.3.0'
96
implementation 'androidx.room:room-runtime:2.3.0'
10-
implementation 'com.google.android.material:material:1.5.0-alpha01'
117
implementation 'io.grpc:grpc-protobuf-lite:1.36.0'
128
implementation 'com.jakewharton.timber:timber:4.7.1'
139
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.1'
1410
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.1'
11+
implementation 'androidx.compose.ui:ui:1.0.1'
12+
implementation 'androidx.compose.material:material:1.0.1'
13+
implementation 'androidx.compose.ui:ui-tooling:1.0.1'
14+
implementation 'androidx.compose.foundation:foundation:1.0.1'
15+
implementation 'androidx.compose.compiler:compiler:1.0.1'
16+
implementation 'androidx.activity:activity-compose:1.3.1'
17+
implementation 'androidx.navigation:navigation-compose:2.4.0-alpha06'
18+
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07'
19+
implementation "com.google.accompanist:accompanist-pager:0.16.0"
20+
implementation "com.google.accompanist:accompanist-pager-indicators:0.16.0"
1521
kapt "androidx.room:room-compiler:2.3.0"
1622
testImplementation 'junit:junit:4.13.2'
1723
}

protodroid/src/main/AndroidManifest.xml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,26 @@
44
<application>
55

66
<activity
7-
android:name=".internal.ui.MainActivity"
8-
android:launchMode="singleTop"
9-
android:screenOrientation="portrait"
10-
android:taskAffinity="id.lukasdylan.grpc.protodroid.task"
11-
android:theme="@style/Protodroid.Theme" />
7+
android:name=".internal.ui.ProtodroidActivity"
8+
android:exported="true"
9+
android:launchMode="singleTask"
10+
android:taskAffinity=""
11+
android:excludeFromRecents="true"
12+
android:screenOrientation="portrait">
1213

13-
<activity
14-
android:name=".internal.ui.detail.DetailActivity"
15-
android:launchMode="singleTop"
16-
android:screenOrientation="portrait"
17-
android:theme="@style/Protodroid.Theme" />
14+
<intent-filter>
15+
<action android:name="android.intent.action.VIEW" />
16+
<category android:name="android.intent.category.DEFAULT" />
17+
<category android:name="android.intent.category.BROWSABLE" />
18+
19+
<data
20+
android:host="detail"
21+
android:scheme="protodroid" />
22+
23+
</intent-filter>
24+
25+
</activity>
1826

1927
</application>
28+
2029
</manifest>

protodroid/src/main/java/id/lukasdylan/grpc/protodroid/ProtodroidInterceptor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import io.grpc.*
1212
*/
1313
open class ProtodroidInterceptor(context: Context) : ClientInterceptor {
1414

15-
private var repository: ProtodroidRepository? = null
16-
private var notificationListener: ProtodroidNotificationListener? = null
15+
private val repository: ProtodroidRepository
16+
private val notificationListener: ProtodroidNotificationListener
1717

1818
init {
1919
with(Protodroid.getInstance(context.applicationContext)) {

protodroid/src/main/java/id/lukasdylan/grpc/protodroid/internal/Logger.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@ package id.lukasdylan.grpc.protodroid.internal
22

33
import timber.log.Timber
44

5-
internal fun printLogRequest(lastState: DataState) {
5+
internal fun DataState.printLogRequest() {
66
val stringBuilder = StringBuilder(".")
77
.appendLine()
88
.appendLine("----- Service URL: -----")
9-
.appendLine(lastState.serviceUrl)
9+
.appendLine(serviceUrl)
1010
.appendLine("----- Service Name: -----")
11-
.appendLine(lastState.serviceName)
11+
.appendLine(serviceName)
1212
.appendLine("----- Request Header: -----")
13-
.appendLine(lastState.requestHeader)
13+
.appendLine(requestHeader)
1414
.appendLine("----- Request Body: -----")
15-
.appendLine(lastState.requestBody)
15+
.appendLine(requestBody)
1616
Timber.tag("GRPC").d(stringBuilder.toString())
1717
}
1818

19-
internal fun printLogFullResponse(lastState: DataState) {
19+
internal fun DataState.printLogFullResponse() {
2020
val stringBuilder = StringBuilder(".")
2121
.appendLine()
2222
.appendLine("----- Service URL: -----")
23-
.appendLine(lastState.serviceUrl)
23+
.appendLine(serviceUrl)
2424
.appendLine("----- Service Name: -----")
25-
.appendLine(lastState.serviceName)
25+
.appendLine(serviceName)
2626
.appendLine("----- Response Header: -----")
27-
.appendLine(lastState.responseHeader)
27+
.appendLine(responseHeader)
2828
.appendLine("----- Response Body: -----")
29-
.appendLine(lastState.responseBody)
29+
.appendLine(responseBody)
3030
Timber.tag("GRPC").d(stringBuilder.toString())
3131
}

protodroid/src/main/java/id/lukasdylan/grpc/protodroid/internal/ProtodroidDataDiffCallback.kt

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)