Loading tests/SilkFX/res/layout/activity_glass.xml +13 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,19 @@ app:layout_constraintStart_toEndOf="@+id/background2" android:src="@drawable/background3" /> <Button android:id="@+id/pickImage" android:layout_width="64dp" android:layout_height="64dp" android:layout_marginStart="8dp" android:scaleType="centerCrop" android:foreground="?android:attr/selectableItemBackgroundBorderless" android:clickable="true" android:onClick="onPickImageClick" app:layout_constraintBottom_toBottomOf="@+id/background1" app:layout_constraintStart_toEndOf="@+id/background3" android:text="Pick file" /> <Switch android:id="@+id/lightMaterialSwitch" android:layout_width="wrap_content" Loading tests/SilkFX/src/com/android/test/silkfx/materials/GlassActivity.kt +25 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.test.silkfx.materials import android.app.Activity import android.content.Intent import android.graphics.Bitmap import android.graphics.BitmapFactory import android.graphics.Color Loading Loading @@ -47,7 +48,12 @@ class GlassActivity : Activity(), SeekBar.OnSeekBarChangeListener { lateinit var blurRadiusValue: TextView lateinit var zoomValue: TextView lateinit var background: Bitmap var background: Bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888) set(value) { field = value backgroundView.setImageBitmap(background) materialView.backgroundBitmap = background } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) Loading @@ -70,8 +76,6 @@ class GlassActivity : Activity(), SeekBar.OnSeekBarChangeListener { zoomValue = requireViewById(R.id.zoomValue) background = BitmapFactory.decodeResource(resources, R.drawable.background1) backgroundView.setImageBitmap(background) materialView.backgroundBitmap = background blurRadiusSeekBar.setOnSeekBarChangeListener(this) materialOpacitySeekBar.setOnSeekBarChangeListener(this) Loading Loading @@ -128,7 +132,23 @@ class GlassActivity : Activity(), SeekBar.OnSeekBarChangeListener { } background = BitmapFactory.decodeResource(resources, resource) backgroundView.setImageBitmap(background) materialView.backgroundBitmap = background } fun onPickImageClick(view: View) { val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply { addCategory(Intent.CATEGORY_OPENABLE) type = "image/*" } startActivityForResult(intent, 0) } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { if (resultCode === RESULT_OK) { data?.data?.also { contentResolver.openFileDescriptor(it, "r").let { background = BitmapFactory.decodeFileDescriptor(it?.fileDescriptor) } } } } } No newline at end of file Loading
tests/SilkFX/res/layout/activity_glass.xml +13 −0 Original line number Diff line number Diff line Loading @@ -219,6 +219,19 @@ app:layout_constraintStart_toEndOf="@+id/background2" android:src="@drawable/background3" /> <Button android:id="@+id/pickImage" android:layout_width="64dp" android:layout_height="64dp" android:layout_marginStart="8dp" android:scaleType="centerCrop" android:foreground="?android:attr/selectableItemBackgroundBorderless" android:clickable="true" android:onClick="onPickImageClick" app:layout_constraintBottom_toBottomOf="@+id/background1" app:layout_constraintStart_toEndOf="@+id/background3" android:text="Pick file" /> <Switch android:id="@+id/lightMaterialSwitch" android:layout_width="wrap_content" Loading
tests/SilkFX/src/com/android/test/silkfx/materials/GlassActivity.kt +25 −5 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.test.silkfx.materials import android.app.Activity import android.content.Intent import android.graphics.Bitmap import android.graphics.BitmapFactory import android.graphics.Color Loading Loading @@ -47,7 +48,12 @@ class GlassActivity : Activity(), SeekBar.OnSeekBarChangeListener { lateinit var blurRadiusValue: TextView lateinit var zoomValue: TextView lateinit var background: Bitmap var background: Bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888) set(value) { field = value backgroundView.setImageBitmap(background) materialView.backgroundBitmap = background } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) Loading @@ -70,8 +76,6 @@ class GlassActivity : Activity(), SeekBar.OnSeekBarChangeListener { zoomValue = requireViewById(R.id.zoomValue) background = BitmapFactory.decodeResource(resources, R.drawable.background1) backgroundView.setImageBitmap(background) materialView.backgroundBitmap = background blurRadiusSeekBar.setOnSeekBarChangeListener(this) materialOpacitySeekBar.setOnSeekBarChangeListener(this) Loading Loading @@ -128,7 +132,23 @@ class GlassActivity : Activity(), SeekBar.OnSeekBarChangeListener { } background = BitmapFactory.decodeResource(resources, resource) backgroundView.setImageBitmap(background) materialView.backgroundBitmap = background } fun onPickImageClick(view: View) { val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply { addCategory(Intent.CATEGORY_OPENABLE) type = "image/*" } startActivityForResult(intent, 0) } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { if (resultCode === RESULT_OK) { data?.data?.also { contentResolver.openFileDescriptor(it, "r").let { background = BitmapFactory.decodeFileDescriptor(it?.fileDescriptor) } } } } } No newline at end of file