Bug Fixes, Added Empty item message.

This commit is contained in:
Binondi
2025-04-14 12:06:56 +05:30
parent 8610ad9a03
commit 4fd8832d90
11 changed files with 76 additions and 30 deletions

View File

@@ -7,6 +7,7 @@ import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import devs.org.calculator.R
import devs.org.calculator.callbacks.FileProcessCallback import devs.org.calculator.callbacks.FileProcessCallback
import devs.org.calculator.utils.FileManager import devs.org.calculator.utils.FileManager
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -43,7 +44,7 @@ class AudioGalleryActivity : BaseGalleryActivity(), FileProcessCallback {
).processMultipleFiles(uriList, fileType, this@AudioGalleryActivity) ).processMultipleFiles(uriList, fileType, this@AudioGalleryActivity)
} }
} else { } else {
Toast.makeText(this, "No files selected", Toast.LENGTH_SHORT).show() Toast.makeText(this, getString(R.string.no_files_selected), Toast.LENGTH_SHORT).show()
} }
} }
} }
@@ -52,7 +53,7 @@ class AudioGalleryActivity : BaseGalleryActivity(), FileProcessCallback {
override fun onFilesProcessedSuccessfully(copiedFiles: List<File>) { override fun onFilesProcessedSuccessfully(copiedFiles: List<File>) {
Toast.makeText( Toast.makeText(
this@AudioGalleryActivity, this@AudioGalleryActivity,
"${copiedFiles.size} Audios hidden successfully", "${copiedFiles.size} ${getString(R.string.audio_hidded_successfully)} ",
Toast.LENGTH_SHORT Toast.LENGTH_SHORT
).show() ).show()
loadFiles() loadFiles()

View File

@@ -1,6 +1,7 @@
package devs.org.calculator.activities package devs.org.calculator.activities
import android.Manifest import android.Manifest
import android.annotation.SuppressLint
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.net.Uri import android.net.Uri
@@ -8,6 +9,7 @@ import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Environment import android.os.Environment
import android.provider.Settings import android.provider.Settings
import android.view.View
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.IntentSenderRequest import androidx.activity.result.IntentSenderRequest
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
@@ -39,6 +41,7 @@ abstract class BaseGalleryActivity : AppCompatActivity() {
abstract val fileType: FileManager.FileType abstract val fileType: FileManager.FileType
@SuppressLint("SetTextI18n")
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setupIntentSenderLauncher() setupIntentSenderLauncher()
@@ -47,18 +50,27 @@ abstract class BaseGalleryActivity : AppCompatActivity() {
fileManager = FileManager(this, this) fileManager = FileManager(this, this)
binding.fabAdd.text = when(fileType){ when(fileType){
FileManager.FileType.IMAGE -> { FileManager.FileType.IMAGE -> {
getString(R.string.add_image) val image = getString(R.string.add_image)
binding.fabAdd.text = image
binding.noItemsTxt.text = "${getString(R.string.no_items_available_add_one_by_clicking_on_the_plus_button)} '$image' button"
} }
FileManager.FileType.AUDIO -> { FileManager.FileType.AUDIO -> {
getString(R.string.add_audio) val text = getString(R.string.add_audio)
binding.fabAdd.text = text
binding.noItemsTxt.text = "${getString(R.string.no_items_available_add_one_by_clicking_on_the_plus_button)} '$text' button"
} }
FileManager.FileType.VIDEO -> { FileManager.FileType.VIDEO -> {
getString(R.string.add_video) val text = getString(R.string.add_video)
binding.fabAdd.text = text
binding.noItemsTxt.text = "${getString(R.string.no_items_available_add_one_by_clicking_on_the_plus_button)} '$text' button"
} }
FileManager.FileType.DOCUMENT -> { FileManager.FileType.DOCUMENT -> {
getString(R.string.add_files) val text = getString(R.string.add_files)
binding.fabAdd.text = text
binding.noItemsTxt.text = "${getString(R.string.no_items_available_add_one_by_clicking_on_the_plus_button)} '$text' button"
} }
} }
binding.recyclerView.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY -> binding.recyclerView.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
@@ -116,6 +128,15 @@ abstract class BaseGalleryActivity : AppCompatActivity() {
protected open fun loadFiles() { protected open fun loadFiles() {
files = fileManager.getFilesInHiddenDir(fileType) files = fileManager.getFilesInHiddenDir(fileType)
adapter.submitList(files) adapter.submitList(files)
if (files.isEmpty()){
binding.recyclerView.visibility = View.GONE
binding.loading.visibility = View.GONE
binding.noItems.visibility = View.VISIBLE
}else{
binding.recyclerView.visibility = View.VISIBLE
binding.loading.visibility = View.GONE
binding.noItems.visibility = View.GONE
}
} }
override fun onResume() { override fun onResume() {

View File

@@ -47,8 +47,8 @@ class DocumentsActivity : BaseGalleryActivity(), FileProcessCallback {
} }
override fun onFilesProcessedSuccessfully(copiedFiles: List<File>) { override fun onFilesProcessedSuccessfully(copiedFiles: List<File>) {
Toast.makeText(this@DocumentsActivity,copiedFiles.size.toString() + Toast.makeText(this@DocumentsActivity,"${copiedFiles.size} ${getString(R.string.documents_hidden_successfully )}"
getString(R.string.documents_hidden_successfully ), Toast.LENGTH_SHORT).show() , Toast.LENGTH_SHORT).show()
loadFiles() loadFiles()
} }

View File

@@ -66,8 +66,7 @@ class ImageGalleryActivity : BaseGalleryActivity(), FileProcessCallback {
} }
override fun onFilesProcessedSuccessfully(copiedFiles: List<File>) { override fun onFilesProcessedSuccessfully(copiedFiles: List<File>) {
Toast.makeText(this@ImageGalleryActivity, copiedFiles.size.toString() + Toast.makeText(this@ImageGalleryActivity, "${copiedFiles.size} ${getString(R.string.images_hidden_successfully)}", Toast.LENGTH_SHORT).show()
getString(R.string.images_hidden_successfully), Toast.LENGTH_SHORT).show()
loadFiles() loadFiles()
} }

View File

@@ -49,8 +49,8 @@ class VideoGalleryActivity : BaseGalleryActivity(), FileProcessCallback {
} }
override fun onFilesProcessedSuccessfully(copiedFiles: List<File>) { override fun onFilesProcessedSuccessfully(copiedFiles: List<File>) {
Toast.makeText(this@VideoGalleryActivity, copiedFiles.size.toString() + Toast.makeText(this@VideoGalleryActivity, "${copiedFiles.size} ${getString(R.string.videos_hidden_successfully)}"
getString(R.string.videos_hidden_successfully), Toast.LENGTH_SHORT).show() , Toast.LENGTH_SHORT).show()
loadFiles() loadFiles()
} }

View File

@@ -60,7 +60,7 @@ class FileManager(private val context: Context, private val lifecycleOwner: Life
} }
} }
fun copyFileToHiddenDir(uri: Uri, type: FileType): File? { private fun copyFileToHiddenDir(uri: Uri, type: FileType): File? {
return try { return try {
val contentResolver = context.contentResolver val contentResolver = context.contentResolver

View File

@@ -8,20 +8,41 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView" android:id="@+id/recyclerView"
android:visibility="gone"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="8dp" /> android:padding="8dp" />
<!-- <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton--> <LinearLayout
<!-- android:id="@+id/fabAdd"--> android:id="@+id/loading"
<!-- android:layout_width="wrap_content"--> android:layout_width="match_parent"
<!-- android:layout_height="wrap_content"--> android:layout_height="match_parent"
<!-- android:layout_gravity="bottom|end"--> android:layout_gravity="center"
<!-- android:layout_margin="16dp"--> android:visibility="visible"
<!-- android:contentDescription="Compose"--> android:gravity="center"
<!-- android:icon="@drawable/plus"--> android:orientation="vertical">
<!-- android:text="Add File"--> <ProgressBar
<!-- app:elevation="6dp"/>--> android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:id="@+id/noItems"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:visibility="gone"
android:orientation="vertical">
<TextView
android:id="@+id/noItemsTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="16sp"
android:gravity="center"
android:padding="25dp"
android:text="@string/no_items_available_add_one_by_clicking_on_the_plus_button"/>
</LinearLayout>
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton <com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
android:id="@+id/fabAdd" android:id="@+id/fabAdd"

View File

@@ -11,6 +11,8 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:padding="8dp" /> android:padding="8dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton <com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fabAdd" android:id="@+id/fabAdd"
android:layout_width="60dp" android:layout_width="60dp"

View File

@@ -7,9 +7,9 @@
<string name="add_files">Add Files</string> <string name="add_files">Add Files</string>
<string name="failed_to_hide_documents">Failed to hide Documents</string> <string name="failed_to_hide_documents">Failed to hide Documents</string>
<string name="no_files_selected">No files selected</string> <string name="no_files_selected">No files selected</string>
<string name="documents_hidden_successfully">%1$s Documents hidden successfully</string> <string name="documents_hidden_successfully"> Documents hidden successfully</string>
<string name="failed_to_hide_unhide_photo">Failed to hide/unhide photo</string> <string name="failed_to_hide_unhide_photo">Failed to hide/unhide photo</string>
<string name="images_hidden_successfully">%1$s Images hidden successfully</string> <string name="images_hidden_successfully"> Images hidden successfully</string>
<string name="failed_to_hide_images">Failed to hide images</string> <string name="failed_to_hide_images">Failed to hide images</string>
<string name="storage_permissions_granted">Storage permissions granted</string> <string name="storage_permissions_granted">Storage permissions granted</string>
<string name="storage_permissions_denied">Storage permissions denied</string> <string name="storage_permissions_denied">Storage permissions denied</string>
@@ -41,7 +41,7 @@
<string name="answer_cannot_be_empty">Answer cannot be empty!</string> <string name="answer_cannot_be_empty">Answer cannot be empty!</string>
<string name="password_successfully_reset">Password successfully reset.</string> <string name="password_successfully_reset">Password successfully reset.</string>
<string name="invalid_answer">Invalid answer!</string> <string name="invalid_answer">Invalid answer!</string>
<string name="videos_hidden_successfully">%1$s Videos hidden successfully</string> <string name="videos_hidden_successfully"> Videos hidden successfully</string>
<string name="failed_to_hide_videos">Failed to hide videos</string> <string name="failed_to_hide_videos">Failed to hide videos</string>
<string name="image">IMAGE</string> <string name="image">IMAGE</string>
<string name="video">VIDEO</string> <string name="video">VIDEO</string>
@@ -50,5 +50,7 @@
<string name="no_audio_player_found">No audio player found!</string> <string name="no_audio_player_found">No audio player found!</string>
<string name="no_suitable_app_found_to_open_this_document">No suitable app found to open this document!</string> <string name="no_suitable_app_found_to_open_this_document">No suitable app found to open this document!</string>
<string name="unknown_file">Unknown File</string> <string name="unknown_file">Unknown File</string>
<string name="details">%1$s DETAILS</string> <string name="details"> DETAILS</string>
<string name="audio_hidded_successfully">Audios hidden successfully</string>
<string name="no_items_available_add_one_by_clicking_on_the_plus_button">No Items Available, Add one by clicking on the</string>
</resources> </resources>

View File

@@ -1,5 +1,5 @@
[versions] [versions]
agp = "8.7.3" agp = "8.9.1"
documentfile = "1.0.1" documentfile = "1.0.1"
exp4j = "0.4.8" exp4j = "0.4.8"
glide = "4.16.0" glide = "4.16.0"

View File

@@ -1,6 +1,6 @@
#Sun Nov 03 19:53:13 IST 2024 #Sun Nov 03 19:53:13 IST 2024
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists