-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Show avatars in activity list #14634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tobiasKaminsky
wants to merge
1
commit into
master
Choose a base branch
from
showAvatars
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * Nextcloud Talk - Android Client | ||
| * | ||
| * SPDX-FileCopyrightText: 2021 Andy Scherzinger <info@andy-scherzinger.de> | ||
| * SPDX-FileCopyrightText: 2017-2018 Mario Danic <mario@lovelyhq.com> | ||
| * SPDX-License-Identifier: GPL-3.0-or-later | ||
| */ | ||
| package com.nextcloud.utils.text; | ||
|
|
||
| import android.graphics.drawable.Drawable; | ||
|
|
||
| import androidx.annotation.NonNull; | ||
| import thirdparties.fresco.BetterImageSpan; | ||
|
|
||
| public class Spans { | ||
|
|
||
| public static class MentionChipSpan extends BetterImageSpan { | ||
| public String id; | ||
| public CharSequence label; | ||
|
|
||
| public MentionChipSpan(@NonNull Drawable drawable, int verticalAlignment, String id, CharSequence label) { | ||
| super(drawable, verticalAlignment); | ||
| this.id = id; | ||
| this.label = label; | ||
| } | ||
|
|
||
| public String getId() { | ||
| return this.id; | ||
| } | ||
|
|
||
| public CharSequence getLabel() { | ||
| return this.label; | ||
| } | ||
|
|
||
| public void setId(String id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public void setLabel(CharSequence label) { | ||
| this.label = label; | ||
| } | ||
|
|
||
| public boolean equals(final Object o) { | ||
| if (o == this) { | ||
| return true; | ||
| } | ||
| if (!(o instanceof MentionChipSpan)) { | ||
| return false; | ||
| } | ||
| final MentionChipSpan other = (MentionChipSpan) o; | ||
| if (!other.canEqual((Object) this)) { | ||
| return false; | ||
| } | ||
| final Object this$id = this.getId(); | ||
| final Object other$id = other.getId(); | ||
| if (this$id == null ? other$id != null : !this$id.equals(other$id)) { | ||
| return false; | ||
| } | ||
| final Object this$label = this.getLabel(); | ||
| final Object other$label = other.getLabel(); | ||
|
|
||
| return this$label == null ? other$label == null : this$label.equals(other$label); | ||
| } | ||
|
|
||
| protected boolean canEqual(final Object other) { | ||
| return other instanceof MentionChipSpan; | ||
| } | ||
|
|
||
| public int hashCode() { | ||
| final int PRIME = 59; | ||
| int result = 1; | ||
| final Object $id = this.getId(); | ||
| result = result * PRIME + ($id == null ? 43 : $id.hashCode()); | ||
| final Object $label = this.getLabel(); | ||
| return result * PRIME + ($label == null ? 43 : $label.hashCode()); | ||
| } | ||
|
|
||
| public String toString() { | ||
| return "Spans.MentionChipSpan(id=" + this.getId() + ", label=" + this.getLabel() + ")"; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
app/src/main/java/third_parties/fresco/BetterImageSpan.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2015-present, Facebook, Inc. and its affiliates. | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| package thirdparties.fresco | ||
|
|
||
| import android.graphics.Canvas | ||
| import android.graphics.Paint | ||
| import android.graphics.Rect | ||
| import android.graphics.drawable.Drawable | ||
| import android.text.style.ReplacementSpan | ||
| import androidx.annotation.IntDef | ||
|
|
||
| /** | ||
| * A better implementation of image spans that also supports centering images against the text. | ||
| * | ||
| * In order to migrate from ImageSpan, replace `new ImageSpan(drawable, alignment)` with | ||
| * `new BetterImageSpan(drawable, BetterImageSpan.normalizeAlignment(alignment))`. | ||
| * | ||
| * There are 2 main differences between BetterImageSpan and ImageSpan: | ||
| * 1. Pass in ALIGN_CENTER to center images against the text. | ||
| * 2. ALIGN_BOTTOM no longer unnecessarily increases the size of the text: | ||
| * DynamicDrawableSpan (ImageSpan's parent) adjusts sizes as if alignment was ALIGN_BASELINE | ||
| * which can lead to unnecessary whitespace. | ||
| */ | ||
| open class BetterImageSpan @JvmOverloads constructor( | ||
| val drawable: Drawable, | ||
| @param:BetterImageSpanAlignment private val mAlignment: Int = ALIGN_BASELINE | ||
| ) : ReplacementSpan() { | ||
| @Suppress("Detekt.SpreadOperator") | ||
| @IntDef(*[ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER]) | ||
| @Retention(AnnotationRetention.SOURCE) | ||
| annotation class BetterImageSpanAlignment | ||
|
|
||
| private var mWidth = 0 | ||
| private var mHeight = 0 | ||
| private var mBounds: Rect? = null | ||
| private val mFontMetricsInt = Paint.FontMetricsInt() | ||
|
|
||
| init { | ||
| updateBounds() | ||
| } | ||
|
|
||
| /** | ||
| * Returns the width of the image span and increases the height if font metrics are available. | ||
| */ | ||
| override fun getSize( | ||
| paint: Paint, | ||
| text: CharSequence, | ||
| start: Int, | ||
| end: Int, | ||
| fontMetrics: Paint.FontMetricsInt? | ||
| ): Int { | ||
| updateBounds() | ||
| if (fontMetrics == null) { | ||
| return mWidth | ||
| } | ||
| val offsetAbove = getOffsetAboveBaseline(fontMetrics) | ||
| val offsetBelow = mHeight + offsetAbove | ||
| if (offsetAbove < fontMetrics.ascent) { | ||
| fontMetrics.ascent = offsetAbove | ||
| } | ||
| if (offsetAbove < fontMetrics.top) { | ||
| fontMetrics.top = offsetAbove | ||
| } | ||
| if (offsetBelow > fontMetrics.descent) { | ||
| fontMetrics.descent = offsetBelow | ||
| } | ||
| if (offsetBelow > fontMetrics.bottom) { | ||
| fontMetrics.bottom = offsetBelow | ||
| } | ||
| return mWidth | ||
| } | ||
|
|
||
| override fun draw( | ||
| canvas: Canvas, | ||
| text: CharSequence, | ||
| start: Int, | ||
| end: Int, | ||
| x: Float, | ||
| top: Int, | ||
| y: Int, | ||
| bottom: Int, | ||
| paint: Paint | ||
| ) { | ||
| paint.getFontMetricsInt(mFontMetricsInt) | ||
| val iconTop = y + getOffsetAboveBaseline(mFontMetricsInt) | ||
| canvas.translate(x, iconTop.toFloat()) | ||
| drawable.draw(canvas) | ||
| canvas.translate(-x, -iconTop.toFloat()) | ||
| } | ||
|
|
||
| private fun updateBounds() { | ||
| mBounds = drawable.bounds | ||
| mWidth = mBounds!!.width() | ||
| mHeight = mBounds!!.height() | ||
| } | ||
|
|
||
| private fun getOffsetAboveBaseline(fm: Paint.FontMetricsInt): Int = when (mAlignment) { | ||
| ALIGN_BOTTOM -> fm.descent - mHeight | ||
| ALIGN_CENTER -> { | ||
| val textHeight = fm.descent - fm.ascent | ||
| val offset = (textHeight - mHeight) / 2 | ||
| fm.ascent + offset | ||
| } | ||
|
|
||
| ALIGN_BASELINE -> -mHeight | ||
| else -> -mHeight | ||
| } | ||
|
|
||
| companion object { | ||
| const val ALIGN_BOTTOM = 0 | ||
| const val ALIGN_BASELINE = 1 | ||
| const val ALIGN_CENTER = 2 | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?><!-- | ||
| ~ Nextcloud Talk - Android Client | ||
tobiasKaminsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ~ | ||
| ~ SPDX-FileCopyrightText: 2017-2018 Mario Danic <mario@lovelyhq.com> | ||
| ~ SPDX-License-Identifier: GPL-3.0-or-later | ||
| --> | ||
| <shape xmlns:android="http://schemas.android.com/apk/res/android" | ||
| android:shape="oval"> | ||
| <solid android:color="@color/colorPrimary" /> | ||
| </shape> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.