This commit is contained in:
Andrei 2022-08-07 17:00:57 -07:00
parent cea73fc8f5
commit ae75ebb096
13 changed files with 58 additions and 46 deletions

View file

@ -1,6 +1,6 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="150dp" android:width="24dp"
android:height="150dp" android:height="24dp"
android:viewportWidth="150" android:viewportWidth="150"
android:viewportHeight="150"> android:viewportHeight="150">
<path <path

View file

@ -1,9 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" <vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp" android:width="24dp"
android:height="24dp" android:height="24dp"
android:viewportWidth="150" android:viewportWidth="24"
android:viewportHeight="150"> android:viewportHeight="24">
<path <path
android:fillColor="#95968E" android:fillColor="#95968E"
android:pathData="M63.11,112.45C72.91,112.46 82.49,109.54 90.62,104.05L119.18,132.61C122.89,136.32 128.92,136.32 132.64,132.61C136.35,128.89 136.35,122.86 132.64,119.15L104.08,90.59C112.32,78.31 114.62,62.99 110.35,48.83C106.08,34.68 95.69,23.19 82.03,17.51C68.38,11.84 52.9,12.58 39.86,19.54C26.82,26.5 17.58,38.94 14.68,53.44C11.8,67.94 15.56,82.97 24.93,94.4C34.31,105.83 48.32,112.45 63.11,112.45L63.11,112.45ZM63.11,25.12C73.17,25.12 82.82,29.12 89.94,36.24C97.06,43.36 101.06,53.01 101.06,63.08C101.06,73.14 97.06,82.79 89.94,89.91C82.82,97.03 73.17,101.03 63.11,101.03C53.04,101.03 43.39,97.03 36.27,89.91C29.15,82.79 25.15,73.14 25.15,63.08C25.17,53.01 29.17,43.37 36.28,36.25C43.4,29.14 53.04,25.14 63.11,25.12L63.11,25.12Z" /> android:pathData="M15.5,14h-0.79l-0.28,-0.27C15.41,12.59 16,11.11 16,9.5 16,5.91 13.09,3 9.5,3S3,5.91 3,9.5 5.91,16 9.5,16c1.61,0 3.09,-0.59 4.23,-1.57l0.27,0.28v0.79l5,4.99L20.49,19l-4.99,-5zM9.5,14C7.01,14 5,11.99 5,9.5S7.01,5 9.5,5 14,7.01 14,9.5 11.99,14 9.5,14z" />
</vector> </vector>

View file

@ -19,12 +19,13 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:animateLayoutChanges="true" android:animateLayoutChanges="true"
android:drawableLeft="@android:drawable/ic_menu_search" android:drawableLeft="@drawable/ic_search"
android:hint="@string/story_search_hint" android:hint="@string/story_search_hint"
android:imeOptions="actionSearch" android:imeOptions="actionSearch"
android:inputType="textNoSuggestions" android:inputType="textNoSuggestions"
android:textSize="16sp" android:textSize="16sp"
android:visibility="gone" /> android:visibility="gone"
android:autofillHints="@null"/>
<LinearLayout <LinearLayout
android:id="@+id/activity_itemlist_container" android:id="@+id/activity_itemlist_container"

View file

@ -139,8 +139,8 @@
android:layout_below="@id/reading_story_changes" android:layout_below="@id/reading_story_changes"
android:layout_alignLeft="@id/reading_item_title" android:layout_alignLeft="@id/reading_item_title"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
app:chipSpacingHorizontal="4dp" app:chipSpacingHorizontal="8dp"
app:chipSpacingVertical="4dp" /> app:chipSpacingVertical="6dp" />
<TextView <TextView
android:id="@+id/reading_item_saved_timestamp" android:id="@+id/reading_item_saved_timestamp"
@ -164,8 +164,8 @@
android:layout_alignLeft="@id/reading_item_title" android:layout_alignLeft="@id/reading_item_title"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:visibility="gone" android:visibility="gone"
app:chipSpacingHorizontal="4dp" app:chipSpacingHorizontal="8dp"
app:chipSpacingVertical="4dp" /> app:chipSpacingVertical="6dp" />
</RelativeLayout> </RelativeLayout>

