Skip to content

Commit

Permalink
migrate to sesl-androidx
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemkinator committed Sep 17, 2024
1 parent 44ae4bb commit ee113c5
Show file tree
Hide file tree
Showing 13 changed files with 195 additions and 121 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 44 additions & 47 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.google.dagger.hilt.android")
id("kotlin-kapt")
//id("com.google.devtools.ksp")
id("com.google.devtools.ksp")
}

val releaseStoreFile: String? by rootProject
Expand All @@ -22,8 +21,6 @@ android {
versionCode = 1
versionName = "1.0.0"
resourceConfigurations += listOf("en", "de")

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
Expand Down Expand Up @@ -86,50 +83,50 @@ android {
}
}

configurations.configureEach {
exclude("androidx.appcompat", "appcompat")
exclude("androidx.fragment", "fragment")
exclude("androidx.core", "core")
exclude("androidx.core", "core-ktx")
exclude("androidx.customview", "customview")
exclude("androidx.viewpager", "viewpager")
exclude("androidx.drawerlayout", "drawerlayout")
exclude("androidx.viewpager", "viewpager")
exclude("androidx.viewpager2", "viewpager2")
exclude("androidx.coordinatorlayout", "coordinatorlayout")
exclude("androidx.recyclerview", "recyclerview")
}

dependencies {
implementation("io.github.oneuiproject:design:1.2.6")

implementation("io.github.oneuiproject.sesl:appcompat:1.4.0")
implementation("io.github.oneuiproject.sesl:preference:1.1.0")
implementation("io.github.oneuiproject.sesl:recyclerview:1.4.1")
implementation("io.github.oneuiproject.sesl:swiperefreshlayout:1.0.0")
implementation("io.github.oneuiproject.sesl:viewpager:1.1.0")
implementation("io.github.oneuiproject.sesl:viewpager2:1.1.0")

implementation("io.github.oneuiproject.sesl:material:1.5.0")

implementation("io.github.oneuiproject.sesl:apppickerview:1.0.0")
implementation("io.github.oneuiproject.sesl:indexscroll:1.0.3")
implementation("io.github.oneuiproject.sesl:picker-basic:1.2.0")
implementation("io.github.oneuiproject.sesl:picker-color:1.1.0")

//sesl6 modules
implementation("sesl.androidx.core:core:1.13.1+1.0.11-sesl6+rev1")
implementation("sesl.androidx.core:core-ktx:1.13.1+1.0.0-sesl6+rev0")
implementation("sesl.androidx.swiperefreshlayout:swiperefreshlayout:1.2.0-alpha01+1.0.0-sesl6+rev0")
implementation("sesl.androidx.fragment:fragment:1.8.3+1.0.0-sesl6+rev0")
implementation("sesl.androidx.recyclerview:recyclerview:1.4.0-beta01+1.0.21-sesl6+rev2")
implementation("sesl.androidx.appcompat:appcompat:1.7.0+1.0.34-sesl6+rev3")
implementation("sesl.androidx.viewpager2:viewpager2:1.1.0+1.0.0-sesl6+rev0")
implementation("sesl.androidx.preference:preference:1.2.1+1.0.4-sesl6+rev3")
implementation("sesl.androidx.indexscroll:indexscroll:1.0.3+1.0.3-sesl6+rev2")
implementation("sesl.androidx.picker:picker-basic:1.0.17+1.0.17-sesl6+rev2")
implementation("sesl.androidx.picker:picker-color:1.0.6+1.0.6-sesl6+rev3")
implementation("sesl.androidx.apppickerview:apppickerview:1.0.1+1.0.1-sesl6+rev2")
implementation("sesl.com.google.android.material:material:1.12.0+1.0.23-sesl6+rev0")

implementation(project(":lib"))
implementation("io.github.oneuiproject:icons:1.1.0")

implementation("com.airbnb.android:lottie:6.3.0")
implementation("com.airbnb.android:lottie:6.4.1")
implementation("androidx.core:core-splashscreen:1.0.1")
implementation("androidx.datastore:datastore-preferences:1.0.0")

//noinspection GradleDependency
implementation("androidx.core:core-ktx:1.9.0")
//noinspection GradleDependency
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.1")

//noinspection GradleDependency
implementation("com.google.dagger:hilt-android:2.42")
//noinspection GradleDependency
kapt("com.google.dagger:hilt-compiler:2.42")
}
implementation("androidx.datastore:datastore-preferences:1.1.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.5")

