diff --git a/app/src/main/java/com/micewine/emu/activities/EmulationActivity.kt b/app/src/main/java/com/micewine/emu/activities/EmulationActivity.kt index 8058a27..7782529 100644 --- a/app/src/main/java/com/micewine/emu/activities/EmulationActivity.kt +++ b/app/src/main/java/com/micewine/emu/activities/EmulationActivity.kt @@ -52,7 +52,6 @@ import com.micewine.emu.CmdEntryPoint.Companion.requestConnection import com.micewine.emu.ICmdEntryInterface import com.micewine.emu.LorieView import com.micewine.emu.R -import com.micewine.emu.activities.GeneralSettings.Companion.ACTION_PREFERENCES_CHANGED import com.micewine.emu.activities.MainActivity.Companion.ACTION_STOP_ALL import com.micewine.emu.activities.MainActivity.Companion.enableCpuCounter import com.micewine.emu.activities.MainActivity.Companion.enableRamCounter @@ -73,7 +72,6 @@ import com.micewine.emu.views.OverlayView import kotlinx.coroutines.cancel import kotlinx.coroutines.launch - class EmulationActivity : AppCompatActivity(), View.OnApplyWindowInsetsListener { private var mInputHandler: TouchInputHandler? = null private var service: ICmdEntryInterface? = null @@ -100,10 +98,6 @@ class EmulationActivity : AppCompatActivity(), View.OnApplyWindowInsetsListener Log.e("MainActivity", "Something went wrong while we extracted connection details from binder.", e) } } - ACTION_PREFERENCES_CHANGED -> { - Log.d("MainActivity", "preference: " + intent.getStringExtra("key")) - onPreferencesChanged() - } ACTION_STOP_ALL -> { finishAffinity() } @@ -273,7 +267,6 @@ class EmulationActivity : AppCompatActivity(), View.OnApplyWindowInsetsListener drawerLayout?.closeDrawers() } - lorieView.releasePointerCapture() return@OnKeyListener true } } else if (k == KeyEvent.KEYCODE_VOLUME_DOWN) { @@ -330,7 +323,6 @@ class EmulationActivity : AppCompatActivity(), View.OnApplyWindowInsetsListener registerReceiver(receiver, object : IntentFilter(ACTION_START) { init { - addAction(ACTION_PREFERENCES_CHANGED) addAction(ACTION_STOP_ALL) } }) @@ -349,6 +341,14 @@ class EmulationActivity : AppCompatActivity(), View.OnApplyWindowInsetsListener } } + override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { + lorieView.requestFocus() + + mLorieKeyListener?.onKey(null, keyCode, event) + + return true + } + override fun onGenericMotionEvent(event: MotionEvent?): Boolean { checkControllerAxis(lorieView, event!!) @@ -410,7 +410,7 @@ class EmulationActivity : AppCompatActivity(), View.OnApplyWindowInsetsListener } } - fun onPreferencesChanged() { + private fun onPreferencesChanged() { mInputHandler!!.setInputMode(TouchInputHandler.InputMode.TRACKPAD) mInputHandler!!.setTapToMove(false) mInputHandler!!.setPreferScancodes(isKeyboardConnected()) diff --git a/app/src/main/java/com/micewine/emu/activities/GeneralSettings.kt b/app/src/main/java/com/micewine/emu/activities/GeneralSettings.kt index c78d2f1..75b6e7a 100644 --- a/app/src/main/java/com/micewine/emu/activities/GeneralSettings.kt +++ b/app/src/main/java/com/micewine/emu/activities/GeneralSettings.kt @@ -117,7 +117,6 @@ class GeneralSettings : AppCompatActivity() { companion object { const val ACTION_PREFERENCE_SELECT = "com.micewine.emu.ACTION_PREFERENCE_SELECT" - const val ACTION_PREFERENCES_CHANGED = "com.micewine.emu.ACTION_PREFERENCES_CHANGED" const val SWITCH = 1 const val SPINNER = 2 const val CHECKBOX = 3 diff --git a/app/src/main/java/com/micewine/emu/adapters/AdapterFiles.kt b/app/src/main/java/com/micewine/emu/adapters/AdapterFiles.kt index 84c7af5..e79a4b5 100644 --- a/app/src/main/java/com/micewine/emu/adapters/AdapterFiles.kt +++ b/app/src/main/java/com/micewine/emu/adapters/AdapterFiles.kt @@ -1,5 +1,6 @@ package com.micewine.emu.adapters +import android.annotation.SuppressLint import android.content.Context import android.content.Intent import android.graphics.BitmapFactory @@ -19,6 +20,7 @@ import com.micewine.emu.activities.MainActivity.Companion.usrDir import com.micewine.emu.core.WineWrapper.extractIcon import com.micewine.emu.fragments.FloatingFileManagerFragment.Companion.refreshFiles import java.io.File +import kotlin.math.round class AdapterFiles(private val fileList: List, private val context: Context, private val isFloatFilesDialog: Boolean) : RecyclerView.Adapter() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { @@ -26,6 +28,7 @@ class AdapterFiles(private val fileList: List, private val context: Co return ViewHolder(itemView) } + @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: ViewHolder, position: Int) { val sList = fileList[position] @@ -37,7 +40,31 @@ class AdapterFiles(private val fileList: List, private val context: Co if (sList.file.isDirectory) { holder.icon.setImageResource(R.drawable.ic_folder) + + val count = sList.file.listFiles()?.count() + + if (count == null) { + holder.fileDescription.visibility = View.GONE + } else { + holder.fileDescription.visibility = View.VISIBLE + + holder.fileDescription.text = when (count) { + 0 -> { + context.getString(R.string.empty_text) + } + 1 -> { + "$count ${context.getString(R.string.item_text)}" + } + else -> { + "$count ${context.getString(R.string.items_text)}" + } + } + } } else if (sList.file.isFile) { + val fileSize = sList.file.length().toDouble() + + holder.fileDescription.text = formatSize(fileSize) + if (sList.file.name.endsWith(".exe")) { val output = "$usrDir/icons/${sList.file.nameWithoutExtension}-icon.ico" @@ -62,6 +89,7 @@ class AdapterFiles(private val fileList: List, private val context: Co inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), View.OnClickListener, View.OnLongClickListener { val fileName: TextView = itemView.findViewById(R.id.title_preferences_model) + val fileDescription: TextView = itemView.findViewById(R.id.description_preferences_model) val icon: ImageView = itemView.findViewById(R.id.set_img) init { @@ -109,4 +137,19 @@ class AdapterFiles(private val fileList: List, private val context: Co } class FileList(var file: File) + + companion object { + private const val GIGABYTE = 1024 * 1024 * 1024 + private const val MEGABYTE = 1024 * 1024 + private const val KILOBYTE = 1024 + + private fun formatSize(value: Double): String { + return when { + value < KILOBYTE -> "${round(value * 100) / 100}B" + value < MEGABYTE -> "${round(value / KILOBYTE * 100) / 100}KB" + value < GIGABYTE -> "${round(value / MEGABYTE * 100) / 100}MB" + else -> "${round(value / GIGABYTE * 100) / 100}GB" + } + } + } } \ No newline at end of file diff --git a/app/src/main/res/layout/activity_emulation.xml b/app/src/main/res/layout/activity_emulation.xml index 0c6a0ee..4fcc8ba 100644 --- a/app/src/main/res/layout/activity_emulation.xml +++ b/app/src/main/res/layout/activity_emulation.xml @@ -43,7 +43,6 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="start" - android:background="@color/darker_gray" app:headerLayout="@layout/nav_header" app:menu="@menu/emulation_drawer"> @@ -53,7 +52,6 @@ android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_gravity="end" - android:background="@color/darker_gray" app:headerLayout="@layout/nav_logs_header"> diff --git a/app/src/main/res/layout/activity_virtual_controller_mapper.xml b/app/src/main/res/layout/activity_virtual_controller_mapper.xml index 768b18b..ecfdb22 100644 --- a/app/src/main/res/layout/activity_virtual_controller_mapper.xml +++ b/app/src/main/res/layout/activity_virtual_controller_mapper.xml @@ -9,6 +9,7 @@ android:gravity="bottom" android:orientation="vertical" android:theme="@style/Theme.MiceWine" + android:background="@color/darker_gray" tools:context=".activities.VirtualControllerOverlayMapper"> diff --git a/app/src/main/res/layout/adapter_files_item.xml b/app/src/main/res/layout/adapter_files_item.xml index b9d77fd..4c119c3 100644 --- a/app/src/main/res/layout/adapter_files_item.xml +++ b/app/src/main/res/layout/adapter_files_item.xml @@ -20,12 +20,12 @@ android:layout_height="wrap_content" android:gravity="center_horizontal" android:orientation="horizontal" - android:padding="18dp"> + android:padding="14dp"> + tools:ignore="HardcodedText"> + + + + diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index b20e51b..01711ae 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -121,4 +121,7 @@ Invalid Architecture Rat File. Falha ao ler arquivo .lnk Salvar atalho .lnk + item + itens + Vazio \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e1f3c81..92270a4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -140,4 +140,7 @@ Invalid Architecture Rat File. Failed to read .lnk file Create .lnk file + item + items + Empty