View file

@ -30,25 +30,25 @@
app:icon="@drawable/ic_feed_train" /> app:icon="@drawable/ic_feed_train" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/share_story_button" android:id="@+id/save_story_button"
style="?storyButtons" style="?storyButtons"
android:layout_marginHorizontal="12dp" android:layout_marginHorizontal="12dp"
android:layout_toEndOf="@+id/train_story_button" android:layout_toEndOf="@+id/train_story_button"
android:layout_below="@+id/mark_read_story_button" android:layout_below="@+id/mark_read_story_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="44dp" android:layout_height="44dp"
android:text="@string/share_this" android:text="@string/save_this"
app:icon="@drawable/ic_share"/> app:icon="@drawable/ic_saved" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/save_story_button" android:id="@+id/share_story_button"
style="?storyButtons" style="?storyButtons"
android:layout_toEndOf="@+id/share_story_button" android:layout_toEndOf="@+id/save_story_button"
android:layout_below="@+id/mark_read_story_button" android:layout_below="@+id/mark_read_story_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="44dp" android:layout_height="44dp"
android:text="@string/save_this" android:text="@string/share_this"
app:icon="@drawable/ic_saved" /> app:icon="@drawable/ic_share"/>
</RelativeLayout> </RelativeLayout>

View file

@ -6,8 +6,8 @@
<ImageView <ImageView
android:id="@+id/row_folder_icon" android:id="@+id/row_folder_icon"
android:layout_width="19dp" android:layout_width="20dp"
android:layout_height="19dp" android:layout_height="20dp"
android:layout_alignParentLeft="true" android:layout_alignParentLeft="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginLeft="12dp" android:layout_marginLeft="12dp"

View file

@ -109,7 +109,6 @@
android:layout_toRightOf="@id/story_item_inteldot_container" android:layout_toRightOf="@id/story_item_inteldot_container"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="3" android:maxLines="3"
android:paddingRight="4dp"
android:textStyle="bold" /> android:textStyle="bold" />
<!--dynamic spacing--> <!--dynamic spacing-->
@ -120,8 +119,6 @@
android:layout_toLeftOf="@id/story_item_thumbnail_right" android:layout_toLeftOf="@id/story_item_thumbnail_right"
android:layout_toRightOf="@id/story_item_inteldot_container" android:layout_toRightOf="@id/story_item_inteldot_container"
android:layout_below="@id/story_item_title" android:layout_below="@id/story_item_title"
android:paddingRight="4dp"
android:maxLines="2"
android:ellipsize="end" android:ellipsize="end"
android:lineSpacingExtra="1dp" android:lineSpacingExtra="1dp"
style="?storySnippetText" /> style="?storySnippetText" />

View file

@ -287,7 +287,7 @@ public abstract class ItemsList extends NbActivity {
menu.findItem(R.id.menu_story_thumbnail_right_small).setChecked(true); menu.findItem(R.id.menu_story_thumbnail_right_small).setChecked(true);
} else if (thumbnailStyle == ThumbnailStyle.RIGHT_LARGE) { } else if (thumbnailStyle == ThumbnailStyle.RIGHT_LARGE) {
menu.findItem(R.id.menu_story_thumbnail_right_large).setChecked(true); menu.findItem(R.id.menu_story_thumbnail_right_large).setChecked(true);
} else if (thumbnailStyle == ThumbnailStyle.OFF) { } else if (thumbnailStyle.isOff()) {
menu.findItem(R.id.menu_story_thumbnail_no_preview).setChecked(true); menu.findItem(R.id.menu_story_thumbnail_no_preview).setChecked(true);
} }

View file

