mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Spinner template selection as cardview and fix margin in kitakt
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
package com.kunzisoft.keepass.activities.fragments
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@@ -112,6 +113,12 @@ class EntryEditFragment : StylishFragment() {
|
||||
|
||||
entryTitleView = rootView.findViewById(R.id.entry_edit_title)
|
||||
templateContainerView = rootView.findViewById(R.id.template_fields_container)
|
||||
// To fix card view margin in KitKat-
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
val paddingVertical = resources.getDimensionPixelSize(R.dimen.card_view_margin_vertical)
|
||||
val paddingHorizontal = resources.getDimensionPixelSize(R.dimen.card_view_margin_horizontal)
|
||||
templateContainerView.setPadding(paddingHorizontal, paddingVertical, paddingHorizontal, paddingVertical)
|
||||
}
|
||||
customFieldsContainerView = rootView.findViewById(R.id.custom_fields_container)
|
||||
|
||||
attachmentsContainerView = rootView.findViewById(R.id.entry_attachments_container)
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import androidx.annotation.IdRes
|
||||
import androidx.cardview.widget.CardView
|
||||
import androidx.core.view.setPadding
|
||||
import com.kunzisoft.keepass.R
|
||||
|
||||
class SectionView @JvmOverloads constructor(context: Context,
|
||||
@@ -33,18 +34,17 @@ class SectionView @JvmOverloads constructor(context: Context,
|
||||
: CardView(context, attrs, defStyle) {
|
||||
|
||||
private var containerSectionView = LinearLayout(context).apply {
|
||||
val margin = resources.getDimension(R.dimen.card_view_padding).toInt()
|
||||
val padding = resources.getDimensionPixelSize(R.dimen.card_view_padding)
|
||||
layoutParams = LinearLayout.LayoutParams(
|
||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT).also {
|
||||
it.setMargins(margin, margin, margin, margin)
|
||||
}
|
||||
LinearLayout.LayoutParams.WRAP_CONTENT)
|
||||
setPadding(padding)
|
||||
orientation = LinearLayout.VERTICAL
|
||||
}
|
||||
|
||||
init {
|
||||
val marginHorizontal = resources.getDimension(R.dimen.card_view_margin_horizontal).toInt()
|
||||
val marginVertical = resources.getDimension(R.dimen.card_view_margin_vertical).toInt()
|
||||
val marginHorizontal = resources.getDimensionPixelSize(R.dimen.card_view_margin_horizontal)
|
||||
val marginVertical = resources.getDimensionPixelSize(R.dimen.card_view_margin_vertical)
|
||||
layoutParams = LayoutParams(
|
||||
LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.WRAP_CONTENT).also {
|
||||
|
||||
@@ -70,7 +70,7 @@
|
||||
app:layout_constraintWidth_percent="@dimen/content_percent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/entry_edit_template_selector" />
|
||||
app:layout_constraintTop_toBottomOf="@+id/entry_edit_template_selector"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
||||
|
||||
@@ -16,41 +16,48 @@
|
||||
* 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
|
||||
<FrameLayout
|
||||
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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="42dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/template_image"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginRight="24dp"
|
||||
android:contentDescription="@string/content_description_entry_icon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:tint="?attr/colorAccent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/template_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content">
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center|center_vertical"
|
||||
android:maxLines="2"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingRight="12dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/template_image" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
style="?attr/cardViewStyle">
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="42dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/template_image"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:contentDescription="@string/content_description_entry_icon"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:tint="?attr/colorAccent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/template_name"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center|center_vertical"
|
||||
android:maxLines="2"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingLeft="12dp"
|
||||
android:paddingEnd="12dp"
|
||||
android:paddingRight="12dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/template_image" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</FrameLayout>
|
||||
|
||||
Reference in New Issue
Block a user