Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ out/
# Gradle files
.gradle/
build/
.idea/

# Local configuration file (sdk path, etc)
local.properties
Expand Down
3 changes: 2 additions & 1 deletion .idea/misc.xml

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

13 changes: 0 additions & 13 deletions .idea/modules.xml

This file was deleted.

8 changes: 8 additions & 0 deletions .idea/runConfigurations.xml

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

22 changes: 18 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 28
namespace("it.sephiroth.android.library.demo")
compileSdk 35
defaultConfig {
applicationId "it.sephiroth.android.library.demo"
minSdkVersion 23
targetSdkVersion 28
targetSdkVersion 35
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -20,16 +21,29 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
viewBinding true
buildConfig(true)
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}

}

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

implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.core:core-ktx:1.1.0-alpha03'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation project(':library')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/it/sephiroth/android/library/demo/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package it.sephiroth.android.library.demo

import android.app.Application
import it.sephiroth.android.library.checkbox3state.isDebugMode

class App:Application() {
override fun onCreate() {
super.onCreate()
isDebugMode = BuildConfig.DEBUG
}
}
59 changes: 42 additions & 17 deletions app/src/main/java/it/sephiroth/android/library/demo/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,86 @@ package it.sephiroth.android.library.demo

import android.os.Bundle
import android.widget.CheckBox
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
import it.sephiroth.android.library.demo.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

private lateinit var checkbox_array: Array<CheckBox>
private lateinit var viewBinding: ActivityMainBinding
var listenToUpdates = true

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
viewBinding = ActivityMainBinding.inflate(layoutInflater)
setContentView(viewBinding.root)

checkBox1.setOnCheckedChangeListener { buttonView, isChecked ->
viewBinding.checkBox1.setOnCheckedChangeListener { buttonView, isChecked ->
if (listenToUpdates) {
listenToUpdates = false
if (!isChecked) {
checkbox_array.forEach { it.isChecked = false }
} else if (isChecked) {
checkbox_array.forEach { it.isChecked = true }
}
checkBox1.text = if(isChecked) "Select None" else "Select All"
checkBox1.setCycle(R.array.sephiroth_checkbox3_cycleCheckedUncheckedOnly)
viewBinding.checkBox1.text = if(isChecked) "Select None" else "Select All"
viewBinding.checkBox1.setCycle(it.sephiroth.android.library.checkbox3state.R.array.sephiroth_checkbox3_cycleCheckedUncheckedOnly)
listenToUpdates = true
}
}

viewBinding.getCheckStateInt.setOnClickListener {
val currentStateInt = viewBinding.threeStateSingleCheckBox.checkState
Toast.makeText(this, "current state Int $currentStateInt", Toast.LENGTH_SHORT).show()
}
viewBinding.checkStateGuide.text = "${viewBinding.checkStateGuide.text} \n [Checked => 1, Unchecked => 0, Indeterminated => -1]"

}

