Add a first "compact" card layout

Closes #189
This commit is contained in:
Jakob Nixdorf 2020-02-04 11:11:52 +01:00
parent 9f6ca63187
commit a42ed5afb0
No known key found for this signature in database
GPG key ID: BE99BF86574A7DBC
7 changed files with 247 additions and 2 deletions

View file

@ -9,7 +9,7 @@
* New feature: Turn tokens red if they are about to expire (Issue #311, PR #410 by @Ullas-Aithal) * New feature: Turn tokens red if they are about to expire (Issue #311, PR #410 by @Ullas-Aithal)
* New feature: Handle otpauth:// intents from other apps (Issue #324, PR #393 by @schwedenmut) * New feature: Handle otpauth:// intents from other apps (Issue #324, PR #393 by @schwedenmut)
* New feature: Create an encrypted backup every time the entries are changed (PR #397 and PR #421 by @RichyHBM) * New feature: Create an encrypted backup every time the entries are changed (PR #397 and PR #421 by @RichyHBM)
* New feature: Different layouts for the entry cards * New feature: Different layouts for the entry cards (compact, default and full)
* New feature: New thumbnail size "Tiny" * New feature: New thumbnail size "Tiny"
* New feature: Block accessibility services from seeing sensitive input fields via a new settings item * New feature: Block accessibility services from seeing sensitive input fields via a new settings item
* New feature: Import QR codes from image files (Issue #377, PR #425 by @Ullas-Aithal) * New feature: Import QR codes from image files (Issue #377, PR #425 by @Ullas-Aithal)

View file

@ -57,7 +57,7 @@ public class Constants {
} }
public enum CardLayouts { public enum CardLayouts {
DEFAULT, FULL COMPACT, DEFAULT, FULL
} }
public enum AutoBackup { public enum AutoBackup {

View file

@ -242,6 +242,8 @@ public class EntriesCardAdapter extends RecyclerView.Adapter<EntryViewHolder>
if (layout == Constants.CardLayouts.DEFAULT) { if (layout == Constants.CardLayouts.DEFAULT) {
cardLayout = R.layout.component_card_default; cardLayout = R.layout.component_card_default;
} else if (layout == Constants.CardLayouts.COMPACT) {
cardLayout = R.layout.component_card_compact;
} else if (layout == Constants.CardLayouts.FULL) { } else if (layout == Constants.CardLayouts.FULL) {
cardLayout = R.layout.component_card_full; cardLayout = R.layout.component_card_full;
} }

View file

@ -0,0 +1,240 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/card_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_margin_xxsmall"
android:layout_marginBottom="@dimen/activity_margin_xxsmall"
app:contentPadding="0dp"
style="?attr/cardStyle">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false">
<FrameLayout
android:id="@+id/thumbnailFrame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingEnd="@dimen/activity_margin"
android:paddingStart="@dimen/card_padding_without_corners"
android:background="?attr/thumbnailBackground">
<ImageView
android:id="@+id/thumbnailImg"
android:layout_width="@dimen/card_thumbnail_size"
android:layout_height="@dimen/card_thumbnail_size"
android:layout_gravity="center"
android:src="@mipmap/ic_launcher" />
</FrameLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="@dimen/activity_margin_xsmall"
android:paddingBottom="@dimen/activity_margin_xsmall"
android:paddingStart="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin_small"
android:gravity="center_vertical"
android:baselineAligned="false" >
<LinearLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/valueLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone">
<ImageView
android:id="@+id/valueImg"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/activity_margin_small"
app:srcCompat="@drawable/ic_visibility_visible"/>
<TextView
android:textDirection="ltr"
android:id="@+id/valueText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:textSize="24sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/coverLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/coverImg"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/activity_margin_small"
android:alpha="0.4"
app:srcCompat="@drawable/ic_visibility_invisible"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.4"
android:textColor="?android:attr/textColorSecondary"
android:textSize="24sp"
android:textStyle="bold"
android:text="@string/label_hidden" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewIssuer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:textSize="18sp"
android:text="Issuer"
android:textStyle="bold" />
<TextView
android:id="@+id/textViewSeparator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textSize="18sp"
android:text="@string/card_separator" />
<TextView
android:id="@+id/textViewLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="Label"
android:textSize="18sp" />
</LinearLayout>
<TextView
android:id="@+id/textViewTags"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="Tags"
android:textSize="13.5sp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/customPeriodLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:visibility="gone"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:srcCompat="@drawable/ic_alarm_gray" />
<TextView
android:id="@+id/customPeriod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="@+id/counterLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="@dimen/activity_horizontal_margin"
android:gravity="center"
android:visibility="visible"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="@string/label_counter_symbol" />
<TextView
android:id="@+id/counter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold" />
</LinearLayout>
<ImageButton
android:id="@+id/copyButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
app:srcCompat="@drawable/ic_content_copy_gray" />
<ImageButton
android:id="@+id/menuButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="@dimen/activity_margin_small"
android:background="?android:attr/selectableItemBackground"
app:srcCompat="@drawable/ic_more_vert_gray" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/cardProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:max="3000"
android:progress="1500"
app:mpb_progressStyle="horizontal"
app:mpb_useIntrinsicPadding="false"
app:mpb_showProgressBackground="false"
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding" />
</LinearLayout>
</androidx.cardview.widget.CardView>

View file

@ -1,5 +1,6 @@
<resources> <resources>
<!-- Default screen margins, per the Android Design guidelines. --> <!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_margin_xxsmall">1dp</dimen>
<dimen name="activity_margin_xsmall">4dp</dimen> <dimen name="activity_margin_xsmall">4dp</dimen>
<dimen name="activity_margin_small">8dp</dimen> <dimen name="activity_margin_small">8dp</dimen>
<dimen name="activity_margin">16dp</dimen> <dimen name="activity_margin">16dp</dimen>

View file

@ -103,6 +103,7 @@
</string-array> </string-array>
<string-array name="settings_values_card_layout" translatable="false"> <string-array name="settings_values_card_layout" translatable="false">
<item>compact</item>
<item>default</item> <item>default</item>
<item>full</item> <item>full</item>
</string-array> </string-array>

View file

@ -171,6 +171,7 @@
</string-array> </string-array>
<string-array name="settings_entries_card_layout"> <string-array name="settings_entries_card_layout">
<item>Compact</item>
<item>Default</item> <item>Default</item>
<item>Full</item> <item>Full</item>
</string-array> </string-array>