Work on Creator Activity : Allow selection of multiples files
This commit is contained in:
parent
216b4c78e7
commit
eb2d4a579e
|
@ -10,6 +10,7 @@ import java.io.InputStream
|
|||
import java.io.OutputStream
|
||||
import java.util.zip.CRC32
|
||||
|
||||
// TODO DOCUMENTATION
|
||||
class ApngEncoder(
|
||||
private val outputStream: OutputStream,
|
||||
private val width : Int,
|
||||
|
|
|
@ -45,6 +45,7 @@ class CreatorActivity : AppCompatActivity() {
|
|||
|
||||
fabAddImage.setOnClickListener {
|
||||
val getIntent = Intent(Intent.ACTION_GET_CONTENT)
|
||||
getIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true)
|
||||
getIntent.type = "image/*"
|
||||
|
||||
startActivityForResult(
|
||||
|
@ -228,6 +229,11 @@ class CreatorActivity : AppCompatActivity() {
|
|||
}
|
||||
true
|
||||
}
|
||||
R.id.menu_clear -> {
|
||||
items.clear()
|
||||
adapter?.notifyDataSetChanged()
|
||||
true
|
||||
}
|
||||
else -> if (item != null) super.onOptionsItemSelected(item) else true
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +243,12 @@ class CreatorActivity : AppCompatActivity() {
|
|||
when (requestCode) {
|
||||
PICK_IMAGE -> {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
if (data?.data != null) {
|
||||
if (data?.clipData != null) {
|
||||
for (i in 0 until data.clipData!!.itemCount) {
|
||||
items.add(Pair(data.clipData!!.getItemAt(i).uri, 1000))
|
||||
}
|
||||
adapter?.notifyDataSetChanged()
|
||||
} else if (data?.data != null) {
|
||||
items.add(Pair(data.data!!, 1000))
|
||||
adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ class ImageAdapter(private val context : Context, private val list : List<Pair<U
|
|||
val imageView : ImageView? = view.findViewById(R.id.listImageView)
|
||||
val textDelay : TextView? = view.findViewById(R.id.textDelay)
|
||||
val positionTextView : TextView? = view.findViewById(R.id.position_textView)
|
||||
val nameTextView : TextView? = view.findViewById(R.id.name_textView)
|
||||
}
|
||||
|
||||
var clickListener : ((position : Int) -> Unit)? = null
|
||||
|
@ -34,6 +35,7 @@ class ImageAdapter(private val context : Context, private val list : List<Pair<U
|
|||
holder.itemView.setOnClickListener { clickListener?.invoke(position) }
|
||||
holder.textDelay?.text = String.format("%dms", list[position].second)
|
||||
holder.positionTextView?.text = String.format("# %d", position + 1)
|
||||
holder.nameTextView?.text = list[position].first.path?.substringAfterLast("/")
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
val inputStream = context.contentResolver.openInputStream(list[position].first)
|
||||
val btm = BitmapFactory.decodeStream(inputStream, null, BitmapFactory.Options().apply {
|
||||
|
|
|
@ -3,7 +3,6 @@ package oupson.apngcreator.dialogs
|
|||
import android.app.Dialog
|
||||
import android.content.DialogInterface
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import androidx.fragment.app.DialogFragment
|
||||
|
@ -25,7 +24,7 @@ class DelayInputDialog(
|
|||
override fun getTheme() = R.style.RoundedCornersDialog
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
val dialogLayout: View = LayoutInflater.from(activity).inflate(R.layout.dialog_delay, null)
|
||||
val dialogLayout: View = View.inflate(context, R.layout.dialog_delay, null)
|
||||
mNumberEdit =
|
||||
dialogLayout.findViewById<TextInputLayout>(R.id.delay_textInputLayout).editText
|
||||
if (value != null)
|
||||
|
|
|
@ -2,19 +2,19 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout 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:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/position_textView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
tools:text="#1"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="#1" />
|
||||
|
||||
<oupson.apngcreator.views.SquareImageView
|
||||
android:id="@+id/listImageView"
|
||||
|
@ -22,22 +22,34 @@
|
|||
android:layout_height="80dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:scaleType="fitCenter"
|
||||
app:layout_constraintBottom_toBottomOf="@id/textDelay"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/position_textView"
|
||||
app:layout_constraintTop_toTopOf="@+id/textDelay"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:srcCompat="@tools:sample/avatars" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/textDelay"
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/name_textView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/listImageView"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="1000ms" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/name_textView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/listImageView"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
app:layout_constraintTop_toBottomOf="@+id/textDelay"
|
||||
tools:text="foo.png" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -29,4 +29,10 @@
|
|||
android:title="@string/set_all_duration"
|
||||
app:showAsAction="ifRoom"
|
||||
app:iconTint="@color/control"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_clear"
|
||||
android:title="@string/clear"
|
||||
app:showAsAction="never"
|
||||
app:iconTint="@color/control" />
|
||||
</menu>
|
|
@ -15,6 +15,7 @@
|
|||
<string name="save">Save</string>
|
||||
<string name="set_all_duration">Set duration of all frames</string>
|
||||
<string name="done">Done</string>
|
||||
<string name="clear">Clear</string>
|
||||
|
||||
<string name="open">open</string>
|
||||
<string name="close">close</string>
|
||||
|
|
Loading…
Reference in New Issue