Skip to content

Commit ecfa90e

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

File tree

108 files changed

+4414
-1420
lines changed

Some content is hidden

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

108 files changed

+4414
-1420
lines changed

app/build.gradle

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
plugins {
2+
id 'com.google.devtools.ksp' version '1.7.10-1.0.6'
3+
}
4+
15
apply plugin: 'com.android.application'
26
apply plugin: 'kotlin-android'
37
apply plugin: 'kotlin-kapt'
4-
apply plugin: "androidx.navigation.safeargs.kotlin"
8+
apply plugin: "androidx.navigation.safeargs"
59
apply plugin: 'com.google.firebase.crashlytics'
610
apply plugin: 'com.google.gms.google-services'
711
apply plugin: 'dagger.hilt.android.plugin'
8-
apply plugin: 'com.mikepenz.aboutlibraries.plugin'
912
apply plugin: 'com.google.firebase.firebase-perf'
1013
apply plugin: 'com.github.triplet.play'
14+
apply plugin: 'com.dicedmelon.gradle.jacoco-android'
1115

1216
android {
1317
compileSdkVersion Config.compile_sdk
14-
buildToolsVersion Config.build_tools
1518

1619
defaultConfig {
1720
applicationId "de.psdev.devdrawer"
@@ -22,16 +25,20 @@ android {
2225

2326
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2427
multiDexEnabled true
25-
26-
resConfig "en"
28+
resConfigs 'en'
2729

2830
// Version info
2931
buildConfigField 'String', 'GIT_SHA', "\"${project.ext.gitHash}\""
3032

33+
vectorDrawables {
34+
useSupportLibrary true
35+
}
36+
3137
javaCompileOptions.annotationProcessorOptions.arguments['room.schemaLocation'] = rootProject.file('schemas').toString()
3238
}
3339
buildFeatures {
3440
viewBinding true
41+
compose true
3542
}
3643
compileOptions {
3744
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -41,11 +48,15 @@ android {
4148
jvmTarget = "1.8"
4249
freeCompilerArgs += [
4350
"-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"
51+
"-Xjvm-default=all",
52+
"-opt-in=kotlin.RequiresOptIn",
53+
"-opt-in=kotlin.ExperimentalStdlibApi",
54+
"-opt-in=kotlin.time.ExperimentalTime",
55+
"-opt-in=kotlinx.coroutines.FlowPreview",
56+
"-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
57+
"-opt-in=androidx.compose.foundation.ExperimentalFoundationApi",
58+
"-opt-in=androidx.compose.animation.ExperimentalAnimationApi",
59+
"-opt-in=androidx.compose.material.ExperimentalMaterialApi"
4960
]
5061
}
5162
testOptions {
@@ -92,18 +103,25 @@ android {
92103
}
93104
}
94105
}
95-
lintOptions {
96-
lintConfig project.file('lint.xml')
97-
disable "GoogleAppIndexingWarning"
98-
disable "RemoveWorkManagerInitializer"
106+
packagingOptions {
107+
resources {
108+
excludes += ['**/LICENSE', '**/LICENSE.txt', '**/NOTICE', '**/NOTICE.txt', '**/*.gwt.xml']
109+
}
110+
}
111+
composeOptions {
112+
kotlinCompilerExtensionVersion Versions.androidXComposeCompiler
113+
}
114+
lint {
115+
disable 'GoogleAppIndexingWarning', 'RemoveWorkManagerInitializer'
99116
enable 'Interoperability'
117+
lintConfig file('lint.xml')
100118
}
101-
packagingOptions {
102-
exclude '**/LICENSE'
103-
exclude '**/LICENSE.txt'
104-
exclude '**/NOTICE'
105-
exclude '**/NOTICE.txt'
106-
exclude '**/*.gwt.xml'
119+
applicationVariants.all { variant ->
120+
kotlin.sourceSets {
121+
getByName(variant.name) {
122+
kotlin.srcDir("build/generated/ksp/${variant.name}/kotlin")
123+
}
124+
}
107125
}
108126
}
109127

@@ -133,30 +151,49 @@ dependencies {
133151
implementation Libs.androidx_browser
134152
implementation Libs.androidx_constraint_layout
135153
implementation Libs.androidx_core
154+
implementation "androidx.core:core-splashscreen:1.0.0"
136155
implementation Libs.androidx_fragment
137156
implementation Libs.androidx_hilt_work
138157
implementation Libs.androidx_lifecycle_viewmodel
158+
implementation Libs.androidx_lifecycle_livedata
139159
implementation Libs.androidx_lifecycle_java8
160+
implementation Libs.androidx_lifecycle_runtime
140161
implementation Libs.androidx_lifecycle_process
141162
implementation Libs.androidx_navigation_fragment
142163
implementation Libs.androidx_navigation_ui
164+
implementation "androidx.navigation:navigation-compose:$Versions.androidXNavigation"
143165
implementation Libs.androidx_preference
144166
implementation Libs.androidx_recyclerview
145167
implementation Libs.androidx_recyclerview_selection
146168
implementation Libs.androidx_room_runtime
147169
implementation Libs.androidx_room_ktx
148170
implementation Libs.androidx_work_runtime
149171
implementation Libs.androidx_work_gcm
172+
implementation 'androidx.activity:activity-compose:1.5.1'
173+
implementation "androidx.compose.ui:ui:$Versions.androidXCompose"
174+
implementation "androidx.compose.foundation:foundation:$Versions.androidXCompose"
175+
implementation "androidx.compose.material:material:$Versions.androidXCompose"
176+
implementation "androidx.compose.material:material-icons-core:$Versions.androidXCompose"
177+
implementation "androidx.compose.material:material-icons-extended:$Versions.androidXCompose"
178+
implementation "androidx.compose.ui:ui-tooling:$Versions.androidXCompose"
179+
180+
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$Versions.androidXLifecycle"
181+
implementation 'androidx.hilt:hilt-navigation-compose:1.0.0'
182+
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$Versions.androidXCompose"
150183
kapt Libs.androidx_room_compiler
151184
kapt Libs.androidx_hilt_compiler
152185

153186
// Android Material
154187
implementation Libs.material_components
155188

156189
// Color Picker
157-
implementation "com.github.dhaval2404:colorpicker:2.0"
190+
implementation "com.github.dhaval2404:colorpicker:2.3"
158191

159-
// Dagger
192+
// Compose Destinations
193+
implementation 'io.github.raamcosta.compose-destinations:core:1.6.15-beta'
194+
ksp 'io.github.raamcosta.compose-destinations:ksp:1.6.15-beta'
195+
196+
// Dagger
160197
implementation Libs.daggerHiltAndroid
161198
kapt Libs.daggerHiltAndroidCompiler
162199

@@ -182,8 +219,8 @@ dependencies {
182219
implementation Libs.kotlinCoroutinesAndroid
183220

184221
// LeakCanary
185-
debugImplementation Libs.leakCanary
186-
implementation Libs.leakCanaryPlumberAndroid
222+
// debugImplementation Libs.leakCanary
223+
// implementation Libs.leakCanaryPlumberAndroid
187224

188225
// Logging
189226
implementation Libs.slf4jAndroidLogger
@@ -200,6 +237,10 @@ kapt {
200237
correctErrorTypes true
201238
}
202239

240+
jacoco {
241+
toolVersion = "0.8.7"
242+
}
243+
203244
play {
204245
def serviceAccountFileName = "google-play-api.json"
205246
if (rootProject.file(serviceAccountFileName).exists()) {

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 17 additions & 4 deletions
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>
Lines changed: 4 additions & 37 deletions
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

Lines changed: 10 additions & 7 deletions
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)