Skip to content

feat: show icon instead of channel alias - #199

Merged
omg-xtao merged 2 commits into
NextAlone:devfrom
waifucon:feat-show-channel-icon
Oct 8, 2026
Merged

omg-xtao merged 2 commits into
NextAlone:devfrom
waifucon:feat-show-channel-icon

Conversation

@waifucon

@waifucon waifucon commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

it looks better imo.

Option disabled:
Screenshot_20261007_210001_Nagram

Option enabled:
image

just like this pr: #85

Summary by Sourcery

Add configurable channel icons for channel-authored message labels.

New Features:

  • Add an option to display a channel icon instead of the channel alias on channel-authored messages.

Enhancements:

  • Use the rendered admin label layout to calculate channel label width accurately.
  • Hide the custom channel label setting when channel icons are enabled.

@sourcery-ai

sourcery-ai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

This PR adds a configurable channel-icon presentation for channel-authored megagroup messages, replacing the alias/custom label with a cached broadcast icon while updating label sizing and conditionally adjusting the related experimental settings UI.

Sequence diagram for channel icon rendering

sequenceDiagram
    participant ChatMessageCell
    participant NaConfig
    participant TimeStringHelper
    participant ContextCompat
    participant Theme
    participant StaticLayout

    ChatMessageCell->>NaConfig: getShowChannelIcon().Bool()
    alt icon enabled
        ChatMessageCell->>TimeStringHelper: getChannelDrawable()
        TimeStringHelper->>ContextCompat: getDrawable(applicationContext, menu_broadcast)
        ContextCompat-->>TimeStringHelper: Drawable
        TimeStringHelper-->>ChatMessageCell: channelDrawable
        ChatMessageCell->>Theme: chat_adminPaint.getTextSize()
        ChatMessageCell->>ChatMessageCell: append icon span
    else icon disabled
        ChatMessageCell->>NaConfig: getCustomChannelLabel().String()
        ChatMessageCell->>ChatMessageCell: getChannelAlias(channel_id)
        ChatMessageCell->>ChatMessageCell: append alias or channel label
    end
    ChatMessageCell->>StaticLayout: getLineWidth(0)
    StaticLayout-->>ChatMessageCell: adminWidth
Loading

Flow diagram for experimental channel label settings

flowchart TD
    A[User toggles ShowChannelIcon] --> B[NaConfig.showChannelIcon updates]
    B --> C[updateRows]
    C --> D{ShowChannelIcon enabled?}
    D -->|Yes| E[Hide custom channel label row]
    D -->|No| F[Show custom channel label row]
Loading

File-Level Changes

Change Details Files
Add an option to render a broadcast-channel icon in place of the channel alias for channel-authored megagroup messages.
  • Introduce a persisted ShowChannelIcon configuration option and expose it in experimental settings.
  • Render the broadcast drawable as a centered, text-sized span and calculate the resulting admin-label width with StaticLayout.
  • Preserve alias/custom-label rendering when the icon option is disabled, and hide the custom channel label setting when the icon is enabled.
  • Cache the channel drawable for reuse.
TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/TimeStringHelper.java
TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java
TMessagesProj/src/main/kotlin/xyz/nextalone/nagram/NaConfig.kt
TMessagesProj/src/main/res/values/strings_na.xml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java" line_range="19098-19099" />
<code_context>
-                    adminString.append(channelStr);
                 }
-                adminWidth = (int) Math.ceil(Theme.chat_adminPaint.measureText(adminString.toString()));
+                StaticLayout staticLayout = new StaticLayout(adminString, Theme.chat_adminPaint, dp(300), Layout.Alignment.ALIGN_NORMAL, 0f, 0f, false);
+                adminWidth = (int) Math.ceil(staticLayout.getLineWidth(0));
                 nameWidth -= adminWidth;
             } else {
</code_context>
<issue_to_address>
**Long labels overlap message content**

When a channel alias or configured label exceeds 300dp, `StaticLayout.getLineWidth(0)` measures only the first wrapped line, making `adminWidth` too narrow and `nameWidth` too large. The label wraps, overlaps the author name, and can spill into message content.

Measure the complete label rather than only the first line when calculating `adminWidth`.
</issue_to_address>

### Comment 2
<location path="TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java" line_range="340-341" />
<code_context>
                 tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
             } else if (key.equals(NaConfig.INSTANCE.getDisableStories().getKey())) {
                 tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
+            } else if (key.equals(NaConfig.INSTANCE.getShowChannelIcon().getKey())) {
+                updateRows();
             }
         };
</code_context>
<issue_to_address>
**Bound messages keep stale labels**

When the option changes while messages with the previous label are already bound, `updateRows()` refreshes only the settings list; `ChatMessageCell.setMessageObjectInternal()` has already stored each message label, so bound cells keep showing the old alias or icon until rebound.

Refresh or rebind the visible `ChatMessageCell` instances when the option changes.
</issue_to_address>

### Comment 3
<location path="TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/TimeStringHelper.java" line_range="14" />
<code_context>

 public class TimeStringHelper {
     public static Drawable forwardsDrawable;
+    public static Drawable channelDrawable;

     public static Drawable getForwardsDrawable() {
</code_context>
<issue_to_address>
**Channel icons use wrong colors**

When channel-label spans with different admin colors are drawn in succession, `TimeStringHelper.getChannelDrawable()` returns the same mutable drawable to every `ColoredImageSpan`. A span can change its color filter while another span skips resetting it because its cached tint is unchanged, so icons display the wrong colors.

Return a separate mutated drawable for each span, or reset the drawable’s color filter on every draw.

Also at `TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java:19078-19081`, `TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/TimeStringHelper.java:25-27`.
</issue_to_address>

### Comment 4
<location path="TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java" line_range="340-341" />
<code_context>
                 tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
             } else if (key.equals(NaConfig.INSTANCE.getDisableStories().getKey())) {
                 tooltip.showWithAction(0, UndoView.ACTION_NEED_RESATRT, null, null);
+            } else if (key.equals(NaConfig.INSTANCE.getShowChannelIcon().getKey())) {
+                updateRows();
             }
         };
</code_context>
<issue_to_address>
**Channel label setting stays stale**

When the user changes ShowChannelIcon while the settings screen is open, the toggle handler calls `updateRows()`, but the custom-label row is added or removed only in `setCanNotChange()`. Since the handler does not call that row-management logic, changing the icon setting leaves the custom-label row visible or hidden until the settings screen is rebuilt.

Reapply the custom-label row visibility rule when the setting changes, then refresh the adapter.

Also at `TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java:552-555`.
</issue_to_address>

Sourcery assessment

Approval pending. 4 findings to address first.

Blocking findings: TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java:19099, TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java:341, TMessagesProj/src/main/java/tw/nekomimi/nekogram/helpers/TimeStringHelper.java:14, TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoExperimentalSettingsActivity.java:341


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@omg-xtao
omg-xtao merged commit 59288a7 into NextAlone:dev Oct 8, 2026
0 of 3 checks passed
@omg-xtao omg-xtao added the enhancement New feature or request label Oct 8, 2026
@waifucon
waifucon deleted the feat-show-channel-icon branch October 8, 2026 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants