Skip to content

Commit

Permalink
Merge pull request #161 from TeamAmaze/bugfix-356
Browse files Browse the repository at this point in the history
Fix divide by zero error in trash bin getCapacity
  • Loading branch information
VishalNehra committed Dec 31, 2023
2 parents f931843 + f25606b commit baa3eba
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Expand Up @@ -252,7 +252,7 @@ dependencies {
implementation 'org.zwobble.mammoth:mammoth:1.4.2'
implementation 'me.zhanghai.android.fastscroll:library:1.1.8'
implementation "ch.acra:acra-core:5.7.0"
implementation 'com.github.TeamAmaze:AmazeTrashBin:1.0.10'
implementation 'com.github.TeamAmaze:AmazeTrashBin:1.0.11'

// https://mvnrepository.com/artifact/com.drewnoakes/metadata-extractor
implementation group: 'com.drewnoakes', name: 'metadata-extractor', version: '2.16.0'
Expand Down
Expand Up @@ -272,7 +272,7 @@ class AnalysisPrefFragment : PreferenceFragmentCompat(), Preference.OnPreference
it?.toInt() ?: PreferencesConstants.DEFAULT_LARGE_SIZE_DIFF_APPS_DAYS
).apply()
},
max = PreferencesConstants.MAX_LARGE_SIZE_DIFF_APPS_DAYS.toLong()
upperBound = PreferencesConstants.MAX_LARGE_SIZE_DIFF_APPS_DAYS.toLong()
)
}
}
Expand Down
Expand Up @@ -82,7 +82,8 @@ class TrashBinPrefFragment : PreferenceFragmentCompat(), Preference.OnPreference
PreferencesConstants.KEY_TRASH_BIN_RETENTION_DAYS,
it?.toInt() ?: TrashBinConfig.RETENTION_DAYS_INFINITE
).apply()
}
},
lowerBound = 1
) {
prefs.edit().putInt(
PreferencesConstants.KEY_TRASH_BIN_RETENTION_DAYS,
Expand All @@ -91,10 +92,13 @@ class TrashBinPrefFragment : PreferenceFragmentCompat(), Preference.OnPreference
}
}
KEY_RETENTION_BYTES -> {
val bytes = prefs.getLong(
var bytes = prefs.getLong(
PreferencesConstants.KEY_TRASH_BIN_RETENTION_BYTES,
TrashBinConfig.RETENTION_BYTES_INFINITE
)
if (bytes != TrashBinConfig.RETENTION_BYTES_INFINITE) {
bytes = bytes.div(1024).div(1024)
}
Utils.buildDigitInputDialog(
requireContext(), getString(R.string.retention_bytes_title),
getString(R.string.retention_bytes_summary), bytes,
Expand All @@ -104,7 +108,8 @@ class TrashBinPrefFragment : PreferenceFragmentCompat(), Preference.OnPreference
PreferencesConstants.KEY_TRASH_BIN_RETENTION_BYTES,
bytesInput ?: TrashBinConfig.RETENTION_BYTES_INFINITE
).apply()
}
},
lowerBound = 1
) {
prefs.edit().putLong(
PreferencesConstants.KEY_TRASH_BIN_RETENTION_BYTES,
Expand All @@ -125,7 +130,8 @@ class TrashBinPrefFragment : PreferenceFragmentCompat(), Preference.OnPreference
PreferencesConstants.KEY_TRASH_BIN_RETENTION_NUM_OF_FILES,
it?.toInt() ?: TrashBinConfig.RETENTION_NUM_OF_FILES
).apply()
}
},
lowerBound = 1
) {
prefs.edit().putInt(
PreferencesConstants.KEY_TRASH_BIN_RETENTION_NUM_OF_FILES,
Expand All @@ -146,7 +152,8 @@ class TrashBinPrefFragment : PreferenceFragmentCompat(), Preference.OnPreference
PreferencesConstants.KEY_TRASH_BIN_CLEANUP_INTERVAL_HOURS,
it?.toInt() ?: TrashBinConfig.INTERVAL_CLEANUP_HOURS
).apply()
}
},
lowerBound = 1
) {
prefs.edit().putInt(
PreferencesConstants.KEY_TRASH_BIN_CLEANUP_INTERVAL_HOURS,
Expand Down
12 changes: 9 additions & 3 deletions app/src/main/java/com/amaze/fileutilities/utilis/Utils.kt
Expand Up @@ -1242,14 +1242,20 @@ class Utils {
summary: String,
days: Long,
callback: (Long?) -> Unit,
max: Long? = null,
lowerBound: Long? = null,
upperBound: Long? = null,
neutralCallback: (() -> Unit)? = null
) {
val inputEditTextViewPair = getEditTextViewForDialog(context, "$days")
inputEditTextViewPair.second.inputType = InputType.TYPE_CLASS_NUMBER
inputEditTextViewPair.second.setText("$days")
if (max != null) {
inputEditTextViewPair.second.filters = arrayOf(InputFilterMinMaxLong(1, max))
if (upperBound != null) {
inputEditTextViewPair.second.filters = arrayOf(InputFilterMinMaxLong(1, upperBound))
}
if (lowerBound != null) {
inputEditTextViewPair.second.filters = arrayOf(InputFilterMinMaxLong(lowerBound,
Integer.MAX_VALUE.toLong()
))
}

val dialogBuilder = AlertDialog.Builder(context, R.style.Custom_Dialog_Dark)
Expand Down

0 comments on commit baa3eba

Please sign in to comment.