Skip to content

Commit

Permalink
demo and fun
Browse files Browse the repository at this point in the history
Took 18 minutes
  • Loading branch information
raheemadamboev committed Dec 19, 2021
1 parent 2cc74c0 commit cbaa822
Show file tree
Hide file tree
Showing 13 changed files with 71 additions and 30 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

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

1 change: 1 addition & 0 deletions .idea/misc.xml

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

7 changes: 6 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@ android {
kotlinOptions {
jvmTarget = '1.8'
}

buildFeatures {
viewBinding true
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'com.github.raheemadamboev:image-radio-button-android:1.0.1'
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
package xyz.teamgravity.imageradiobuttondemo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import xyz.teamgravity.imageradiobutton.GravityImageRadioButton
import xyz.teamgravity.imageradiobutton.GravityRadioGroup
import xyz.teamgravity.imageradiobuttondemo.databinding.ActivityMainBinding

class MainActivity : AppCompatActivity() {

private lateinit var binding: ActivityMainBinding

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

binding.gravityGroup.setOnCheckedChangeListener(object : GravityRadioGroup.OnCheckedChangeListener {
override fun onCheckedChanged(radioGroup: View, radioButton: View?, checked: Boolean, checkedId: Int) {
Toast.makeText(this@MainActivity, (radioButton as GravityImageRadioButton).text(), Toast.LENGTH_SHORT).show()
}
})
}
}
Binary file added app/src/main/res/drawable/android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/kotlin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/tea.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 42 additions & 7 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,48 @@
android:layout_height="match_parent"
tools:context=".MainActivity">

<TextView
android:layout_width="wrap_content"
<xyz.teamgravity.imageradiobutton.GravityRadioGroup
android:id="@+id/gravity_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_margin="20dp"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent">

<xyz.teamgravity.imageradiobutton.GravityImageRadioButton
android:id="@+id/android_b"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dp"
app:image="@drawable/android"
app:pressedBackgroundDrawable="@drawable/background_shape_preset_button_pressed"
app:pressedTextColor="@color/white"
app:unpressedText="Android"
app:unpressedTextColor="@color/black" />

<xyz.teamgravity.imageradiobutton.GravityImageRadioButton
android:id="@+id/java_b"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dp"
app:image="@drawable/tea"
app:pressedBackgroundDrawable="@drawable/background_shape_preset_button_pressed"
app:pressedTextColor="@color/white"
app:unpressedText="Java"
app:unpressedTextColor="@color/black" />

<xyz.teamgravity.imageradiobutton.GravityImageRadioButton
android:id="@+id/kotlin_b"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:padding="20dp"
app:image="@drawable/kotlin"
app:pressedBackgroundDrawable="@drawable/background_shape_preset_button_pressed"
app:pressedTextColor="@color/white"
app:unpressedText="Kotlin"
app:unpressedTextColor="@color/black" />
</xyz.teamgravity.imageradiobutton.GravityRadioGroup>
</androidx.constraintlayout.widget.ConstraintLayout>
16 changes: 0 additions & 16 deletions app/src/main/res/values-night/themes.xml

This file was deleted.

3 changes: 2 additions & 1 deletion app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.ImageRadioButtonDemo" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.ImageRadioButtonDemo" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
Expand All @@ -12,5 +12,6 @@
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
<item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
</style>
</resources>
1 change: 0 additions & 1 deletion image_radio_button/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ android {
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface GravityRadioCheckable : Checkable {

fun removeOnCheckedChangeListener(listener: OnCheckedChangeListener)

interface OnCheckedChangeListener {
fun interface OnCheckedChangeListener {
fun onCheckedChange(radioButton: View, checked: Boolean)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class GravityRadioGroup : LinearLayout {

fun onCheckedChangeListener() = onCheckedChangeListener

interface OnCheckedChangeListener {
fun interface OnCheckedChangeListener {
fun onCheckedChanged(radioGroup: View, radioButton: View?, checked: Boolean, checkedId: Int)
}

Expand Down

0 comments on commit cbaa822

Please sign in to comment.