Skip to content

Commit 7b5f4ae

Browse files
committed
Implement JetPack Compose
This commit reimplements the UI with JetPack Compose.
1 parent ccefd8c commit 7b5f4ae

File tree

110 files changed

+4612
-1422
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+4612
-1422
lines changed

app/build.gradle

+79-24
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1+
import com.android.build.api.dsl.ManagedVirtualDevice
2+
3+
plugins {
4+
id 'com.google.devtools.ksp' version '1.7.10-1.0.6'
5+
}
6+
17
apply plugin: 'com.android.application'
28
apply plugin: 'kotlin-android'
39
apply plugin: 'kotlin-kapt'
4-
apply plugin: "androidx.navigation.safeargs.kotlin"
10+
apply plugin: "androidx.navigation.safeargs"
511
apply plugin: 'com.google.firebase.crashlytics'
612
apply plugin: 'com.google.gms.google-services'
713
apply plugin: 'dagger.hilt.android.plugin'
8-
apply plugin: 'com.mikepenz.aboutlibraries.plugin'
914
apply plugin: 'com.google.firebase.firebase-perf'
1015
apply plugin: 'com.github.triplet.play'
16+
apply plugin: 'com.dicedmelon.gradle.jacoco-android'
1117

1218
android {
1319
compileSdkVersion Config.compile_sdk
14-
buildToolsVersion Config.build_tools
1520

1621
defaultConfig {
1722
applicationId "de.psdev.devdrawer"
@@ -22,16 +27,20 @@ android {
2227

2328
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2429
multiDexEnabled true
25-
26-
resConfig "en"
30+
resConfigs 'en'
2731

2832
// Version info
2933
buildConfigField 'String', 'GIT_SHA', "\"${project.ext.gitHash}\""
3034

35+
vectorDrawables {
36+
useSupportLibrary true
37+
}
38+
3139
javaCompileOptions.annotationProcessorOptions.arguments['room.schemaLocation'] = rootProject.file('schemas').toString()
3240
}
3341
buildFeatures {
3442
viewBinding true
43+
compose true
3544
}
3645
compileOptions {
3746
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -41,14 +50,29 @@ android {
4150
jvmTarget = "1.8"
4251
freeCompilerArgs += [
4352
"-Xinline-classes",
44-
"-Xopt-in=kotlin.RequiresOptIn",
45-
"-Xopt-in=kotlin.ExperimentalStdlibApi",
46-
"-Xopt-in=kotlin.time.ExperimentalTime",
47-
"-Xopt-in=kotlinx.coroutines.FlowPreview",
48-
"-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
53+
"-Xjvm-default=all",
54+
"-opt-in=kotlin.RequiresOptIn",
55+
"-opt-in=kotlin.ExperimentalStdlibApi",
56+
"-opt-in=kotlin.time.ExperimentalTime",
57+
"-opt-in=kotlinx.coroutines.FlowPreview",
58+
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
59+
"-opt-in=androidx.lifecycle.compose.ExperimentalLifecycleComposeApi",
60+
"-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
61+
"-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
62+
"-opt-in=androidx.compose.material.ExperimentalMaterialApi"
4963
]
5064
}
5165
testOptions {
66+
managedDevices {
67+
devices {
68+
pixel4api31(ManagedVirtualDevice) {
69+
device = "Pixel 4"
70+
apiLevel = 31
71+
systemImageSource = "google"
72+
require64Bit = true
73+
}
74+
}
75+
}
5276
unitTests {
5377
includeAndroidResources = true
5478
all { ignoreFailures = true }
@@ -92,18 +116,25 @@ android {
92116
}
93117
}
94118
}
95-
lintOptions {
96-
lintConfig project.file('lint.xml')
97-
disable "GoogleAppIndexingWarning"
98-
disable "RemoveWorkManagerInitializer"
119+
packagingOptions {
120+
resources {
121+
excludes += ['**/LICENSE', '**/LICENSE.txt', '**/NOTICE', '**/NOTICE.txt', '**/*.gwt.xml']
122+
}
123+
}
124+
composeOptions {
125+
kotlinCompilerExtensionVersion Versions.androidXComposeCompiler
126+
}
127+
lint {
128+
disable 'GoogleAppIndexingWarning', 'RemoveWorkManagerInitializer'
99129
enable 'Interoperability'
130+
lintConfig file('lint.xml')
100131
}
101-
packagingOptions {
102-
exclude '**/LICENSE'
103-
exclude '**/LICENSE.txt'
104-
exclude '**/NOTICE'
105-
exclude '**/NOTICE.txt'
106-
exclude '**/*.gwt.xml'
132+
applicationVariants.all { variant ->
133+
kotlin.sourceSets {
134+
getByName(variant.name) {
135+
kotlin.srcDir("build/generated/ksp/${variant.name}/kotlin")
136+
}
137+
}
107138
}
108139
}
109140

@@ -133,30 +164,50 @@ dependencies {
133164
implementation Libs.androidx_browser
134165
implementation Libs.androidx_constraint_layout
135166
implementation Libs.androidx_core
167+
implementation "androidx.core:core-splashscreen:1.0.0"
136168
implementation Libs.androidx_fragment
137169
implementation Libs.androidx_hilt_work
138170
implementation Libs.androidx_lifecycle_viewmodel
171+
implementation Libs.androidx_lifecycle_livedata
139172
implementation Libs.androidx_lifecycle_java8
173+
implementation Libs.androidx_lifecycle_runtime
140174
implementation Libs.androidx_lifecycle_process
141175
implementation Libs.androidx_navigation_fragment
142176
implementation Libs.androidx_navigation_ui
177+
implementation "androidx.navigation:navigation-compose:$Versions.androidXNavigation"
143178
implementation Libs.androidx_preference
144179
implementation Libs.androidx_recyclerview
145180
implementation Libs.androidx_recyclerview_selection
146181
implementation Libs.androidx_room_runtime
147182
implementation Libs.androidx_room_ktx
148183
implementation Libs.androidx_work_runtime
149184
implementation Libs.androidx_work_gcm
185+
implementation 'androidx.activity:activity-compose:1.6.0'
186+
implementation "androidx.compose.ui:ui:$Versions.androidXCompose"
187+
implementation "androidx.compose.foundation:foundation:$Versions.androidXCompose"
188+
implementation "androidx.compose.material:material:$Versions.androidXCompose"
189+
implementation "androidx.compose.material:material-icons-core:$Versions.androidXCompose"
190+
implementation "androidx.compose.material:material-icons-extended:$Versions.androidXCompose"
191+
implementation "androidx.compose.ui:ui-tooling:$Versions.androidXCompose"
192+
193+
implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.0-alpha02"
194+
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$Versions.androidXLifecycle"
195+
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
196+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$Versions.androidXCompose"
150197
kapt Libs.androidx_room_compiler
151198
kapt Libs.androidx_hilt_compiler
152199

153200
// Android Material
154201
implementation Libs.material_components
155202

156203
// Color Picker
157-
implementation "com.github.dhaval2404:colorpicker:2.0"
204+
implementation "com.github.dhaval2404:colorpicker:2.3"
205+
206+
// Compose Destinations
207+
implementation 'io.github.raamcosta.compose-destinations:core:1.7.21-beta'
208+
ksp 'io.github.raamcosta.compose-destinations:ksp:1.7.21-beta'
158209

159-
// Dagger
210+
// Dagger
160211
implementation Libs.daggerHiltAndroid
161212
kapt Libs.daggerHiltAndroidCompiler
162213

@@ -182,8 +233,8 @@ dependencies {
182233
implementation Libs.kotlinCoroutinesAndroid
183234

184235
// LeakCanary
185-
debugImplementation Libs.leakCanary
186-
implementation Libs.leakCanaryPlumberAndroid
236+
// debugImplementation Libs.leakCanary
237+
// implementation Libs.leakCanaryPlumberAndroid
187238

188239
// Logging
189240
implementation Libs.slf4jAndroidLogger
@@ -200,6 +251,10 @@ kapt {
200251
correctErrorTypes true
201252
}
202253

254+
jacoco {
255+
toolVersion = "0.8.7"
256+
}
257+
203258
play {
204259
def serviceAccountFileName = "google-play-api.json"
205260
if (rootProject.file(serviceAccountFileName).exists()) {

app/src/debug/res/values/strings.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<resources>
3-
<string name="app_name">DevDrawer2 (Debug)</string>
3+
<string name="app_name" translatable="false">DevDrawer2 (Debug)</string>
44
</resources>

app/src/main/AndroidManifest.xml

+17-4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@
1313
<application
1414
android:name=".DevDrawerApplication"
1515
android:allowBackup="true"
16+
android:dataExtractionRules="@xml/data_extraction_rules"
1617
android:fullBackupContent="@xml/backup_descriptor"
1718
android:icon="@mipmap/ic_launcher"
1819
android:label="@string/app_name"
1920
android:roundIcon="@mipmap/ic_launcher_round"
2021
android:supportsRtl="true"
2122
android:theme="@style/AppTheme.NoActionBar">
22-
<activity android:name=".MainActivity">
23+
<activity
24+
android:name=".MainActivity"
25+
android:exported="true"
26+
android:windowSoftInputMode="adjustResize">
2327
<intent-filter>
2428
<action android:name="android.intent.action.MAIN" />
2529
<category android:name="android.intent.category.LAUNCHER" />
@@ -30,6 +34,7 @@
3034
android:name=".appwidget.ClickHandlingActivity"
3135
android:allowTaskReparenting="false"
3236
android:excludeFromRecents="true"
37+
android:exported="true"
3338
android:noHistory="true"
3439
android:taskAffinity=""
3540
android:theme="@android:style/Theme.NoDisplay">
@@ -46,13 +51,17 @@
4651
android:taskAffinity=""
4752
android:theme="@style/AppTheme.Dialog.NoActionBar" />
4853

49-
<activity android:name=".widgets.WidgetConfigActivity">
54+
<activity
55+
android:name=".widgets.ui.WidgetConfigActivity"
56+
android:exported="true">
5057
<intent-filter>
5158
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
5259
</intent-filter>
5360
</activity>
5461

55-
<receiver android:name=".appwidget.DDWidgetProvider">
62+
<receiver
63+
android:name=".appwidget.DDWidgetProvider"
64+
android:exported="true">
5665
<intent-filter>
5766
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
5867
</intent-filter>
@@ -65,6 +74,10 @@
6574
android:name=".receivers.UpdateReceiver"
6675
android:exported="false" />
6776

77+
<receiver
78+
android:name=".receivers.PinWidgetSuccessReceiver"
79+
android:exported="false" />
80+
6881
<service
6982
android:name=".appwidget.WidgetService"
7083
android:permission="android.permission.BIND_REMOTEVIEWS" />
@@ -76,7 +89,7 @@
7689
android:exported="false"
7790
tools:node="merge">
7891
<meta-data
79-
android:name="androidx.work.impl.WorkManagerInitializer"
92+
android:name="androidx.work.WorkManagerInitializer"
8093
android:value="androidx.startup"
8194
tools:node="remove" />
8295
</provider>
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,26 @@
11
package de.psdev.devdrawer
22

3-
import android.os.Bundle
4-
import android.view.LayoutInflater
5-
import android.view.View
6-
import android.view.ViewGroup
7-
import androidx.annotation.CallSuper
83
import androidx.annotation.StringRes
94
import androidx.fragment.app.Fragment
105
import androidx.lifecycle.LifecycleCoroutineScope
116
import androidx.lifecycle.lifecycleScope
12-
import androidx.viewbinding.ViewBinding
137
import de.psdev.devdrawer.analytics.TrackingService
148
import javax.inject.Inject
159

16-
abstract class BaseFragment<T : ViewBinding> : Fragment() {
10+
open class BaseFragment : Fragment() {
1711

1812
@Inject
1913
lateinit var trackingService: TrackingService
20-
21-
private var _binding: T? = null
22-
// This property is only valid between onCreateView and onDestroyView.
23-
protected val binding get() = _binding!!
24-
2514
protected var toolbarTitle: CharSequence
2615
get() = requireActivity().title
2716
set(value) {
2817
requireActivity().title = value
2918
}
30-
31-
final override fun onCreateView(
32-
inflater: LayoutInflater,
33-
container: ViewGroup?,
34-
savedInstanceState: Bundle?
35-
): View = createViewBinding(inflater, container, savedInstanceState).also { viewBinding ->
36-
_binding = viewBinding
37-
}.root
38-
39-
protected abstract fun createViewBinding(
40-
inflater: LayoutInflater,
41-
container: ViewGroup?,
42-
savedInstanceState: Bundle?
43-
): T
44-
45-
@CallSuper
46-
override fun onDestroyView() {
47-
super.onDestroyView()
48-
_binding = null
49-
}
19+
val Fragment.viewLifecycleScope: LifecycleCoroutineScope
20+
get() = viewLifecycleOwner.lifecycleScope
5021

5122
protected fun updateToolbarTitle(@StringRes resId: Int) {
5223
requireActivity().setTitle(resId)
5324
trackingService.trackScreen(this::class.java, getString(resId))
5425
}
55-
56-
val Fragment.viewLifecycleScope: LifecycleCoroutineScope
57-
get() = viewLifecycleOwner.lifecycleScope
58-
59-
}
26+
}

app/src/main/java/de/psdev/devdrawer/DevDrawerApplication.kt

+10-7
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,23 @@ class DevDrawerApplication: Application(), Configuration.Provider {
2929
registerAppInstallationReceiver()
3030
setupWorkers()
3131
}.let {
32-
logger.warn("{} version {} ({}) took {}ms to init", this::class.java.simpleName, BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, it)
32+
logger.warn(
33+
"{} version {} ({}) took {}ms to init",
34+
this::class.java.simpleName,
35+
BuildConfig.VERSION_NAME,
36+
BuildConfig.VERSION_CODE,
37+
it
38+
)
3339
}
3440
}
3541

3642
// ==========================================================================================================================
3743
// Configuration.Provider
3844
// ==========================================================================================================================
3945

40-
override fun getWorkManagerConfiguration(): Configuration {
41-
logger.warn { "getWorkManagerConfiguration" }
42-
return Configuration.Builder()
43-
.setWorkerFactory(workerFactory)
44-
.build()
45-
}
46+
override fun getWorkManagerConfiguration(): Configuration = Configuration.Builder()
47+
.setWorkerFactory(workerFactory)
48+
.build()
4649

4750
// ==========================================================================================================================
4851
// Private API

0 commit comments

Comments
 (0)