mirror of
https://github.com/bitfireAT/davx5-ose
synced 2024-07-23 19:50:18 +00:00
Use Jetpack Compose for AboutLibraries (bitfireAT/davx5#246)
- add JetPack Compose dependencies - use existing XML theme as Compose MdcTheme - update AboutLibraries to newest version (uses Compose) - embed AboutLibraries Compose into existing Fragment layout
This commit is contained in:
parent
0bed00c05a
commit
c3cd970581
|
@ -48,9 +48,15 @@ android {
|
|||
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
compose = true
|
||||
viewBinding = true
|
||||
dataBinding = true
|
||||
}
|
||||
composeOptions {
|
||||
// Keep this in sync with Kotlin version:
|
||||
// https://developer.android.com/jetpack/androidx/releases/compose-kotlin
|
||||
kotlinCompilerExtensionVersion = "1.4.6"
|
||||
}
|
||||
|
||||
// Java namespace for our classes (not to be confused with Android package ID)
|
||||
namespace 'at.bitfire.davdroid'
|
||||
|
@ -131,19 +137,27 @@ dependencies {
|
|||
implementation 'com.google.android.flexbox:flexbox:3.0.0'
|
||||
implementation 'com.google.android.material:material:1.8.0'
|
||||
|
||||
def room_version = '2.5.1'
|
||||
implementation "androidx.room:room-runtime:$room_version"
|
||||
implementation "androidx.room:room-ktx:$room_version"
|
||||
implementation "androidx.room:room-paging:$room_version"
|
||||
kapt "androidx.room:room-compiler:$room_version"
|
||||
androidTestImplementation "androidx.room:room-testing:$room_version"
|
||||
// Jetpack Compose
|
||||
def composeBom = platform("androidx.compose:compose-bom:${versions.composeBom}")
|
||||
implementation composeBom
|
||||
androidTestImplementation composeBom
|
||||
implementation 'androidx.compose.material:material'
|
||||
implementation 'com.google.accompanist:accompanist-themeadapter-material:0.30.1'
|
||||
|
||||
// Jetpack Room
|
||||
implementation "androidx.room:room-runtime:${versions.room}"
|
||||
implementation "androidx.room:room-ktx:${versions.room}"
|
||||
implementation "androidx.room:room-paging:${versions.room}"
|
||||
kapt "androidx.room:room-compiler:${versions.room}"
|
||||
androidTestImplementation "androidx.room:room-testing:${versions.room}"
|
||||
|
||||
// third-party libs
|
||||
implementation 'com.jaredrummler:colorpicker:1.1.0'
|
||||
implementation "com.github.AppIntro:AppIntro:${versions.appIntro}"
|
||||
implementation("com.github.bitfireAT:dav4jvm:${versions.dav4jvm}") {
|
||||
exclude group: 'junit'
|
||||
}
|
||||
implementation "com.mikepenz:aboutlibraries:${versions.aboutLibraries}"
|
||||
implementation "com.mikepenz:aboutlibraries-compose:${versions.aboutLibraries}"
|
||||
implementation "com.squareup.okhttp3:okhttp:${versions.okhttp}"
|
||||
implementation "com.squareup.okhttp3:okhttp-brotli:${versions.okhttp}"
|
||||
implementation "com.squareup.okhttp3:logging-interceptor:${versions.okhttp}"
|
||||
|
|
|
@ -14,6 +14,9 @@ import android.util.DisplayMetrics
|
|||
import android.view.*
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
|
@ -32,8 +35,8 @@ import at.bitfire.davdroid.databinding.AboutBinding
|
|||
import at.bitfire.davdroid.databinding.AboutLanguagesBinding
|
||||
import at.bitfire.davdroid.databinding.AboutTranslationBinding
|
||||
import at.bitfire.davdroid.databinding.ActivityAboutBinding
|
||||
import com.mikepenz.aboutlibraries.Libs
|
||||
import com.mikepenz.aboutlibraries.LibsBuilder
|
||||
import com.google.accompanist.themeadapter.material.MdcTheme
|
||||
import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer
|
||||
import dagger.BindsOptionalOf
|
||||
import dagger.Module
|
||||
import dagger.hilt.InstallIn
|
||||
|
@ -88,7 +91,7 @@ class AboutActivity: AppCompatActivity() {
|
|||
|
||||
|
||||
private inner class TabsAdapter(
|
||||
fm: FragmentManager
|
||||
fm: FragmentManager
|
||||
): FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
|
||||
|
||||
override fun getCount() = 3
|
||||
|
@ -104,18 +107,7 @@ class AboutActivity: AppCompatActivity() {
|
|||
when (position) {
|
||||
0 -> AppFragment()
|
||||
1 -> LanguagesFragment()
|
||||
else -> {
|
||||
LibsBuilder()
|
||||
.withFields(R.string::class.java.fields) // mandatory for non-standard build flavors
|
||||
.withLicenseShown(true)
|
||||
.withAboutIconShown(false)
|
||||
|
||||
// https://github.com/mikepenz/AboutLibraries/issues/490
|
||||
.withLibraryModification("org_brotli__dec", Libs.LibraryFields.LIBRARY_NAME, "Brotli")
|
||||
.withLibraryModification("org_brotli__dec", Libs.LibraryFields.AUTHOR_NAME, "Google")
|
||||
|
||||
.supportFragment()
|
||||
}
|
||||
else -> LibsFragment()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -133,7 +125,7 @@ class AboutActivity: AppCompatActivity() {
|
|||
}
|
||||
|
||||
@AndroidEntryPoint
|
||||
class AppFragment: Fragment() {
|
||||
class AppFragment : Fragment() {
|
||||
|
||||
private var _binding: AboutBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
@ -233,6 +225,21 @@ class AboutActivity: AppCompatActivity() {
|
|||
|
||||
}
|
||||
|
||||
class LibsFragment : Fragment() {
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?) =
|
||||
ComposeView(requireContext()).apply {
|
||||
setContent {
|
||||
MdcTheme {
|
||||
LibrariesContainer(
|
||||
Modifier.fillMaxSize()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
open class TextFileModel(
|
||||
application: Application
|
||||
|
|
|
@ -4,12 +4,14 @@
|
|||
|
||||
buildscript {
|
||||
ext.versions = [
|
||||
aboutLibraries: '8.9.4',
|
||||
aboutLibraries: '10.6.2',
|
||||
appIntro: '6.2.0',
|
||||
composeBom: '2023.04.01',
|
||||
dav4jvm: 'aac98bd76cf3034194c9ba6d2bf58212083a72a0',
|
||||
hilt: '2.45',
|
||||
kotlin: '1.8.20',
|
||||
okhttp: '4.10.0',
|
||||
room: '2.5.1',
|
||||
// latest Apache Commons versions that don't require Java 8 (Android 7)
|
||||
commonsCollections: '4.2',
|
||||
commonsLang: '3.8.1',
|
||||
|
|
|
@ -6,5 +6,5 @@ android.useAndroidX=true
|
|||
android.enableR8.fullMode=false
|
||||
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xmx1536M -Dkotlin.daemon.jvm.options\="-Xmx1536M"
|
||||
org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M"
|
||||
org.gradle.parallel=true
|
||||
|
|
Loading…
Reference in a new issue