Remove DialogSingleChoiceAdapter

This commit is contained in:
Matéo Duparc 2022-01-18 20:42:13 +01:00
parent 55883172a1
commit 3ae7e4df70
Signed by untrusted user: hardcoresushi
GPG Key ID: 007F84120107191E
4 changed files with 5 additions and 51 deletions

View File

@ -29,14 +29,14 @@ import androidx.camera.extensions.ExtensionsManager
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.core.app.ActivityCompat
import androidx.core.content.ContextCompat
import sushi.hardcore.droidfs.adapters.DialogSingleChoiceAdapter
import sushi.hardcore.droidfs.content_providers.RestrictedFileProvider
import sushi.hardcore.droidfs.databinding.ActivityCameraBinding
import sushi.hardcore.droidfs.util.PathUtils
import sushi.hardcore.droidfs.video_recording.SeekableWriter
import sushi.hardcore.droidfs.video_recording.VideoCapture
import sushi.hardcore.droidfs.widgets.CustomAlertDialogBuilder
import java.io.*
import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream
import java.text.SimpleDateFormat
import java.util.*
import java.util.concurrent.Executor
@ -127,7 +127,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
}
CustomAlertDialogBuilder(this, themeValue)
.setTitle(R.string.camera_optimization)
.setSingleChoiceItems(DialogSingleChoiceAdapter(this, arrayOf(R.string.maximize_quality, R.string.minimize_latency).map { getString(it) }), currentIndex) { dialog, which ->
.setSingleChoiceItems(arrayOf(getString(R.string.maximize_quality), getString(R.string.minimize_latency)), currentIndex) { dialog, which ->
val resId: Int
val newCaptureMode = if (which == 0) {
resId = R.drawable.icon_high_quality
@ -150,7 +150,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
resolutions?.let {
CustomAlertDialogBuilder(this, themeValue)
.setTitle(R.string.choose_resolution)
.setSingleChoiceItems(DialogSingleChoiceAdapter(this, it.map { size -> size.toString() }), currentResolutionIndex) { dialog, which ->
.setSingleChoiceItems(it.map { size -> size.toString() }.toTypedArray(), currentResolutionIndex) { dialog, which ->
setupCamera(resolutions!![which])
dialog.dismiss()
currentResolutionIndex = which

View File

@ -1,31 +0,0 @@
package sushi.hardcore.droidfs.adapters
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.CheckedTextView
import sushi.hardcore.droidfs.R
class DialogSingleChoiceAdapter(private val context: Context, private val entries: List<String>): BaseAdapter() {
private val inflater: LayoutInflater = LayoutInflater.from(context)
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
val view: View = convertView ?: inflater.inflate(R.layout.adapter_colored_dialog_single_choice, parent, false)
val checkedTextView = view.findViewById<CheckedTextView>(android.R.id.text1)
checkedTextView.text = getItem(position)
val typedArray = context.theme.obtainStyledAttributes(arrayOf(android.R.attr.listChoiceIndicatorSingle).toIntArray())
val drawable = typedArray.getDrawable(0)
typedArray.recycle()
checkedTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
return view
}
override fun getItem(position: Int): String {
return entries[position]
}
override fun getItemId(position: Int): Long { return 0 }
override fun getCount(): Int { return entries.size }
}

View File

@ -29,7 +29,6 @@ import sushi.hardcore.droidfs.ConstValues.Companion.isText
import sushi.hardcore.droidfs.ConstValues.Companion.isVideo
import sushi.hardcore.droidfs.GocryptfsVolume
import sushi.hardcore.droidfs.R
import sushi.hardcore.droidfs.adapters.DialogSingleChoiceAdapter
import sushi.hardcore.droidfs.adapters.ExplorerElementAdapter
import sushi.hardcore.droidfs.adapters.OpenAsDialogAdapter
import sushi.hardcore.droidfs.content_providers.ExternalProvider
@ -513,7 +512,7 @@ open class BaseExplorerActivity : BaseActivity() {
R.id.sort -> {
CustomAlertDialogBuilder(this, themeValue)
.setTitle(R.string.sort_order)
.setSingleChoiceItems(DialogSingleChoiceAdapter(this, sortOrderEntries.toList()), currentSortOrderIndex) { dialog, which ->
.setSingleChoiceItems(sortOrderEntries, currentSortOrderIndex) { dialog, which ->
currentSortOrderIndex = which
setCurrentPath(currentDirectoryPath)
dialog.dismiss()

View File

@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingEnd="16dp"
android:paddingStart="24dp"
android:textSize="@dimen/adapter_text_size"
android:textColor="?android:attr/textColorAlertDialogListItem"
android:drawableStart="?android:attr/listChoiceIndicatorSingle"
android:drawablePadding="20dp"/>