From 6eda1c5537ab8cf86ea2b8a51ce322a2f5fe52ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20N=C3=BCsse?= Date: Thu, 16 May 2024 21:00:18 +0200 Subject: [PATCH] update faq --- .../java/de/felixnuesse/disky/FAQActivity.kt | 2 +- .../disky/ui/RecyclerViewAdapter.kt | 26 +++++-- .../disky/ui/dialogs/HelpDialog.kt | 21 ++++++ app/src/main/res/drawable/icon_help.xml | 19 +++++ app/src/main/res/layout/activity_faq.xml | 73 +++++++++++++++++++ .../main/res/layout/activity_faqactivity.xml | 34 --------- app/src/main/res/menu/context_os_menu.xml | 10 +++ app/src/main/res/values-de/strings.xml | 10 +++ app/src/main/res/values/strings.xml | 7 ++ 9 files changed, 161 insertions(+), 41 deletions(-) create mode 100644 app/src/main/java/de/felixnuesse/disky/ui/dialogs/HelpDialog.kt create mode 100644 app/src/main/res/drawable/icon_help.xml create mode 100644 app/src/main/res/layout/activity_faq.xml delete mode 100644 app/src/main/res/layout/activity_faqactivity.xml create mode 100644 app/src/main/res/menu/context_os_menu.xml diff --git a/app/src/main/java/de/felixnuesse/disky/FAQActivity.kt b/app/src/main/java/de/felixnuesse/disky/FAQActivity.kt index 7cd9823..87ac2cb 100644 --- a/app/src/main/java/de/felixnuesse/disky/FAQActivity.kt +++ b/app/src/main/java/de/felixnuesse/disky/FAQActivity.kt @@ -12,7 +12,7 @@ class FAQActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() - setContentView(R.layout.activity_faqactivity) + setContentView(R.layout.activity_faq) setSupportActionBar(findViewById(R.id.toolbar)) ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) diff --git a/app/src/main/java/de/felixnuesse/disky/ui/RecyclerViewAdapter.kt b/app/src/main/java/de/felixnuesse/disky/ui/RecyclerViewAdapter.kt index 001e6a2..4bc5807 100644 --- a/app/src/main/java/de/felixnuesse/disky/ui/RecyclerViewAdapter.kt +++ b/app/src/main/java/de/felixnuesse/disky/ui/RecyclerViewAdapter.kt @@ -5,6 +5,7 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.provider.DocumentsContract +import android.util.Log import android.view.LayoutInflater import android.view.MenuItem import android.view.ViewGroup @@ -23,6 +24,7 @@ import de.felixnuesse.disky.model.StorageLeaf import de.felixnuesse.disky.model.StoragePrototype import de.felixnuesse.disky.model.StorageType import de.felixnuesse.disky.ui.dialogs.DeleteDialog +import de.felixnuesse.disky.ui.dialogs.HelpDialog import java.io.File @@ -75,8 +77,12 @@ class RecyclerViewAdapter(private var mContext: Context, private val folders: Li binding.title.text = name binding.size.text = readableFileSize(getCalculatedSize()) + val leaf = this when(StorageType.fromInt(holder.itemViewType)) { - StorageType.OS, + StorageType.OS -> { + setMenu(R.menu.context_os_menu, leaf) + setImage(R.drawable.icon_android) + } StorageType.APP_APK, StorageType.APP -> { setImage(R.drawable.icon_android) @@ -91,7 +97,7 @@ class RecyclerViewAdapter(private var mContext: Context, private val folders: Li setImage(R.drawable.icon_account) } StorageType.FILE -> { - leafItem = folders[position] as StorageLeaf + leafItem = leaf enableDeletion() } else -> {} @@ -101,7 +107,6 @@ class RecyclerViewAdapter(private var mContext: Context, private val folders: Li } } - override fun getItemViewType(position: Int): Int { return folders[position].storageType.ordinal } @@ -170,15 +175,20 @@ class RecyclerViewAdapter(private var mContext: Context, private val folders: Li private var popupMenuEnableDeletion = false init { + setMenu(R.menu.context_file_menu, null) + } + + fun setMenu(menu: Int, leaf: StorageLeaf?) { + leaf.let{leafItem = it} binding.root.setOnLongClickListener { if(leafItem == null) { return@setOnLongClickListener true } val context = binding.root.context - var popup = PopupMenu(context, it) + val popup = PopupMenu(context, it) popup.setOnMenuItemClickListener(this) - popup.menuInflater.inflate(R.menu.context_file_menu, popup.menu) - popup.menu.findItem(R.id.action_file_delete).setVisible(popupMenuEnableDeletion) + popup.menuInflater.inflate(menu, popup.menu) + popup.menu.findItem(R.id.action_file_delete)?.setVisible(popupMenuEnableDeletion) popup.setForceShowIcon(true) popup.show() true @@ -215,6 +225,10 @@ class RecyclerViewAdapter(private var mContext: Context, private val folders: Li DeleteDialog(mContext, File(leafItem!!.getParentPath())).askDelete() true } + R.id.action_os_help -> { + HelpDialog(mContext).help(R.string.help_android_os, R.string.help_android_os_description) + true + } else -> { false } diff --git a/app/src/main/java/de/felixnuesse/disky/ui/dialogs/HelpDialog.kt b/app/src/main/java/de/felixnuesse/disky/ui/dialogs/HelpDialog.kt new file mode 100644 index 0000000..17f2df6 --- /dev/null +++ b/app/src/main/java/de/felixnuesse/disky/ui/dialogs/HelpDialog.kt @@ -0,0 +1,21 @@ +package de.felixnuesse.disky.ui.dialogs + +import android.content.Context +import com.google.android.material.dialog.MaterialAlertDialogBuilder +import de.felixnuesse.disky.R + +class HelpDialog(private var mContext: Context) { + + fun help(title: Int, message: Int) { + MaterialAlertDialogBuilder(mContext) + .setTitle(mContext.getString(title)) + .setMessage(mContext.getString(message)) + .setPositiveButton( + R.string.ok + ) { dialog, _ -> + dialog.dismiss(); + } + .setIcon(R.drawable.icon_help) + .show() + } +} \ No newline at end of file diff --git a/app/src/main/res/drawable/icon_help.xml b/app/src/main/res/drawable/icon_help.xml new file mode 100644 index 0000000..158d86c --- /dev/null +++ b/app/src/main/res/drawable/icon_help.xml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/app/src/main/res/layout/activity_faq.xml b/app/src/main/res/layout/activity_faq.xml new file mode 100644 index 0000000..6b553f1 --- /dev/null +++ b/app/src/main/res/layout/activity_faq.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_faqactivity.xml b/app/src/main/res/layout/activity_faqactivity.xml deleted file mode 100644 index 4538544..0000000 --- a/app/src/main/res/layout/activity_faqactivity.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/menu/context_os_menu.xml b/app/src/main/res/menu/context_os_menu.xml new file mode 100644 index 0000000..3556d75 --- /dev/null +++ b/app/src/main/res/menu/context_os_menu.xml @@ -0,0 +1,10 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index e213982..b6c7385 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -54,4 +54,14 @@ Wenn du Fragen hast, werden sie hier vielleicht beantwortet. Alphabet Größe + ok + Android OS + Ist diese App genau? + Was ist \"Android OS\"? + + Dies zeigt die Differenz zwischen dem gesamten Speicher, wieviel von deinen Dateien und dem freien Speicher an.\n\nDies enthält nicht nur das Android System, sondern auch temoräre Dateien und Apps und Dateien von anderen Profilen. Das bedeutet das dieser Wert ungenau ist. + Nein. Wir können zwar Apps und Dateien korrekt berechnen, aber nicht die des Android Systems. Das bedeutet das diese Werte sich vermutlich jedesmal ändern wenn du einen neuen Scan startest. Das ist eine Begrenzung von Android. + Das ist all der Speicher den wir nicht direkt scannen können. Das beinhaltet andere Profile, deren Dateien und Apps, sowie temporäre Systemdateien. Der berechnete Wert ist deshalb nur eine Schätzung. + + \ 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 8f9e5b3..062e58b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -59,4 +59,11 @@ If you have questions, they might be answered here Alphabet Size + ok + Android OS + This collects the difference between the total available diskspace, how much is used by your files and the known free storage.\n\nThis not only includes the android system itself, but also other profiles apps and files, and temporary system files. This means that this value is inaccurate. + Is this app accurate? + No. We can calculate your files and apps properly, but not your android system. That means you will likely get different results for the system each time you refresh the scan. This is a limitation of android itself. + What is \"Android OS\"? + This is all the used space that we can\'t access. That includes other profiles and their apps and the system itself. The calculated value is therefore only an estimation of its true size. \ No newline at end of file