implementation("com.google.dagger:hilt-android:2.52")
ksp("com.google.dagger:hilt-compiler:2.52")
}

configurations.implementation {
//Exclude official android jetpack modules
exclude ("androidx.core", "core")
exclude ("androidx.core", "core-ktx")
exclude ("androidx.customview", "customview")
exclude ("androidx.coordinatorlayout", "coordinatorlayout")
exclude ("androidx.drawerlayout", "drawerlayout")
exclude ("androidx.viewpager2", "viewpager2")
exclude ("androidx.viewpager", "viewpager")
exclude ("androidx.appcompat", "appcompat")
exclude ("androidx.fragment", "fragment")
exclude ("androidx.preference", "preference")
exclude ("androidx.recyclerview", "recyclerview")
exclude ("androidx.slidingpanelayout", "slidingpanelayout")
exclude ("androidx.swiperefreshlayout", "swiperefreshlayout")

//Exclude official material components lib
exclude ("com.google.android.material", "material")
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,16 @@ class AppPickerActivity : AppCompatActivity(), AppPickerView.OnBindListener, Ada
when (listType) {
AppPickerView.TYPE_LIST -> holder.item.setOnClickListener { }
AppPickerView.TYPE_LIST_ACTION_BUTTON ->
holder.actionButton.setOnClickListener { Toast.makeText(this, "onClick", Toast.LENGTH_SHORT).show() }
holder.actionButton?.setOnClickListener { Toast.makeText(this, "onClick", Toast.LENGTH_SHORT).show() }
AppPickerView.TYPE_LIST_CHECKBOX -> {
val checkBox = holder.checkBox
checkBox.isChecked = items[position]
checkBox.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean -> items[position] = isChecked }
holder.checkBox?.isChecked = items[position]
holder.checkBox?.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean -> items[position] = isChecked }
}
AppPickerView.TYPE_LIST_CHECKBOX_WITH_ALL_APPS -> {
val checkBox = holder.checkBox
if (position == 0) {
holder.appLabel.text = getString(R.string.all_apps)
checkBox.isChecked = isAllAppsSelected
checkBox.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
holder.checkBox?.isChecked = isAllAppsSelected
holder.checkBox?.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
if (isAllAppsSelected != isChecked) {
isAllAppsSelected = isChecked
var i = 0
Expand All @@ -187,17 +185,16 @@ class AppPickerActivity : AppCompatActivity(), AppPickerView.OnBindListener, Ada
}
}
} else {
checkBox.isChecked = items[position]
checkBox.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
holder.checkBox?.isChecked = items[position]
holder.checkBox?.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
items[position] = isChecked
checkAllAppsToggle()
}
}
}
AppPickerView.TYPE_LIST_RADIOBUTTON -> {
val radioButton = holder.radioButton
radioButton.isChecked = items[position]
holder.radioButton.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
holder.radioButton?.isChecked = items[position]
holder.radioButton?.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
if (isChecked) {
if (checkedPosition != position) {
items[checkedPosition] = false
Expand All @@ -209,16 +206,14 @@ class AppPickerActivity : AppCompatActivity(), AppPickerView.OnBindListener, Ada
}
}
AppPickerView.TYPE_LIST_SWITCH -> {
val switchWidget = holder.switch
switchWidget.isChecked = items[position]
switchWidget.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean -> items[position] = isChecked }
holder.switch?.isChecked = items[position]
holder.switch?.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean -> items[position] = isChecked }
}
AppPickerView.TYPE_LIST_SWITCH_WITH_ALL_APPS -> {
val switchWidget = holder.switch
if (position == 0) {
holder.appLabel.text = getString(R.string.all_apps)
switchWidget.isChecked = isAllAppsSelected
switchWidget.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
holder.switch?.isChecked = isAllAppsSelected
holder.switch?.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
if (isAllAppsSelected != isChecked) {
isAllAppsSelected = isChecked
var i = 0
Expand All @@ -230,19 +225,18 @@ class AppPickerActivity : AppCompatActivity(), AppPickerView.OnBindListener, Ada
}
}
} else {
switchWidget.isChecked = items[position]
switchWidget.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
holder.switch?.isChecked = items[position]
holder.switch?.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean ->
items[position] = isChecked
checkAllAppsToggle()
}
}
}
AppPickerView.TYPE_GRID -> holder.item.setOnClickListener { }
AppPickerView.TYPE_GRID_CHECKBOX -> {
val checkBox = holder.checkBox
checkBox.isChecked = items[position]
checkBox.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean -> items[position] = isChecked }
holder.item.setOnClickListener { checkBox.isChecked = !checkBox.isChecked }
holder.checkBox?.isChecked = items[position]
holder.checkBox?.setOnCheckedChangeListener { _: CompoundButton?, isChecked: Boolean -> items[position] = isChecked }
holder.item.setOnClickListener { holder.checkBox?.isChecked = holder.checkBox?.isChecked?.not() == true }
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import dev.oneuiproject.oneui.oneuisampleapp.databinding.ActivityCustomAboutCont
import dev.oneuiproject.oneui.utils.ViewUtils
import dev.oneuiproject.oneui.utils.internal.ToolbarLayoutUtils
import android.widget.Toast
import androidx.appcompat.content.res.AppCompatResources
import kotlin.math.abs

