From 9f9c1d5762f8e5d2c8a4110d722ca38b993ca73d Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Wed, 11 Apr 2018 18:24:43 +0300 Subject: [PATCH] Add alternative wikivoyage article card design --- .../wikivoyage_article_card_alternative.xml | 159 ++++++++++++++++++ OsmAnd/res/values-large/sizes.xml | 1 + OsmAnd/res/values/sizes.xml | 1 + .../widgets/tools/CropRectTransformation.java | 30 ++++ .../explore/SavedArticlesRvAdapter.java | 9 +- 5 files changed, 198 insertions(+), 2 deletions(-) create mode 100644 OsmAnd/res/layout/wikivoyage_article_card_alternative.xml create mode 100644 OsmAnd/src/net/osmand/plus/widgets/tools/CropRectTransformation.java diff --git a/OsmAnd/res/layout/wikivoyage_article_card_alternative.xml b/OsmAnd/res/layout/wikivoyage_article_card_alternative.xml new file mode 100644 index 0000000000..cccd290ecb --- /dev/null +++ b/OsmAnd/res/layout/wikivoyage_article_card_alternative.xml @@ -0,0 +1,159 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd/res/values-large/sizes.xml b/OsmAnd/res/values-large/sizes.xml index 37fd92161b..837f7d4504 100644 --- a/OsmAnd/res/values-large/sizes.xml +++ b/OsmAnd/res/values-large/sizes.xml @@ -196,4 +196,5 @@ 54dp 120dp + 60dp \ No newline at end of file diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index 8479383619..680e1974bf 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -270,6 +270,7 @@ 36dp 80dp + 40dp 0.01 \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/widgets/tools/CropRectTransformation.java b/OsmAnd/src/net/osmand/plus/widgets/tools/CropRectTransformation.java new file mode 100644 index 0000000000..6a3af820cf --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/widgets/tools/CropRectTransformation.java @@ -0,0 +1,30 @@ +package net.osmand.plus.widgets.tools; + +import android.graphics.Bitmap; + +import com.squareup.picasso.Transformation; + +public class CropRectTransformation implements Transformation { + + private static final String KEY = "CropRectTransformation"; + + @Override + public Bitmap transform(Bitmap source) { + int size = Math.min(source.getWidth(), source.getHeight()); + + int x = (source.getWidth() - size * 2) / 2; + int y = (source.getHeight() - size) / 2; + + Bitmap bitmap = Bitmap.createBitmap(source, x, y, size * 2, size); + if (bitmap != source) { + source.recycle(); + } + + return bitmap; + } + + @Override + public String key() { + return KEY; + } +} diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java index 797e64cda9..b0a5fc042a 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/explore/SavedArticlesRvAdapter.java @@ -19,6 +19,7 @@ import net.osmand.plus.IconsCache; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.widgets.tools.CropCircleTransformation; +import net.osmand.plus.widgets.tools.CropRectTransformation; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper; @@ -30,6 +31,8 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter items = new ArrayList<>(); @@ -56,7 +59,9 @@ public class SavedArticlesRvAdapter extends RecyclerView.Adapter