added jetpack compose testing samples; migrating after AS Arctic Fox releases
This commit is contained in:
parent
ae1d5691ac
commit
7acb40234b
|
@ -45,6 +45,7 @@ android {
|
||||||
|
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding = true
|
viewBinding = true
|
||||||
|
//compose = true
|
||||||
}
|
}
|
||||||
|
|
||||||
packagingOptions {
|
packagingOptions {
|
||||||
|
@ -63,6 +64,7 @@ android {
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = "1.8"
|
jvmTarget = "1.8"
|
||||||
|
//useIR = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +87,7 @@ fun getLanguages(): String {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
||||||
|
//val composeVersion = "1.0.0-alpha12"
|
||||||
implementation(project(":core-presentation"))
|
implementation(project(":core-presentation"))
|
||||||
implementation(project(":core-ui"))
|
implementation(project(":core-ui"))
|
||||||
|
|
||||||
|
@ -108,6 +111,17 @@ dependencies {
|
||||||
implementation("androidx.preference:preference-ktx:1.1.1")
|
implementation("androidx.preference:preference-ktx:1.1.1")
|
||||||
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
|
||||||
|
|
||||||
|
|
||||||
|
// Compose
|
||||||
|
// implementation("androidx.compose.ui:ui:$composeVersion")
|
||||||
|
// implementation("androidx.compose.ui:ui-tooling:$composeVersion")
|
||||||
|
// implementation("androidx.compose.foundation:foundation:$composeVersion")
|
||||||
|
// implementation("androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha02")
|
||||||
|
// implementation("androidx.compose.material:material:$composeVersion")
|
||||||
|
// implementation("androidx.compose.material:material-icons-core:$composeVersion")
|
||||||
|
// implementation("androidx.compose.material:material-icons-extended:$composeVersion")
|
||||||
|
// implementation("androidx.compose.runtime:runtime-livedata:$composeVersion")
|
||||||
|
|
||||||
// Appearance
|
// Appearance
|
||||||
implementation("com.github.madrapps:pikolo:2.0.1")
|
implementation("com.github.madrapps:pikolo:2.0.1")
|
||||||
implementation("com.google.android.material:material:1.3.0")
|
implementation("com.google.android.material:material:1.3.0")
|
||||||
|
|
|
@ -17,7 +17,7 @@ open class DataModel(
|
||||||
lifecycleOwner: LifecycleOwner,
|
lifecycleOwner: LifecycleOwner,
|
||||||
val appPkg: String,
|
val appPkg: String,
|
||||||
val appName: String,
|
val appName: String,
|
||||||
val appIcon: Drawable?,
|
val appIcon: Drawable?
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val versionCode = MutableLiveData<Int>()
|
private val versionCode = MutableLiveData<Int>()
|
||||||
|
|
|
@ -4,5 +4,5 @@ import android.graphics.drawable.Drawable
|
||||||
|
|
||||||
data class LinkModel(
|
data class LinkModel(
|
||||||
val linkIcon: Drawable?,
|
val linkIcon: Drawable?,
|
||||||
val linkUrl: String,
|
val linkUrl: String
|
||||||
)
|
)
|
|
@ -0,0 +1,2 @@
|
||||||
|
package com.vanced.manager.ui.compose
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
package com.vanced.manager.ui.compose
|
||||||
|
|
||||||
|
//import androidx.compose.foundation.clickable
|
||||||
|
//import androidx.compose.foundation.layout.Column
|
||||||
|
//import androidx.compose.foundation.layout.ColumnScope
|
||||||
|
//import androidx.compose.foundation.layout.padding
|
||||||
|
//import androidx.compose.material.Switch
|
||||||
|
//import androidx.compose.material.Text
|
||||||
|
//import androidx.compose.runtime.*
|
||||||
|
//import androidx.compose.ui.Modifier
|
||||||
|
//import androidx.compose.ui.graphics.Color
|
||||||
|
//import androidx.compose.ui.platform.LocalContext
|
||||||
|
//import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
//import androidx.compose.ui.unit.dp
|
||||||
|
//import androidx.compose.ui.unit.em
|
||||||
|
//import androidx.compose.ui.unit.sp
|
||||||
|
//import androidx.constraintlayout.compose.ConstraintLayout
|
||||||
|
//import androidx.core.content.edit
|
||||||
|
//import androidx.preference.PreferenceManager
|
||||||
|
//
|
||||||
|
//@Composable
|
||||||
|
//@Preview
|
||||||
|
//inline fun PreferenceCategory(
|
||||||
|
// categoryTitle: String,
|
||||||
|
// content: @Composable ColumnScope.() -> Unit
|
||||||
|
//) {
|
||||||
|
// Column {
|
||||||
|
// Text(
|
||||||
|
// categoryTitle,
|
||||||
|
// letterSpacing = 0.15.em,
|
||||||
|
// color = Color(LocalContext.current.accentColor)
|
||||||
|
// )
|
||||||
|
// content()
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//@Composable
|
||||||
|
//@Preview
|
||||||
|
//inline fun SwitchPreference(
|
||||||
|
// preferenceTitle: String,
|
||||||
|
// preferenceDescription: String? = null,
|
||||||
|
// preferenceKey: String,
|
||||||
|
// defValue: Boolean = true,
|
||||||
|
// crossinline onCheckedChange: (Boolean) -> Unit = {}
|
||||||
|
//) {
|
||||||
|
// val prefs = PreferenceManager.getDefaultSharedPreferences(LocalContext.current)
|
||||||
|
// val isChecked = remember { mutableStateOf(prefs.getBoolean(preferenceKey, defValue)) }
|
||||||
|
// ConstraintLayout(modifier = Modifier.padding(12.dp, 4.dp).clickable {
|
||||||
|
// isChecked.value = !isChecked.value
|
||||||
|
// }) {
|
||||||
|
// val (title, description, switch) = createRefs()
|
||||||
|
// Text(preferenceTitle, fontSize = 16.sp, modifier = Modifier.constrainAs(title) {
|
||||||
|
// top.linkTo(parent.top)
|
||||||
|
// start.linkTo(parent.start)
|
||||||
|
// end.linkTo(switch.start, 4.dp)
|
||||||
|
// if (preferenceDescription != null) {
|
||||||
|
// bottom.linkTo(description.top)
|
||||||
|
// } else {
|
||||||
|
// bottom.linkTo(parent.bottom)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// if (preferenceDescription != null) {
|
||||||
|
// Text(preferenceDescription, fontSize = 13.sp, modifier = Modifier.constrainAs(description) {
|
||||||
|
// top.linkTo(title.bottom)
|
||||||
|
// start.linkTo(parent.start)
|
||||||
|
// end.linkTo(switch.start, 8.dp)
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// Switch(
|
||||||
|
// isChecked.value,
|
||||||
|
// onCheckedChange = {
|
||||||
|
// prefs.edit { putBoolean(preferenceKey, it) }
|
||||||
|
// onCheckedChange(it)
|
||||||
|
// },
|
||||||
|
// modifier = Modifier.clickable(false) {}
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//@Composable
|
||||||
|
//@Preview
|
||||||
|
//fun Preference(
|
||||||
|
// preferenceTitle: String,
|
||||||
|
// preferenceDescription: String? = null,
|
||||||
|
// onClick: () -> Unit
|
||||||
|
//) {
|
||||||
|
// ConstraintLayout(modifier = Modifier.padding(12.dp, 4.dp).clickable(onClick = onClick)) {
|
||||||
|
// val (title, description, switch) = createRefs()
|
||||||
|
// Text(preferenceTitle, fontSize = 16.sp, modifier = Modifier.constrainAs(title) {
|
||||||
|
// top.linkTo(parent.top)
|
||||||
|
// start.linkTo(parent.start)
|
||||||
|
// end.linkTo(switch.start, 4.dp)
|
||||||
|
// if (preferenceDescription != null) {
|
||||||
|
// bottom.linkTo(description.top)
|
||||||
|
// } else {
|
||||||
|
// bottom.linkTo(parent.bottom)
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// if (preferenceDescription != null) {
|
||||||
|
// Text(preferenceDescription, fontSize = 13.sp, modifier = Modifier.constrainAs(description) {
|
||||||
|
// top.linkTo(title.bottom)
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package com.vanced.manager.ui.compose
|
||||||
|
|
||||||
|
//import android.content.Context
|
||||||
|
//import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
|
//import androidx.compose.material.MaterialTheme
|
||||||
|
//import androidx.compose.material.darkColors
|
||||||
|
//import androidx.compose.material.lightColors
|
||||||
|
//import androidx.compose.runtime.Composable
|
||||||
|
//import androidx.compose.runtime.MutableState
|
||||||
|
//import androidx.compose.runtime.mutableStateOf
|
||||||
|
//import androidx.compose.runtime.remember
|
||||||
|
//import androidx.compose.ui.graphics.Color
|
||||||
|
//import androidx.compose.ui.platform.LocalContext
|
||||||
|
//import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||||
|
//import com.vanced.manager.utils.mutableAccentColor
|
||||||
|
//
|
||||||
|
//const val Dark = "Dark"
|
||||||
|
//const val SystemDefault = "System Default"
|
||||||
|
//
|
||||||
|
//const val defAccentColor: Int = -13732865
|
||||||
|
//
|
||||||
|
//val Context.accentColor get() = mutableAccentColor.value ?: getDefaultSharedPreferences(this).getInt("manager_accent_color", defAccentColor)
|
||||||
|
//
|
||||||
|
//enum class Theme {
|
||||||
|
// DARK, LIGHT
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//val lightColors = lightColors(
|
||||||
|
// primary = Color(defAccentColor)
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//val darkColors = darkColors(
|
||||||
|
// primary = Color(defAccentColor)
|
||||||
|
//)
|
||||||
|
//
|
||||||
|
//fun Context.retrieveTheme(): Theme = when (getDefaultSharedPreferences(this).getString("manager_theme", SystemDefault)) {
|
||||||
|
// SystemDefault -> if (isSystemInDarkTheme()) Theme.DARK else Theme.LIGHT
|
||||||
|
// Dark -> Theme.DARK
|
||||||
|
// else -> Theme.LIGHT
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//val Context.isDarkTheme: Boolean
|
||||||
|
// get() = retrieveTheme() == Theme.DARK
|
||||||
|
//
|
||||||
|
//fun Context.ManagerTheme(
|
||||||
|
// content: @Composable () -> Unit
|
||||||
|
//) {
|
||||||
|
// MaterialTheme(
|
||||||
|
// colors = if (isDarkTheme) darkColors else lightColors,
|
||||||
|
// content = content
|
||||||
|
// )
|
||||||
|
//}
|
|
@ -10,7 +10,7 @@ import com.vanced.manager.databinding.ViewPreferenceCategoryBinding
|
||||||
class PreferenceCategory @JvmOverloads constructor(
|
class PreferenceCategory @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
defStyle: Int = 0,
|
defStyle: Int = 0
|
||||||
) : LinearLayout(context, attrs, defStyle) {
|
) : LinearLayout(context, attrs, defStyle) {
|
||||||
|
|
||||||
private var _binding: ViewPreferenceCategoryBinding? = null
|
private var _binding: ViewPreferenceCategoryBinding? = null
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package com.vanced.manager.ui.fragments
|
||||||
|
|
||||||
|
//import android.os.Bundle
|
||||||
|
//import android.view.LayoutInflater
|
||||||
|
//import android.view.View
|
||||||
|
//import android.view.ViewGroup
|
||||||
|
//import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
//import androidx.compose.ui.platform.ComposeView
|
||||||
|
//import androidx.fragment.app.Fragment
|
||||||
|
//import com.vanced.manager.R
|
||||||
|
//import com.vanced.manager.ui.compose.Preference
|
||||||
|
//import com.vanced.manager.ui.compose.PreferenceCategory
|
||||||
|
//import com.vanced.manager.ui.compose.SwitchPreference
|
||||||
|
//
|
||||||
|
//class SettingsFragmentCompose : Fragment() {
|
||||||
|
//
|
||||||
|
// override fun onCreateView(
|
||||||
|
// inflater: LayoutInflater,
|
||||||
|
// container: ViewGroup?,
|
||||||
|
// savedInstanceState: Bundle?
|
||||||
|
// ): View {
|
||||||
|
// return ComposeView(requireActivity()).apply {
|
||||||
|
// setContent {
|
||||||
|
// LazyColumn {
|
||||||
|
// // use `item` for separate elements like headers
|
||||||
|
// // and `items` for lists of identical elements
|
||||||
|
// item {
|
||||||
|
// PreferenceCategory(
|
||||||
|
// categoryTitle = getString(R.string.category_behaviour)
|
||||||
|
// ) {
|
||||||
|
// SwitchPreference(
|
||||||
|
// preferenceTitle = getString(R.string.use_custom_tabs),
|
||||||
|
// preferenceDescription = getString(R.string.link_custom_tabs),
|
||||||
|
// preferenceKey = "use_custom_tabs"
|
||||||
|
// )
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// item {
|
||||||
|
// PreferenceCategory(
|
||||||
|
// categoryTitle = getString(R.string.category_appearance)
|
||||||
|
// ) {
|
||||||
|
// Preference(
|
||||||
|
// preferenceTitle = "test",
|
||||||
|
// preferenceDescription = "test",
|
||||||
|
// ) {}
|
||||||
|
// Preference(
|
||||||
|
// preferenceTitle = "test"
|
||||||
|
// ) {}
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//}
|
|
@ -1,6 +1,7 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
|
val kotlin_version by extra("1.4.30")
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
jcenter()
|
jcenter()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#Sat Jan 09 23:28:33 GET 2021
|
#Fri Feb 19 17:21:09 GET 2021
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|
|
@ -2,5 +2,4 @@
|
||||||
package="com.vanced.manager.library.network">
|
package="com.vanced.manager.library.network">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
|
||||||
</manifest>
|
</manifest>
|
Loading…
Reference in New Issue