mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-21 07:13:44 +01:00
Change how avatars are selected so that poor quality avatars are passed up for their feed favicon
This commit is contained in:
parent
2e178dbebc
commit
da8c40d38f
@ -191,9 +191,7 @@ private extension MasterTimelineTableViewCell {
|
|||||||
|
|
||||||
func updateAvatar() {
|
func updateAvatar() {
|
||||||
|
|
||||||
// The avatar should be bigger than a favicon. They’re too small; they look weird.
|
guard let image = cellData.avatar, cellData.showAvatar else {
|
||||||
let minDimension = 22.0 * RSScreen.mainScreenScale
|
|
||||||
guard let image = cellData.avatar, cellData.showAvatar, image.size.height >= minDimension, image.size.width >= minDimension else {
|
|
||||||
makeAvatarEmpty()
|
makeAvatarEmpty()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -202,7 +200,7 @@ private extension MasterTimelineTableViewCell {
|
|||||||
avatarImageView.layer.cornerRadius = MasterTimelineCellLayout.avatarCornerRadius
|
avatarImageView.layer.cornerRadius = MasterTimelineCellLayout.avatarCornerRadius
|
||||||
avatarImageView.clipsToBounds = true
|
avatarImageView.clipsToBounds = true
|
||||||
|
|
||||||
if avatarImageView.image !== image {
|
if avatarImageView.image !== cellData.avatar {
|
||||||
avatarImageView.image = image
|
avatarImageView.image = image
|
||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import Articles
|
|||||||
|
|
||||||
class MasterTimelineViewController: ProgressTableViewController, UndoableCommandRunner {
|
class MasterTimelineViewController: ProgressTableViewController, UndoableCommandRunner {
|
||||||
|
|
||||||
|
private static var minAvatarDimension: CGFloat = 20.0
|
||||||
private var rowHeightWithFeedName: CGFloat = 0.0
|
private var rowHeightWithFeedName: CGFloat = 0.0
|
||||||
private var rowHeightWithoutFeedName: CGFloat = 0.0
|
private var rowHeightWithoutFeedName: CGFloat = 0.0
|
||||||
|
|
||||||
@ -365,15 +366,12 @@ private extension MasterTimelineViewController {
|
|||||||
|
|
||||||
func configureTimelineCell(_ cell: MasterTimelineTableViewCell, article: Article) {
|
func configureTimelineCell(_ cell: MasterTimelineTableViewCell, article: Article) {
|
||||||
|
|
||||||
var avatar = avatarFor(article)
|
let avatar = avatarFor(article)
|
||||||
if avatar == nil, let feed = article.feed {
|
|
||||||
avatar = appDelegate.faviconDownloader.favicon(for: feed)
|
|
||||||
}
|
|
||||||
let featuredImage = featuredImageFor(article)
|
let featuredImage = featuredImageFor(article)
|
||||||
|
|
||||||
let showFeedNames = navState?.showFeedNames ?? false
|
let showFeedNames = navState?.showFeedNames ?? false
|
||||||
let showAvatars = navState?.showAvatars ?? false
|
let showAvatar = navState?.showAvatars ?? false && avatar != nil
|
||||||
cell.cellData = MasterTimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, avatar: avatar, showAvatar: showAvatars, featuredImage: featuredImage)
|
cell.cellData = MasterTimelineCellData(article: article, showFeedName: showFeedNames, feedName: article.feed?.nameForDisplay, avatar: avatar, showAvatar: showAvatar, featuredImage: featuredImage)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +383,7 @@ private extension MasterTimelineViewController {
|
|||||||
|
|
||||||
if let authors = article.authors {
|
if let authors = article.authors {
|
||||||
for author in authors {
|
for author in authors {
|
||||||
if let image = avatarForAuthor(author) {
|
if let image = avatarForAuthor(author), imagePassesQualityAssurance(image) {
|
||||||
return image
|
return image
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,8 +393,27 @@ private extension MasterTimelineViewController {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return appDelegate.feedIconDownloader.icon(for: feed)
|
let feedIconImage = appDelegate.feedIconDownloader.icon(for: feed)
|
||||||
|
if imagePassesQualityAssurance(feedIconImage) {
|
||||||
|
return feedIconImage
|
||||||
|
}
|
||||||
|
|
||||||
|
if let feed = article.feed, let faviconImage = appDelegate.faviconDownloader.favicon(for: feed) {
|
||||||
|
if imagePassesQualityAssurance(faviconImage) {
|
||||||
|
return faviconImage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func imagePassesQualityAssurance(_ image: UIImage?) -> Bool {
|
||||||
|
let minDimension = MasterTimelineViewController.minAvatarDimension * RSScreen.mainScreenScale
|
||||||
|
if let image = image, image.size.height >= minDimension, image.size.width >= minDimension {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func avatarForAuthor(_ author: Author) -> UIImage? {
|
func avatarForAuthor(_ author: Author) -> UIImage? {
|
||||||
|
Loading…
Reference in New Issue
Block a user