-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample: Add activity to test color APIs simply
- Loading branch information
Showing
7 changed files
with
172 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
sample/src/main/java/soup/neumorphism/sample/ColorSampleActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package soup.neumorphism.sample | ||
|
||
import android.content.res.ColorStateList | ||
import android.graphics.Color | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import androidx.appcompat.app.AppCompatActivity | ||
import soup.neumorphism.sample.databinding.ActivitySampleColorBinding | ||
|
||
class ColorSampleActivity : AppCompatActivity() { | ||
|
||
private lateinit var binding: ActivitySampleColorBinding | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
binding = ActivitySampleColorBinding.inflate(LayoutInflater.from(this)) | ||
setContentView(binding.root) | ||
|
||
onBackgroundColorChanged(Color.RED) | ||
} | ||
|
||
private fun onBackgroundColorChanged(backgroundColor: Int) { | ||
binding.run { | ||
card.setBackgroundColor(backgroundColor) | ||
imageView.setBackgroundColor(backgroundColor) | ||
imageButton.setBackgroundColor(backgroundColor) | ||
button.setBackgroundColor(backgroundColor) | ||
fab.setBackgroundColor(backgroundColor) | ||
} | ||
} | ||
|
||
private fun onBackgroundColorChanged(backgroundColor: ColorStateList?) { | ||
binding.run { | ||
card.setBackgroundColor(backgroundColor) | ||
imageView.setBackgroundColor(backgroundColor) | ||
imageButton.setBackgroundColor(backgroundColor) | ||
button.setBackgroundColor(backgroundColor) | ||
fab.setBackgroundColor(backgroundColor) | ||
} | ||
} | ||
|
||
private fun onStrokeColorChanged(strokeColor: ColorStateList?) { | ||
binding.run { | ||
card.setStrokeColor(strokeColor) | ||
imageView.setStrokeColor(strokeColor) | ||
imageButton.setStrokeColor(strokeColor) | ||
button.setStrokeColor(strokeColor) | ||
fab.setStrokeColor(strokeColor) | ||
} | ||
} | ||
|
||
private fun onStrokeWidthChanged(strokeWidth: Float) { | ||
binding.run { | ||
card.setStrokeWidth(strokeWidth) | ||
imageView.setStrokeWidth(strokeWidth) | ||
imageButton.setStrokeWidth(strokeWidth) | ||
button.setStrokeWidth(strokeWidth) | ||
fab.setStrokeWidth(strokeWidth) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
package soup.neumorphism.sample | ||
|
||
import android.content.Intent | ||
import android.os.Bundle | ||
import android.view.View | ||
import androidx.appcompat.app.AppCompatActivity | ||
|
||
class MainActivity : AppCompatActivity() { | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
findViewById<View>(R.id.button).setOnClickListener { | ||
startActivity(Intent(this, ColorSampleActivity::class.java)) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<gradient | ||
android:angle="135" | ||
android:endColor="#444444" | ||
android:startColor="#111111" /> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="rectangle"> | ||
<gradient | ||
android:angle="135" | ||
android:endColor="#eeeeee" | ||
android:startColor="#cccccc" /> | ||
</shape> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
tools:context=".ColorSampleActivity"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical"> | ||
|
||
<soup.neumorphism.NeumorphCardView | ||
android:layout_width="150dp" | ||
android:layout_height="150dp" | ||
android:layout_gravity="center_horizontal" | ||
app:layout_constraintEnd_toStartOf="@id/pressed_card" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/textview"> | ||
|
||
<View | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@drawable/gradation" /> | ||
|
||
</soup.neumorphism.NeumorphCardView> | ||
|
||
<soup.neumorphism.NeumorphCardView | ||
android:id="@+id/card" | ||
android:layout_width="150dp" | ||
android:layout_height="150dp" | ||
android:layout_gravity="center_horizontal" | ||
app:layout_constraintEnd_toStartOf="@id/pressed_card" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/textview" /> | ||
|
||
<soup.neumorphism.NeumorphImageView | ||
android:id="@+id/image_view" | ||
style="@style/Widget.Neumorph.ImageButton" | ||
android:layout_width="88dp" | ||
android:layout_height="88dp" | ||
android:layout_gravity="center_horizontal" | ||
android:scaleType="centerInside" | ||
android:src="@drawable/ic_daynight_sky" | ||
app:layout_constraintEnd_toStartOf="@id/pressed_image_view" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/card_barrier" /> | ||
|
||
<soup.neumorphism.NeumorphImageButton | ||
android:id="@+id/image_button" | ||
style="@style/Widget.Neumorph.ImageButton" | ||
android:layout_width="88dp" | ||
android:layout_height="88dp" | ||
android:layout_gravity="center_horizontal" | ||
android:scaleType="centerInside" | ||
android:src="@drawable/ic_daynight_sky" | ||
app:layout_constraintEnd_toStartOf="@id/pressed_image_view" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/card_barrier" /> | ||
|
||
<soup.neumorphism.NeumorphButton | ||
android:id="@+id/button" | ||
style="@style/Widget.Neumorph.Button" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center_horizontal" | ||
android:text="Button" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" /> | ||
|
||
<soup.neumorphism.NeumorphFloatingActionButton | ||
android:id="@+id/fab" | ||
style="@style/Widget.Neumorph.FloatingActionButton" | ||
android:layout_width="88dp" | ||
android:layout_height="88dp" | ||
android:layout_gravity="center_horizontal" | ||
android:scaleType="centerInside" | ||
android:src="@drawable/ic_filter" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" /> | ||
|
||
</LinearLayout> | ||
</ScrollView> |