From f039106194c9006fb095be5290699346bf5a5239 Mon Sep 17 00:00:00 2001 From: Jakob Nixdorf Date: Mon, 26 Feb 2018 12:54:34 +0100 Subject: [PATCH] Add background frame for the thumbnails --- .../andotp/View/EntriesCardAdapter.java | 6 + .../flocke/andotp/View/EntryViewHolder.java | 5 +- .../View/ThumbnailSelectionAdapter.java | 16 -- app/src/main/res/layout/component_card.xml | 234 ++++++++++-------- app/src/main/res/values/dimens.xml | 3 +- app/src/main/res/values/styles.xml | 1 - 6 files changed, 138 insertions(+), 127 deletions(-) diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java index 1ac6c244..f1f71d69 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/EntriesCardAdapter.java @@ -52,6 +52,7 @@ import org.shadowice.flocke.andotp.Utilities.Constants; import org.shadowice.flocke.andotp.Utilities.DatabaseHelper; import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; +import org.shadowice.flocke.andotp.Utilities.Tools; import org.shadowice.flocke.andotp.View.ItemTouchHelper.ItemTouchHelperAdapter; import java.text.Collator; @@ -377,8 +378,13 @@ public class EntriesCardAdapter extends RecyclerView.Adapter } }); + int gridPadding = context.getResources().getDimensionPixelSize(R.dimen.activity_margin_small); + int gridBackground = Tools.getThemeColor(context, R.attr.thumbnailBackground); + GridView grid = new GridView(context); grid.setAdapter(thumbnailAdapter); + grid.setBackgroundColor(gridBackground); + grid.setPadding(gridPadding, gridPadding, gridPadding, gridPadding); grid.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); int thumbnailSize = settings.getThumbnailSize(); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java b/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java index e054b399..e83f94f6 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/EntryViewHolder.java @@ -28,6 +28,7 @@ import android.support.v7.widget.CardView; import android.support.v7.widget.RecyclerView; import android.text.TextUtils; import android.view.View; +import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; @@ -51,6 +52,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder private LinearLayout valueLayout; private LinearLayout coverLayout; private LinearLayout customPeriodLayout; + private FrameLayout thumbnailFrame; private ImageView visibleImg; private ImageView thumbnailImg; private TextView value; @@ -68,6 +70,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder value = v.findViewById(R.id.valueText); valueLayout = v.findViewById(R.id.valueLayout); visibleImg = v.findViewById(R.id.valueImg); + thumbnailFrame = v.findViewById(R.id.thumbnailFrame); thumbnailImg = v.findViewById(R.id.thumbnailImg); coverLayout = v.findViewById(R.id.coverLayout); label = v.findViewById(R.id.textViewLabel); @@ -131,7 +134,7 @@ public class EntryViewHolder extends RecyclerView.ViewHolder this.tags.setVisibility(View.GONE); } - thumbnailImg.setVisibility(settings.getThumbnailVisible() ? View.VISIBLE : View.GONE); + thumbnailFrame.setVisibility(settings.getThumbnailVisible() ? View.VISIBLE : View.GONE); int thumbnailSize = settings.getThumbnailSize(); if(settings.getThumbnailVisible()) { diff --git a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java index 781295e9..f9f9af15 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/View/ThumbnailSelectionAdapter.java @@ -1,17 +1,13 @@ package org.shadowice.flocke.andotp.View; import android.content.Context; -import android.content.res.Resources; -import android.support.annotation.ColorInt; import android.support.annotation.NonNull; -import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.GridView; import android.widget.ImageView; -import org.shadowice.flocke.andotp.R; import org.shadowice.flocke.andotp.Utilities.EntryThumbnail; import org.shadowice.flocke.andotp.Utilities.Settings; @@ -80,18 +76,6 @@ public class ThumbnailSelectionAdapter extends BaseAdapter { EntryThumbnail.EntryThumbnails thumb = (EntryThumbnail.EntryThumbnails)getItem(i); imageView.setImageBitmap(EntryThumbnail.getThumbnailGraphic(context, label, thumbnailSize, thumb)); - - try { - TypedValue typedValue = new TypedValue(); - Resources.Theme theme = context.getTheme(); - theme.resolveAttribute(R.attr.thumbnailBackground, typedValue, true); - @ColorInt int color = typedValue.data; - - imageView.setBackgroundColor(color); - }catch (Exception e) { - e.printStackTrace(); - imageView.setBackgroundColor(context.getResources().getColor(android.R.color.white)); - } return imageView; } } diff --git a/app/src/main/res/layout/component_card.xml b/app/src/main/res/layout/component_card.xml index 5062149d..7d92262b 100644 --- a/app/src/main/res/layout/component_card.xml +++ b/app/src/main/res/layout/component_card.xml @@ -10,133 +10,151 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" - android:gravity="center_vertical" - android:baselineAligned="false" > + android:baselineAligned="false"> - + - + - - - - - - - - - - - - - - - - - - - - - - - - + + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:padding="@dimen/activity_margin" + android:gravity="center_vertical" + android:baselineAligned="false" > + android:layout_weight="1"> - + android:layout_height="wrap_content" > + + + + + + + + + + + + + + + + + + android:maxLines="1" + android:ellipsize="end" + android:textSize="18sp" /> + + + - + android:layout_height="wrap_content"> + + + + + + + + + + + + - diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index ccb74986..945247ae 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -8,7 +8,8 @@ 16dp - 0dp + 2dp + 14dp 46dp diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 5fe89f5b..7eec6bea 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -33,7 +33,6 @@