From 3ae7e4df7032fdde81bb71739dbc263641e27232 Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Tue, 18 Jan 2022 20:42:13 +0100 Subject: [PATCH] Remove DialogSingleChoiceAdapter --- .../sushi/hardcore/droidfs/CameraActivity.kt | 8 ++--- .../adapters/DialogSingleChoiceAdapter.kt | 31 ------------------- .../droidfs/explorers/BaseExplorerActivity.kt | 3 +- .../adapter_colored_dialog_single_choice.xml | 14 --------- 4 files changed, 5 insertions(+), 51 deletions(-) delete mode 100644 app/src/main/java/sushi/hardcore/droidfs/adapters/DialogSingleChoiceAdapter.kt delete mode 100644 app/src/main/res/layout/adapter_colored_dialog_single_choice.xml diff --git a/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt index c53d161..af2b140 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/CameraActivity.kt @@ -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 diff --git a/app/src/main/java/sushi/hardcore/droidfs/adapters/DialogSingleChoiceAdapter.kt b/app/src/main/java/sushi/hardcore/droidfs/adapters/DialogSingleChoiceAdapter.kt deleted file mode 100644 index bdf9703..0000000 --- a/app/src/main/java/sushi/hardcore/droidfs/adapters/DialogSingleChoiceAdapter.kt +++ /dev/null @@ -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): 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(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 } -} \ No newline at end of file diff --git a/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt b/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt index 293a4fa..a2fd394 100644 --- a/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt +++ b/app/src/main/java/sushi/hardcore/droidfs/explorers/BaseExplorerActivity.kt @@ -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() diff --git a/app/src/main/res/layout/adapter_colored_dialog_single_choice.xml b/app/src/main/res/layout/adapter_colored_dialog_single_choice.xml deleted file mode 100644 index a21c62e..0000000 --- a/app/src/main/res/layout/adapter_colored_dialog_single_choice.xml +++ /dev/null @@ -1,14 +0,0 @@ - - \ No newline at end of file