Skip to content

Commit

Permalink
Update project library versions
Browse files Browse the repository at this point in the history
  • Loading branch information
max1lyu committed Sep 12, 2023
1 parent 247ade1 commit 9da66c4
Show file tree
Hide file tree
Showing 27 changed files with 199 additions and 159 deletions.
2 changes: 1 addition & 1 deletion common.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ext.version = "1.2.0"
ext.version = "1.3.0"
ext.group = "nz.co.trademe.konfigure"
ext.repo = "konfigure"
ext.org = "trademe"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Aug 26 13:01:08 NZST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
23 changes: 12 additions & 11 deletions konfigure-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ buildscript {

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

ext {
PUBLISH_VERSION = rootVersionName
Expand All @@ -24,22 +23,24 @@ ext {
apply from: '../common.gradle'
apply from: '../publishing.gradle'

androidExtensions {
experimental = true
}
android {
namespace 'nz.co.trademe.konfigure.android'

buildFeatures {
viewBinding true
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

api project(":konfigure")

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlin"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$versions.coroutines"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.coroutines"

implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "androidx.lifecycle:lifecycle-extensions:2.1.0"
implementation "androidx.appcompat:appcompat:$versions.appcompat"
implementation "com.google.android.material:material:$versions.material"
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import android.view.inputmethod.InputMethodManager
import androidx.annotation.CallSuper
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.SearchView
import kotlinx.android.synthetic.main.activity_config.*
import nz.co.trademe.konfigure.android.R
import nz.co.trademe.konfigure.android.databinding.ActivityConfigBinding
import nz.co.trademe.konfigure.android.ui.view.ConfigView

/**
Expand All @@ -20,21 +20,22 @@ import nz.co.trademe.konfigure.android.ui.view.ConfigView
*
* To use, simply call [ConfigActivity.start]
*/
open class ConfigActivity: AppCompatActivity() {
open class ConfigActivity : AppCompatActivity() {

val configurationView: ConfigView
get() = configView
private var _binding: ActivityConfigBinding? = null
protected val binding get() = _binding!!

@CallSuper
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_config)
_binding = ActivityConfigBinding.inflate(layoutInflater)
setContentView(binding.root)
}

@CallSuper
override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
setSupportActionBar(toolbar)
setSupportActionBar(binding.toolbar)
setTitle(R.string.configuration)

supportActionBar?.apply {
Expand All @@ -53,27 +54,33 @@ open class ConfigActivity: AppCompatActivity() {

searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String?): Boolean {
configView.search(query ?: "")
binding.configView.search(query ?: "")
hideSoftKeyboard()
return true
}

override fun onQueryTextChange(newText: String?): Boolean {
configView.search(newText ?: "")
binding.configView.search(newText ?: "")
return true
}
})

return true
}

override fun onDestroy() {
super.onDestroy()
_binding = null
}

@CallSuper
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
finish()
true
}

else -> super.onOptionsItemSelected(item)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package nz.co.trademe.konfigure.android.ui.adapter.viewholder

import android.view.View
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.extensions.LayoutContainer
import androidx.viewbinding.ViewBinding

/**
* Simple base for ViewHolders which implements [LayoutContainer]
* Simple base for ViewHolders
*/
internal open class BaseViewHolder(
override val containerView: View
): RecyclerView.ViewHolder(containerView), LayoutContainer
internal open class BaseViewHolder<VB : ViewBinding>(
protected val binding: VB
): RecyclerView.ViewHolder(binding.root)
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
package nz.co.trademe.konfigure.android.ui.adapter.viewholder

import android.view.ViewGroup
import kotlinx.android.synthetic.main.view_holder_boolean.*
import nz.co.trademe.konfigure.android.R
import nz.co.trademe.konfigure.android.ui.adapter.ConfigAdapterModel
import nz.co.trademe.konfigure.android.databinding.ViewHolderBooleanBinding
import nz.co.trademe.konfigure.android.extensions.applicationConfig
import nz.co.trademe.konfigure.android.ui.adapter.ConfigAdapterModel

internal class BooleanConfigViewHolder(
parent: ViewGroup
) : BaseViewHolder(parent.inflate(R.layout.view_holder_boolean)) {
parent: ViewGroup,
) : BaseViewHolder<ViewHolderBooleanBinding>(parent.inflate(ViewHolderBooleanBinding::inflate)) {

fun bind(model: ConfigAdapterModel.BooleanConfig) {
itemView.setOnClickListener {
valueSwitch.toggle()
}
with(binding) {
itemView.setOnClickListener {
valueSwitch.toggle()
}

titleTextView.text = model.metadata.title
titleTextView.showAsModified(model.isModified)
titleTextView.text = model.metadata.title
titleTextView.showAsModified(model.isModified)

descriptionTextView.text = model.metadata.description
descriptionTextView.text = model.metadata.description

valueSwitch.setOnCheckedChangeListener(null)
valueSwitch.isChecked = model.value
valueSwitch.setOnCheckedChangeListener { _, newValue ->
itemView.context.applicationConfig.setValueOf(model.item, Boolean::class, newValue)
valueSwitch.setOnCheckedChangeListener(null)
valueSwitch.isChecked = model.value
valueSwitch.setOnCheckedChangeListener { _, newValue ->
itemView.context.applicationConfig.setValueOf(model.item, Boolean::class, newValue)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package nz.co.trademe.konfigure.android.ui.adapter.viewholder
import android.view.ViewGroup
import androidx.appcompat.content.res.AppCompatResources
import nz.co.trademe.konfigure.android.R
import nz.co.trademe.konfigure.android.databinding.ViewHolderDividerBinding

internal class DividerViewHolder(
parent: ViewGroup
) : BaseViewHolder(parent.inflate(R.layout.view_holder_divider)) {
) : BaseViewHolder<ViewHolderDividerBinding>(parent.inflate(ViewHolderDividerBinding::inflate)) {

init {
itemView.setBackgroundColor(AppCompatResources.getColorStateList(itemView.context, R.color.color_divider).defaultColor)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package nz.co.trademe.konfigure.android.ui.adapter.viewholder

import android.view.ViewGroup
import kotlinx.android.synthetic.main.view_holder_header.*
import nz.co.trademe.konfigure.android.R
import nz.co.trademe.konfigure.android.databinding.ViewHolderHeaderBinding

internal class HeaderViewHolder(
parent: ViewGroup
) : BaseViewHolder(parent.inflate(R.layout.view_holder_header)) {
) : BaseViewHolder<ViewHolderHeaderBinding>(parent.inflate(ViewHolderHeaderBinding::inflate)) {

fun bind(title: String) {
titleTextView.text = title
binding.titleTextView.text = title
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@ package nz.co.trademe.konfigure.android.ui.adapter.viewholder

import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.view_holder_number.*
import nz.co.trademe.konfigure.android.R
import nz.co.trademe.konfigure.android.databinding.ViewHolderNumberBinding
import nz.co.trademe.konfigure.android.ui.adapter.ConfigAdapterModel
import nz.co.trademe.konfigure.android.ui.dialog.EditConfigDialogFragment

internal class NumberConfigViewHolder(
parent: ViewGroup
) : BaseViewHolder(parent.inflate(R.layout.view_holder_number)) {
) : BaseViewHolder<ViewHolderNumberBinding>(parent.inflate(ViewHolderNumberBinding::inflate)) {

fun bind(model: ConfigAdapterModel.NumberConfig<*>) {
titleTextView.text = model.metadata.title
titleTextView.showAsModified(model.isModified)
with(binding) {
titleTextView.text = model.metadata.title
titleTextView.showAsModified(model.isModified)

descriptionTextView.text = model.metadata.description
descriptionTextView.text = model.metadata.description

currentValueTextView.text = model.value.toString()
currentValueTextView.applyMonospaceFont()
currentValueTextView.text = model.value.toString()
currentValueTextView.applyMonospaceFont()

itemView.setOnClickListener {
EditConfigDialogFragment.start(
itemView.setOnClickListener {
EditConfigDialogFragment.start(
model.item,
model.value.toString(),
(itemView.context as AppCompatActivity).supportFragmentManager)
(itemView.context as AppCompatActivity).supportFragmentManager
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package nz.co.trademe.konfigure.android.ui.adapter.viewholder

import android.view.ViewGroup
import kotlinx.android.synthetic.main.view_holder_reset_to_default.*
import nz.co.trademe.konfigure.android.R
import nz.co.trademe.konfigure.android.databinding.ViewHolderResetToDefaultBinding

internal class ResetToDefaultFooterViewHolder(
parent: ViewGroup
) : BaseViewHolder(parent.inflate(R.layout.view_holder_reset_to_default)) {
) : BaseViewHolder<ViewHolderResetToDefaultBinding>(parent.inflate(ViewHolderResetToDefaultBinding::inflate)) {

fun bind(resetCallback: () -> Unit) {
resetToDefaultButton.setOnClickListener {
binding.resetToDefaultButton.setOnClickListener {
resetCallback()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,33 @@ package nz.co.trademe.konfigure.android.ui.adapter.viewholder

import android.annotation.SuppressLint
import android.view.ViewGroup
import kotlinx.android.synthetic.main.view_holder_string.*
import nz.co.trademe.konfigure.android.R
import nz.co.trademe.konfigure.android.databinding.ViewHolderStringBinding
import nz.co.trademe.konfigure.android.ui.ConfigActivity
import nz.co.trademe.konfigure.android.ui.adapter.ConfigAdapterModel
import nz.co.trademe.konfigure.android.ui.dialog.EditConfigDialogFragment
import nz.co.trademe.konfigure.android.ui.ConfigActivity

internal class StringConfigViewHolder(
parent: ViewGroup
) : BaseViewHolder(parent.inflate(R.layout.view_holder_string)) {
) : BaseViewHolder<ViewHolderStringBinding>(parent.inflate(ViewHolderStringBinding::inflate)) {

fun bind(model: ConfigAdapterModel.StringConfig) {
titleTextView.text = model.metadata.title
titleTextView.showAsModified(model.isModified)
with (binding) {
titleTextView.text = model.metadata.title
titleTextView.showAsModified(model.isModified)

descriptionTextView.text = model.metadata.description
descriptionTextView.text = model.metadata.description

@SuppressLint("SetTextI18n")
currentValueTextView.text = "\"${model.value}\""
currentValueTextView.applyMonospaceFont()
@SuppressLint("SetTextI18n")
currentValueTextView.text = "\"${model.value}\""
currentValueTextView.applyMonospaceFont()

itemView.setOnClickListener {
EditConfigDialogFragment.start(
itemView.setOnClickListener {
EditConfigDialogFragment.start(
model.item,
model.value,
(itemView.context as ConfigActivity).supportFragmentManager)
(itemView.context as ConfigActivity).supportFragmentManager
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.viewbinding.ViewBinding
import nz.co.trademe.konfigure.android.R

/**
* Helper function for allowing simple ViewHolder view inflation
*/
internal fun ViewGroup.inflate(@LayoutRes resource: Int): View =
LayoutInflater.from(context).inflate(resource, this, false)
internal fun <VB : ViewBinding> ViewGroup.inflate(inflate: (LayoutInflater, ViewGroup, Boolean) -> VB): VB {
return inflate(LayoutInflater.from(context), this, false)
}

internal fun TextView.applyMonospaceFont() {
val typeface = Typeface.createFromAsset(context.assets, "fonts/RobotoMono-Regular.ttf")
Expand Down
Loading

0 comments on commit 9da66c4

Please sign in to comment.