@ -624,8 +624,9 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
// dynamic spacing // dynamic spacing
int verticalTitlePadding = spacingStyle.getStoryTitleVerticalPadding(context); int verticalTitlePadding = spacingStyle.getStoryTitleVerticalPadding(context);
int RightTitlePadding = spacingStyle.getStoryContentRightPadding(context, thumbnailStyle);
vh.storyTitleView.setPadding(vh.storyTitleView.getPaddingLeft(), verticalTitlePadding, vh.storyTitleView.setPadding(vh.storyTitleView.getPaddingLeft(), verticalTitlePadding,
vh.storyTitleView.getPaddingRight(), verticalTitlePadding); RightTitlePadding, verticalTitlePadding);
// read/unread fading // read/unread fading
if (this.ignoreReadStatus || (! story.read)) { if (this.ignoreReadStatus || (! story.read)) {
@ -659,7 +660,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
// the image loader, which in turn can massively optimise loading. the image loader will // the image loader, which in turn can massively optimise loading. the image loader will
// reject nonsene values // reject nonsene values
if (PrefsUtils.getThumbnailStyle(context) != ThumbnailStyle.OFF && vh.thumbTileView != null) { if (!thumbnailStyle.isOff() && vh.thumbTileView != null) {
// the view will display a stale, recycled thumb before the new one loads if the old is not cleared // the view will display a stale, recycled thumb before the new one loads if the old is not cleared
int thumbSizeGuess = vh.thumbTileView.getMeasuredHeight(); int thumbSizeGuess = vh.thumbTileView.getMeasuredHeight();
vh.thumbTileView.setImageBitmap(null); vh.thumbTileView.setImageBitmap(null);
@ -676,7 +677,7 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
vh.storySnippet.setMaxLines(6); vh.storySnippet.setMaxLines(6);
} else if (storyContentPreviewStyle == StoryContentPreviewStyle.MEDIUM) { } else if (storyContentPreviewStyle == StoryContentPreviewStyle.MEDIUM) {
vh.storySnippet.setMaxLines(4); vh.storySnippet.setMaxLines(4);
} else if (storyContentPreviewStyle == StoryContentPreviewStyle.SMALL){ } else if (storyContentPreviewStyle == StoryContentPreviewStyle.SMALL) {
vh.storySnippet.setMaxLines(2); vh.storySnippet.setMaxLines(2);
} }
if (!TextUtils.isEmpty(story.shortContent)) { if (!TextUtils.isEmpty(story.shortContent)) {
@ -699,9 +700,10 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
vh.storyAuthor.setTextSize(textSize * defaultTextSize_story_item_date_or_author); vh.storyAuthor.setTextSize(textSize * defaultTextSize_story_item_date_or_author);
vh.storySnippet.setTextSize(textSize * defaultTextSize_story_item_snip); vh.storySnippet.setTextSize(textSize * defaultTextSize_story_item_snip);
int contentRightPadding = spacingStyle.getStoryContentRightPadding(context, thumbnailStyle);
int contentVerticalPadding = spacingStyle.getStoryContentVerticalPadding(context); int contentVerticalPadding = spacingStyle.getStoryContentVerticalPadding(context);
vh.storySnippet.setPadding(vh.storySnippet.getPaddingLeft(), vh.storySnippet.getPaddingTop(), vh.storySnippet.setPadding(vh.storySnippet.getPaddingLeft(), vh.storySnippet.getPaddingTop(),
vh.storySnippet.getPaddingRight(), contentVerticalPadding); contentRightPadding, contentVerticalPadding);
int verticalContainerMargin = spacingStyle.getStoryContainerMargin(context); int verticalContainerMargin = spacingStyle.getStoryContainerMargin(context);
RelativeLayout.LayoutParams feedIconLp = (RelativeLayout.LayoutParams) vh.feedIconView.getLayoutParams(); RelativeLayout.LayoutParams feedIconLp = (RelativeLayout.LayoutParams) vh.feedIconView.getLayoutParams();
@ -711,15 +713,15 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
RelativeLayout.LayoutParams storyDateLp = (RelativeLayout.LayoutParams) vh.storyDate.getLayoutParams(); RelativeLayout.LayoutParams storyDateLp = (RelativeLayout.LayoutParams) vh.storyDate.getLayoutParams();
storyDateLp.setMargins(storyDateLp.leftMargin, storyDateLp.topMargin, storyDateLp.rightMargin, verticalContainerMargin); storyDateLp.setMargins(storyDateLp.leftMargin, storyDateLp.topMargin, storyDateLp.rightMargin, verticalContainerMargin);
if (PrefsUtils.getThumbnailStyle(context) != ThumbnailStyle.OFF && vh.thumbViewRight != null && vh.thumbViewLeft != null) { if (!thumbnailStyle.isOff() && vh.thumbViewRight != null && vh.thumbViewLeft != null) {
// the view will display a stale, recycled thumb before the new one loads if the old is not cleared // the view will display a stale, recycled thumb before the new one loads if the old is not cleared
if (thumbnailStyle == ThumbnailStyle.LEFT_LARGE || thumbnailStyle == ThumbnailStyle.LEFT_SMALL) { if (thumbnailStyle.isLeft()) {
int thumbSizeGuess = vh.thumbViewLeft.getMeasuredHeight(); int thumbSizeGuess = vh.thumbViewLeft.getMeasuredHeight();
vh.thumbViewLeft.setImageBitmap(null); vh.thumbViewLeft.setImageBitmap(null);
vh.thumbLoader = thumbnailLoader.displayImage(story.thumbnailUrl, vh.thumbViewLeft, thumbSizeGuess, true); vh.thumbLoader = thumbnailLoader.displayImage(story.thumbnailUrl, vh.thumbViewLeft, thumbSizeGuess, true);
vh.thumbViewRight.setVisibility(View.GONE); vh.thumbViewRight.setVisibility(View.GONE);
vh.thumbViewLeft.setVisibility(View.VISIBLE); vh.thumbViewLeft.setVisibility(View.VISIBLE);
} else if (thumbnailStyle == ThumbnailStyle.RIGHT_LARGE || thumbnailStyle == ThumbnailStyle.RIGHT_SMALL) { } else if (thumbnailStyle.isRight()) {
int thumbSizeGuess = vh.thumbViewRight.getMeasuredHeight(); int thumbSizeGuess = vh.thumbViewRight.getMeasuredHeight();
vh.thumbViewRight.setImageBitmap(null); vh.thumbViewRight.setImageBitmap(null);
vh.thumbLoader = thumbnailLoader.displayImage(story.thumbnailUrl, vh.thumbViewRight, thumbSizeGuess, true); vh.thumbLoader = thumbnailLoader.displayImage(story.thumbnailUrl, vh.thumbViewRight, thumbSizeGuess, true);
@ -735,23 +737,23 @@ public class StoryViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHold
} }
int sizeRes = R.dimen.thumbnails_size; int sizeRes = R.dimen.thumbnails_size;
if (thumbnailStyle == ThumbnailStyle.LEFT_SMALL || thumbnailStyle == ThumbnailStyle.RIGHT_SMALL) { if (thumbnailStyle.isSmall()) {
sizeRes = R.dimen.thumbnails_small_size; sizeRes = R.dimen.thumbnails_small_size;
} }
int sizeDp = context.getResources().getDimensionPixelSize(sizeRes); int sizeDp = context.getResources().getDimensionPixelSize(sizeRes);
RelativeLayout.LayoutParams params = null; RelativeLayout.LayoutParams params = null;
if ((thumbnailStyle == ThumbnailStyle.LEFT_LARGE || thumbnailStyle == ThumbnailStyle.LEFT_SMALL) && vh.thumbViewLeft != null) { if (thumbnailStyle.isLeft() && vh.thumbViewLeft != null) {
vh.thumbViewLeft.setThumbnailStyle(thumbnailStyle); vh.thumbViewLeft.setThumbnailStyle(thumbnailStyle);
params = (RelativeLayout.LayoutParams) vh.thumbViewLeft.getLayoutParams(); params = (RelativeLayout.LayoutParams) vh.thumbViewLeft.getLayoutParams();
} else if ((thumbnailStyle == ThumbnailStyle.RIGHT_LARGE || thumbnailStyle == ThumbnailStyle.RIGHT_SMALL) && vh.thumbViewRight != null) { } else if (thumbnailStyle.isRight() && vh.thumbViewRight != null) {
vh.thumbViewRight.setThumbnailStyle(thumbnailStyle); vh.thumbViewRight.setThumbnailStyle(thumbnailStyle);
params = (RelativeLayout.LayoutParams) vh.thumbViewRight.getLayoutParams(); params = (RelativeLayout.LayoutParams) vh.thumbViewRight.getLayoutParams();
} }
if (params != null && params.width != sizeDp) { if (params != null && params.width != sizeDp) {
params.width = sizeDp; params.width = sizeDp;
} }
if (params != null && (thumbnailStyle == ThumbnailStyle.RIGHT_SMALL || thumbnailStyle == ThumbnailStyle.LEFT_SMALL)) { if (params != null && thumbnailStyle.isSmall()) {
int verticalMargin = singleFeed ? verticalContainerMargin + UIUtils.dp2px(context, 2) : verticalContainerMargin; int verticalMargin = singleFeed ? verticalContainerMargin + UIUtils.dp2px(context, 2) : verticalContainerMargin;
params.setMargins(UIUtils.dp2px(context, 8), verticalMargin, 0, verticalMargin); params.setMargins(UIUtils.dp2px(context, 8), verticalMargin, 0, verticalMargin);
params.addRule(RelativeLayout.ALIGN_BOTTOM, vh.storySnippet.getId()); params.addRule(RelativeLayout.ALIGN_BOTTOM, vh.storySnippet.getId());

View file

@ -29,4 +29,8 @@ enum class SpacingStyle {
COMFORTABLE -> UIUtils.dp2px(context, 11) COMFORTABLE -> UIUtils.dp2px(context, 11)
COMPACT -> UIUtils.dp2px(context, 3) COMPACT -> UIUtils.dp2px(context, 3)
} }
fun getStoryContentRightPadding(context: Context, thumbnailStyle: ThumbnailStyle): Int =
if (thumbnailStyle.isRight()) UIUtils.dp2px(context, 4)
else UIUtils.dp2px(context, 16)
} }

View file

@ -1,10 +0,0 @@
package com.newsblur.util;
public enum ThumbnailStyle {
LEFT_SMALL,
LEFT_LARGE,
RIGHT_SMALL,
RIGHT_LARGE,
OFF
}

View file

@ -0,0 +1,18 @@
package com.newsblur.util
enum class ThumbnailStyle {
LEFT_SMALL,
LEFT_LARGE,
RIGHT_SMALL,
RIGHT_LARGE,
OFF,
;
fun isLeft() = this == LEFT_SMALL || this == LEFT_LARGE
fun isRight() = this == RIGHT_SMALL || this == RIGHT_LARGE
fun isSmall() = this == RIGHT_SMALL || this == LEFT_SMALL
fun isOff() = this == OFF
}

View file

@ -16,7 +16,7 @@ class StoryThumbnailView
} }
fun setThumbnailStyle(thumbnailStyle: ThumbnailStyle) { fun setThumbnailStyle(thumbnailStyle: ThumbnailStyle) {
if (thumbnailStyle == ThumbnailStyle.LEFT_SMALL || thumbnailStyle == ThumbnailStyle.RIGHT_SMALL) { if (thumbnailStyle.isSmall()) {
setBackgroundResource(R.drawable.shape_rounded_corners_6dp) setBackgroundResource(R.drawable.shape_rounded_corners_6dp)
} else { } else {
setBackgroundResource(0) setBackgroundResource(0)