@AndroidEntryPoint
Expand Down Expand Up @@ -98,7 +99,7 @@ class CustomAboutActivity : AppCompatActivity(), View.OnClickListener {
ViewUtils.SEM_ROUNDED_CORNER_TOP_LEFT or ViewUtils.SEM_ROUNDED_CORNER_TOP_RIGHT,
getColor(dev.oneuiproject.oneui.design.R.color.oui_round_and_bgcolor)
)
val appIcon = getDrawable(R.drawable.ic_launcher)
val appIcon = AppCompatResources.getDrawable(this, R.drawable.ic_launcher)
binding.aboutHeaderAppIcon.setImageDrawable(appIcon)
binding.aboutBottomAppIcon.setImageDrawable(appIcon)
binding.aboutHeaderAppVersion.text = getString(R.string.version, BuildConfig.VERSION_NAME)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.oneuiproject.oneui.oneuisampleapp.ui.widget

import android.content.Context
import android.content.res.TypedArray
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.View
Expand All @@ -12,39 +11,31 @@ import android.widget.TextView
import dev.oneuiproject.oneui.oneuisampleapp.R

class CardView(context: Context, attrs: AttributeSet) : LinearLayout(context, attrs) {
private var isIconView = false
private var isDividerViewVisible = false
private var isIconView: Boolean = false
private var isDividerViewVisible: Boolean = false
private val parentView: FrameLayout
private val containerView: LinearLayout
private val titleTextView: TextView
private val summaryTextView: TextView
private lateinit var iconImageView: ImageView
private var dividerView: View? = null
private var dividerView: View
private var iconColor = 0
private var iconDrawable: Drawable? = null
private var titleText1: String? = null
private var summaryText1: String? = null

init {
val styledAttr: TypedArray = context.obtainStyledAttributes(attrs, dev.oneuiproject.oneui.design.R.styleable.CardView)
iconDrawable = styledAttr.getDrawable(R.styleable.CardView_IconDrawable)
iconColor = styledAttr.getColor(R.styleable.CardView_IconColor, -1)
titleText1 = styledAttr.getString(R.styleable.CardView_TitleText)
summaryText1 = styledAttr.getString(R.styleable.CardView_SummaryText)
isIconView = iconDrawable != null
isDividerViewVisible = styledAttr.getBoolean(R.styleable.CardView_isDividerViewVisible, false)
styledAttr.recycle()

setStyleable(attrs)
removeAllViews()
if (isIconView) {
View.inflate(context, R.layout.widget_cardview_icon, this)
inflate(context, R.layout.widget_cardview_icon, this)
iconImageView = findViewById(R.id.cardview_icon)
iconImageView.setImageDrawable(iconDrawable)
if (iconColor != -1) {
iconImageView.drawable.setTint(iconColor)
}
} else {
View.inflate(context, R.layout.widget_cardview, this)
inflate(context, R.layout.widget_cardview, this)
}
parentView = findViewById(R.id.cardview_main_container)
containerView = findViewById(R.id.cardview_container)
Expand All @@ -53,18 +44,69 @@ class CardView(context: Context, attrs: AttributeSet) : LinearLayout(context, at
summaryTextView = findViewById(R.id.cardview_summary)
if (summaryText1 != null && summaryText1!!.isNotEmpty()) {
summaryTextView.text = summaryText1
summaryTextView.visibility = View.VISIBLE
summaryTextView.visibility = VISIBLE
}
dividerView = findViewById(R.id.cardview_divider)
val lp: MarginLayoutParams = dividerView!!.layoutParams as MarginLayoutParams
val lp = dividerView.layoutParams as MarginLayoutParams
lp.marginStart = if (isIconView) ((resources.getDimensionPixelSize(R.dimen.cardview_icon_divider_margin_end)
+ resources.getDimensionPixelSize(R.dimen.cardview_icon_size)
+ resources.getDimensionPixelSize(R.dimen.cardview_icon_margin_end))
- resources.getDimensionPixelSize(R.dimen.cardview_icon_margin_vertical)) else resources.getDimensionPixelSize(
R.dimen.cardview_icon_divider_margin_end
)
- resources.getDimensionPixelSize(R.dimen.cardview_icon_margin_vertical)
) else resources.getDimensionPixelSize(R.dimen.cardview_icon_divider_margin_end)
lp.marginEnd = resources.getDimensionPixelSize(R.dimen.cardview_icon_divider_margin_end)
dividerView!!.visibility = if (isDividerViewVisible) View.VISIBLE else View.GONE
dividerView.visibility = if (isDividerViewVisible) VISIBLE else GONE
}

private fun setStyleable(attrs: AttributeSet) {
val a = context.obtainStyledAttributes(attrs, R.styleable.CardView)
iconDrawable = a.getDrawable(R.styleable.CardView_IconDrawable)
iconColor = a.getColor(R.styleable.CardView_IconColor, -1)
titleText1 = a.getString(R.styleable.CardView_TitleText)
summaryText1 = a.getString(R.styleable.CardView_SummaryText)
isIconView = iconDrawable != null
isDividerViewVisible = a.getBoolean(R.styleable.CardView_isDividerViewVisible, false)
a.recycle()
}

fun setIconDrawable(drawable: Drawable?) {
iconDrawable = drawable
val isNewDrawableNotNull = iconDrawable != null
if (isNewDrawableNotNull == isIconView) {
if (isNewDrawableNotNull) {
if (iconColor != -1) {
iconDrawable!!.setTint(iconColor)
}
iconImageView.setImageDrawable(iconDrawable)
}
} else {
isIconView = isNewDrawableNotNull
removeAllViews()
if (isIconView) {
inflate(context, R.layout.widget_cardview_icon, this)

iconImageView = findViewById(R.id.cardview_icon)
iconImageView.setImageDrawable(iconDrawable)
if (iconColor != -1) {
iconImageView.drawable.setTint(iconColor)
}
} else {
inflate(context, R.layout.widget_cardview, this)
}
titleTextView.text = titleText1
if (summaryText1 != null && summaryText1!!.isNotEmpty()) {
summaryTextView.text = summaryText1
summaryTextView.visibility = VISIBLE
}
dividerView = findViewById(R.id.cardview_divider)
val lp = dividerView.layoutParams as MarginLayoutParams
lp.marginStart = if (isIconView) ((resources.getDimensionPixelSize(R.dimen.cardview_icon_divider_margin_end)
+ resources.getDimensionPixelSize(R.dimen.cardview_icon_size)
+ resources.getDimensionPixelSize(R.dimen.cardview_icon_margin_end))
- resources.getDimensionPixelSize(R.dimen.cardview_icon_margin_vertical)
) else resources.getDimensionPixelSize(R.dimen.cardview_icon_divider_margin_end)
lp.marginEnd = resources.getDimensionPixelSize(R.dimen.cardview_icon_divider_margin_end)
dividerView.visibility = if (isDividerViewVisible) VISIBLE else GONE
}
}

override fun setEnabled(enabled: Boolean) {
Expand All @@ -81,17 +123,19 @@ class CardView(context: Context, attrs: AttributeSet) : LinearLayout(context, at
titleText1 = title
titleTextView.text = titleText1
}

var summaryText: String?
get() = summaryText1
set(newText) {
var text = newText
if (text == null) text = ""
summaryText1 = text
summaryTextView.text = summaryText1
if (summaryText1!!.isEmpty()) summaryTextView.visibility = View.GONE else summaryTextView.visibility = View.VISIBLE
if (summaryText1!!.isEmpty()) summaryTextView.visibility = GONE
else summaryTextView.visibility = VISIBLE
}

fun setDividerVisible(visible: Boolean) {
dividerView!!.visibility = if (visible) View.VISIBLE else View.GONE
dividerView.visibility = if (visible) VISIBLE else GONE
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/drawable/icon_face_background.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/oui_round_and_bgcolor" />
<solid android:color="@color/round_and_bg_color" />
</shape>
Loading

0 comments on commit ee113c5

Please sign in to comment.