mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Add big image file error
This commit is contained in:
@@ -27,7 +27,9 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.fragment.app.commit
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.kunzisoft.keepass.R
|
||||
import com.kunzisoft.keepass.activities.fragments.IconPickerFragment
|
||||
import com.kunzisoft.keepass.activities.helpers.SelectFileHelper
|
||||
@@ -37,6 +39,8 @@ import com.kunzisoft.keepass.database.element.Database
|
||||
import com.kunzisoft.keepass.database.element.icon.IconImage
|
||||
import com.kunzisoft.keepass.settings.PreferencesUtil
|
||||
import com.kunzisoft.keepass.utils.UriUtil
|
||||
import com.kunzisoft.keepass.view.asError
|
||||
import com.kunzisoft.keepass.view.showActionErrorIfNeeded
|
||||
import com.kunzisoft.keepass.view.updateLockPaddingLeft
|
||||
import com.kunzisoft.keepass.viewmodels.IconPickerViewModel
|
||||
|
||||
@@ -44,6 +48,7 @@ import com.kunzisoft.keepass.viewmodels.IconPickerViewModel
|
||||
class IconPickerActivity : LockingActivity() {
|
||||
|
||||
private lateinit var toolbar: Toolbar
|
||||
private lateinit var coordinatorLayout: CoordinatorLayout
|
||||
private lateinit var uploadButton: View
|
||||
private var lockView: View? = null
|
||||
|
||||
@@ -65,6 +70,8 @@ class IconPickerActivity : LockingActivity() {
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
supportActionBar?.setDisplayShowTitleEnabled(false)
|
||||
|
||||
coordinatorLayout = findViewById(R.id.icon_picker_coordinator)
|
||||
|
||||
uploadButton = findViewById(R.id.icon_picker_upload)
|
||||
uploadButton.setOnClickListener {
|
||||
mSelectFileHelper?.selectFileOnClickViewListener?.onClick(it)
|
||||
@@ -142,7 +149,7 @@ class IconPickerActivity : LockingActivity() {
|
||||
uri?.let { iconToUploadUri ->
|
||||
UriUtil.getFileData(this, iconToUploadUri)?.also { documentFile ->
|
||||
if (documentFile.length() > MAX_ICON_SIZE) {
|
||||
// TODO Error Icon size too big
|
||||
Snackbar.make(coordinatorLayout, R.string.error_image_to_big, Snackbar.LENGTH_LONG).asError().show()
|
||||
} else {
|
||||
mDatabase?.let { database ->
|
||||
iconPickerViewModel.addCustomIcon(database,
|
||||
|
||||
@@ -66,8 +66,10 @@ class IconsManager {
|
||||
fun getCustomIconList(): List<IconImage> {
|
||||
val list = ArrayList<IconImage>()
|
||||
customCache.doForEachBinary { key, binary ->
|
||||
if (binary.length > 0) {
|
||||
list.add(IconImage(IconImageCustom(key, binary)))
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,17 @@
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/icon_picker_fragment"
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/icon_picker_coordinator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/toolbar" />
|
||||
app:layout_constraintBottom_toTopOf="@+id/toolbar">
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/icon_picker_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<com.kunzisoft.keepass.view.ToolbarAction
|
||||
android:id="@+id/toolbar"
|
||||
|
||||
@@ -137,6 +137,7 @@
|
||||
<string name="error_field_name_already_exists">The field name already exists.</string>
|
||||
<string name="error_database_uri_null">Database URI cannot be retrieved.</string>
|
||||
<string name="error_rebuild_list">Unable to properly rebuild the list.</string>
|
||||
<string name="error_image_to_big">The image you are trying to upload is too big.</string>
|
||||
<string name="field_name">Field name</string>
|
||||
<string name="field_value">Field value</string>
|
||||
<string name="file_not_found_content">Could not find file. Try reopening it from your file browser.</string>
|
||||
|
||||
Reference in New Issue
Block a user