diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7f8e6394..3a6aa629 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -31,5 +31,6 @@ + \ No newline at end of file diff --git a/app/src/main/java/info/touchimage/demo/MainActivity.kt b/app/src/main/java/info/touchimage/demo/MainActivity.kt index 1635d1ed..a79854d4 100644 --- a/app/src/main/java/info/touchimage/demo/MainActivity.kt +++ b/app/src/main/java/info/touchimage/demo/MainActivity.kt @@ -29,5 +29,6 @@ class MainActivity : AppCompatActivity() { binding.animateButton.setOnClickListener { startActivity(Intent(this@MainActivity, AnimateZoomActivity::class.java)) } binding.glideButton.setOnClickListener { startActivity(Intent(this@MainActivity, GlideExampleActivity::class.java)) } binding.shapedImageButton.setOnClickListener { startActivity(Intent(this@MainActivity, ShapedExampleActivity::class.java)) } + binding.touchSync.setOnClickListener { startActivity(Intent(this@MainActivity, TouchSyncActivity::class.java)) } } } \ No newline at end of file diff --git a/app/src/main/java/info/touchimage/demo/TouchSyncActivity.kt b/app/src/main/java/info/touchimage/demo/TouchSyncActivity.kt new file mode 100644 index 00000000..e62e712a --- /dev/null +++ b/app/src/main/java/info/touchimage/demo/TouchSyncActivity.kt @@ -0,0 +1,54 @@ +package info.touchimage.demo + +import android.content.Context +import android.graphics.Bitmap +import android.graphics.Canvas +import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.ContextCompat +import com.ortiz.touchview.OnTouchImageViewListener +import info.touchimage.demo.databinding.ActivityTouchSyncBinding + +class TouchSyncActivity : AppCompatActivity() { + + private lateinit var binding: ActivityTouchSyncBinding + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding = ActivityTouchSyncBinding.inflate(layoutInflater) + val view = binding.root + setContentView(view) + + binding.touchImageOverlay.setOnTouchImageViewListener(object : OnTouchImageViewListener { + override fun onMove() { + binding.touchImage1.setZoom(binding.touchImageOverlay) + binding.touchImage2.setZoom(binding.touchImageOverlay) + } + }) + + // Works + val img = getBitmap(this, R.drawable.ic_baseline_aspect_ratio_24) + + /** HERE IS THE PROBLEM **/ + // Does not work (after zooming in, dinosaur head is unreachable) +// val img = getBitmap(this, R.drawable.corgosaurus) + binding.touchImage2.setImageBitmap(img) + + // Also does not work (after zooming in, dinosaur head is unreachable) +// binding.touchImage2.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.corgosaurus)) + } + + private fun getBitmap(context: Context, drawableRes: Int): Bitmap? { + val drawable = ContextCompat.getDrawable(context, drawableRes) ?: return null + val canvas = Canvas() + val bitmap = Bitmap.createBitmap( + drawable.intrinsicWidth, + drawable.intrinsicHeight, + Bitmap.Config.ARGB_8888 + ) + canvas.setBitmap(bitmap) + drawable.setBounds(0, 0, drawable.intrinsicWidth, drawable.intrinsicHeight) + drawable.draw(canvas) + return bitmap + } +} diff --git a/app/src/main/res/drawable/corgosaurus.png b/app/src/main/res/drawable/corgosaurus.png new file mode 100644 index 00000000..b2e3738b Binary files /dev/null and b/app/src/main/res/drawable/corgosaurus.png differ diff --git a/app/src/main/res/drawable/ic_baseline_aspect_ratio_24.xml b/app/src/main/res/drawable/ic_baseline_aspect_ratio_24.xml new file mode 100644 index 00000000..97cb262a --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_aspect_ratio_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_lunch_dining_24.xml b/app/src/main/res/drawable/ic_baseline_lunch_dining_24.xml new file mode 100644 index 00000000..a8b4d1ea --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_lunch_dining_24.xml @@ -0,0 +1,19 @@ + + + + + diff --git a/app/src/main/res/drawable/ic_baseline_masks_24.xml b/app/src/main/res/drawable/ic_baseline_masks_24.xml new file mode 100644 index 00000000..04cafc0e --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_masks_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_mode_standby_24.xml b/app/src/main/res/drawable/ic_baseline_mode_standby_24.xml new file mode 100644 index 00000000..ef7b8980 --- /dev/null +++ b/app/src/main/res/drawable/ic_baseline_mode_standby_24.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..07d5da9c --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/img_user_avatar.png b/app/src/main/res/drawable/img_user_avatar.png new file mode 100644 index 00000000..6029ea8a Binary files /dev/null and b/app/src/main/res/drawable/img_user_avatar.png differ diff --git a/app/src/main/res/drawable/transparent.png b/app/src/main/res/drawable/transparent.png new file mode 100644 index 00000000..b6c16523 Binary files /dev/null and b/app/src/main/res/drawable/transparent.png differ diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 1e4e2625..68e9a2a2 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,6 +1,7 @@ +