First implementation

This commit is contained in:
J-Jamet committed 2020-12-02 09:28:44 +01:00
1 parent 3d12a0e8e9
commit 58d10672ea
8 files changed
+1215 -88

No files matched your search

+3
View File
@@ -124,6 +124,9 @@
<activity
android:name="com.kunzisoft.keepass.activities.EntryActivity"
android:configChanges="keyboardHidden" />
<activity
android:name="com.kunzisoft.keepass.activities.ImageViewerActivity"
android:configChanges="keyboardHidden" />
<activity
android:name="com.kunzisoft.keepass.activities.EntryEditActivity"
android:windowSoftInputMode="adjustPan|stateAlwaysHidden" />
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,39 @@
package com.kunzisoft.keepass.activities
import android.os.Bundle
import android.widget.ImageView
import com.igreenwood.loupe.Loupe
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.activities.lock.LockingActivity
import kotlinx.android.synthetic.main.activity_image_viewer.*
class ImageViewerActivity : LockingActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_image_viewer)
Loupe.create(image_viewer_image, image_viewer_container) {
onViewTranslateListener = object : Loupe.OnViewTranslateListener {
override fun onStart(view: ImageView) {
// called when the view starts moving
}
override fun onViewTranslate(view: ImageView, amount: Float) {
// called whenever the view position changed
}
override fun onRestore(view: ImageView) {
// called when the view drag gesture ended
}
override fun onDismiss(view: ImageView) {
// called when the view drag gesture ended
finish()
}
}
}
}
}
@@ -20,6 +20,7 @@
package com.kunzisoft.keepass.adapters
import android.content.Context
import android.content.Intent
import android.content.res.TypedArray
import android.graphics.Color
import android.text.format.Formatter
@@ -31,6 +32,7 @@ import android.widget.ProgressBar
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.kunzisoft.keepass.R
import com.kunzisoft.keepass.activities.ImageViewerActivity
import com.kunzisoft.keepass.database.element.database.CompressionAlgorithm
import com.kunzisoft.keepass.model.AttachmentState
import com.kunzisoft.keepass.model.EntryAttachmentState
@@ -62,6 +64,13 @@ class EntryAttachmentsItemsAdapter(context: Context)
val entryAttachmentState = itemsList[position]
holder.itemView.visibility = View.VISIBLE
holder.binaryFileThumbnail.apply {
setOnClickListener {
context.startActivity(Intent(context, ImageViewerActivity::class.java).apply {
})
}
}
holder.binaryFileBroken.apply {
setColorFilter(Color.RED)
visibility = if (entryAttachmentState.attachment.binaryAttachment.isCorrupted) {
@@ -136,6 +145,7 @@ class EntryAttachmentsItemsAdapter(context: Context)
class EntryBinariesViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
var binaryFileThumbnail: ImageView = itemView.findViewById(R.id.item_attachment_thumbnail)
var binaryFileBroken: ImageView = itemView.findViewById(R.id.item_attachment_broken)
var binaryFileTitle: TextView = itemView.findViewById(R.id.item_attachment_title)
var binaryFileSize: TextView = itemView.findViewById(R.id.item_attachment_size)
@@ -57,7 +57,7 @@ class NodeAdapter (private val context: Context)
private val mNodeSortedList: SortedList<Node>
private val mInflater: LayoutInflater = LayoutInflater.from(context)
private var mCalculateViewTypeTextSize = Array(2) { true} // number of view type
private var mCalculateViewTypeTextSize = Array(2) { true } // number of view type
private var mTextSizeUnit: Int = TypedValue.COMPLEX_UNIT_PX
private var mPrefSizeMultiplier: Float = 0F
private var mSubtextDefaultDimension: Float = 0F
Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/image_viewer_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/windowBackground">
<ImageView
android:id="@+id/image_viewer_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:contentDescription="@string/entry_attachments"
android:scaleType="fitCenter"
android:src="@drawable/keepassdx_logo"/>
</FrameLayout>
+112 -87
View File
@@ -17,111 +17,136 @@
You should have received a copy of the GNU General Public License
along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
-->
<androidx.constraintlayout.widget.ConstraintLayout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:targetApi="p"
android:id="@+id/item_attachment_container"
android:focusable="false"
android:orientation="horizontal"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/item_attachment_broken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:src="@drawable/ic_attach_file_broken_white_24dp"
android:contentDescription="@string/entry_attachments" />
android:layout_height="160dp">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/item_attachment_title"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@+id/item_attachment_broken"
app:layout_constraintEnd_toStartOf="@+id/item_attachment_size_container"
android:layout_width="0dp"
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/item_attachment_thumbnail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/KeepassDXStyle.TextAppearance.TextEntryItem"
tools:text="BinaryFile.attach" />
<LinearLayout
android:id="@+id/item_attachment_size_container"
android:layout_width="wrap_content"
android:layout_marginTop="16dp"
android:layout_above="@+id/constraintLayout"
android:scaleType="centerCrop"
android:src="@drawable/keepassdx_logo" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="end"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/item_attachment_action_container" >
android:layout_alignParentBottom="true">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/item_attachment_broken"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/entry_attachments"
android:src="@drawable/ic_attach_file_broken_white_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/item_attachment_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:firstBaselineToTopHeight="0dp"
android:includeFontPadding="false"
android:paddingStart="8dp"
android:paddingEnd="8dp"
tools:text="1.2 Mb" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/item_attachment_compression"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/KeepassDXStyle.TextAppearance.Tiny"
android:firstBaselineToTopHeight="0dp"
android:includeFontPadding="false"
android:paddingStart="8dp"
android:paddingEnd="8dp"
tools:text="GZip" />
</LinearLayout>
<FrameLayout
android:id="@+id/item_attachment_action_container"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/item_attachment_delete_button"
android:layout_width="wrap_content"
android:id="@+id/item_attachment_title"
style="@style/KeepassDXStyle.TextAppearance.TextEntryItem"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/item_attachment_size_container"
app:layout_constraintStart_toEndOf="@+id/item_attachment_broken"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_gravity="center"
android:contentDescription="@string/content_description_remove_field"
android:focusable="true"
android:src="@drawable/ic_content_delete_white_24dp"
style="@style/KeepassDXStyle.ImageButton.Simple" />
<FrameLayout
android:id="@+id/item_attachment_progress_container"
tools:text="BinaryFile.attach" />
<LinearLayout
android:id="@+id/item_attachment_size_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:layout_gravity="center">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/item_attachment_icon"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:gravity="end"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/item_attachment_action_container"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/item_attachment_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:firstBaselineToTopHeight="0dp"
android:includeFontPadding="false"
android:paddingStart="8dp"
android:paddingEnd="8dp"
tools:text="1.2 Mb" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/item_attachment_compression"
style="@style/KeepassDXStyle.TextAppearance.Tiny"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:firstBaselineToTopHeight="0dp"
android:includeFontPadding="false"
android:paddingStart="8dp"
android:paddingEnd="8dp"
tools:text="GZip" />
</LinearLayout>
<FrameLayout
android:id="@+id/item_attachment_action_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/item_attachment_delete_button"
style="@style/KeepassDXStyle.ImageButton.Simple"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/ic_file_stream_white_24dp"
android:contentDescription="@string/download"
style="@style/KeepassDXStyle.ImageButton.Simple" />
<ProgressBar
android:id="@+id/item_attachment_progress"
app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/content_description_remove_field"
android:focusable="true"
android:src="@drawable/ic_content_delete_white_24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<FrameLayout
android:id="@+id/item_attachment_progress_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
style="@style/KeepassDXStyle.ProgressBar.Circle"
android:layout_width="36dp"
android:layout_height="36dp"
android:max="100"
android:progress="60" />
android:focusable="false">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/item_attachment_icon"
style="@style/KeepassDXStyle.ImageButton.Simple"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@string/download"
android:src="@drawable/ic_file_stream_white_24dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ProgressBar
android:id="@+id/item_attachment_progress"
style="@style/KeepassDXStyle.ProgressBar.Circle"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center"
android:max="100"
android:progress="60"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</FrameLayout>
</FrameLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>