override fun onContentChanged() {
super.onContentChanged()

checkbox_array = arrayOf(checkBox2, checkBox3, checkBox4)
checkbox_array = arrayOf(viewBinding.checkBox2, viewBinding.checkBox3, viewBinding.checkBox4)

checkbox_array.forEach {
it.setOnCheckedChangeListener { buttonView, isChecked ->
checkbox_array.forEach { checkBox->
checkBox.setOnCheckedChangeListener { buttonView, isChecked ->
if (listenToUpdates) {
listenToUpdates = false
val checked_size = checkbox_array.filter { it.isChecked }.size

if (checked_size == checkbox_array.size) {
checkBox1.setCycle(R.array.sephiroth_checkbox3_cycleCheckedUncheckedOnly)
checkBox1.setChecked(true, false)
checkBox1.text = "Select None"
viewBinding.checkBox1.setCycle(it.sephiroth.android.library.checkbox3state.R.array.sephiroth_checkbox3_cycleCheckedUncheckedOnly)
viewBinding.checkBox1.setChecked(true, false)
viewBinding.checkBox1.text = "Select None"
} else if (checked_size == 0) {
checkBox1.setCycle(R.array.sephiroth_checkbox3_cycleCheckedUncheckedOnly)
checkBox1.setChecked(false, false)
checkBox1.text = "Select All"
viewBinding.checkBox1.setCycle(it.sephiroth.android.library.checkbox3state.R.array.sephiroth_checkbox3_cycleCheckedUncheckedOnly)
viewBinding.checkBox1.setChecked(false, false)
viewBinding.checkBox1.text = "Select All"
} else {
checkBox1.setCycle(R.array.sephiroth_checkbox3_cycleAll)
checkBox1.setChecked(false, true)
checkBox1.text = "Select All"
viewBinding.checkBox1.setCycle(it.sephiroth.android.library.checkbox3state.R.array.sephiroth_checkbox3_cycleAll)
viewBinding.checkBox1.setChecked(false, true)
viewBinding.checkBox1.text = "Select All"
}
listenToUpdates = true
}
}
}

viewBinding.threeStateSingleCheckBox.setOnNotifyListener { buttonView, isChecked, isIndetermianted ->
Toast.makeText(this, "isIndetermianted $isIndetermianted \nisChecked $isChecked", Toast.LENGTH_SHORT).show()
}

viewBinding.apply {
unchecked.setOnClickListener {
viewBinding.threeStateSingleCheckBox.checkState = 0
}
checked.setOnClickListener {
viewBinding.threeStateSingleCheckBox.checkState = 1
}
indeterminated.setOnClickListener {
viewBinding.threeStateSingleCheckBox.checkState = -1
}
}
}
}
70 changes: 70 additions & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,74 @@
app:layout_constraintStart_toStartOf="@+id/checkBox3"
app:layout_constraintTop_toBottomOf="@+id/checkBox3" />

<TextView
android:id="@+id/checkStateGuide"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Check State Int Guide: "
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/three_state_single_checkBox"
app:layout_constraintEnd_toEndOf="@+id/three_state_single_checkBox"
app:layout_constraintStart_toStartOf="@+id/three_state_single_checkBox"
android:layout_marginBottom="8dp"
android:gravity="center"/>

<it.sephiroth.android.library.checkbox3state.CheckBox3
android:id="@+id/three_state_single_checkBox"
style="@style/Sephiroth.Widget.Checkbox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:enabled="true"
android:text="Three State Single CheckBox"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:sephiroth_checkbox3_checkableCycle="@array/sephiroth_checkbox3_cycleIndeterminate"
app:sephiroth_checkbox3_indeterminate="false" />

<Button
android:id="@+id/checked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="checked"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="24dp"

app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/three_state_single_checkBox" />

<Button
android:id="@+id/unchecked"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="unchecked"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.501"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginTop="8dp"

app:layout_constraintTop_toBottomOf="@+id/checked" />

<Button
android:id="@+id/indeterminated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="indeterminated"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/unchecked" />

<Button
android:id="@+id/getCheckStateInt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get Check State Int"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/indeterminated" />

</androidx.constraintlayout.widget.ConstraintLayout>
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.11'
ext.kotlin_version = '1.9.25'
repositories {
google()
jcenter()

}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0-alpha10'
classpath 'com.android.tools.build:gradle:8.6.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jan 14 18:48:18 EST 2019
#Sun Jan 26 15:47:09 GMT+03:30 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-milestone-1-all.zip
22 changes: 15 additions & 7 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-parcelize'
apply plugin: 'kotlin-kapt'

android {
compileSdkVersion rootProject.ext.compileSdkVersion
testBuildType "debug"
namespace("it.sephiroth.android.library.checkbox3state")


defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
minSdkVersion 23
compileSdk 35
targetSdkVersion 35
versionCode 1
versionName VERSION_NAME

Expand All @@ -29,10 +31,13 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}
testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
animationsDisabled true
Expand All @@ -42,6 +47,9 @@ android {
}
}

buildFeatures {
viewBinding true
}
}

dependencies {
Expand Down Expand Up @@ -80,4 +88,4 @@ try {

}

uploadArchives.dependsOn 'check'
//uploadArchives.dependsOn 'check'
Loading