Emoji & Media Input
Relevant source files
The following files were used as context for generating this wiki page:
Emoji and media input in Ownkey Keyboard provides a dedicated interface for users to insert expressive content such as emojis, emoticons, and kaomoji. It is implemented as a specialized view within the Input Method Editor (IME) that allows for category-based browsing, historical tracking, and candidate suggestions while typing. Sources: strings.xml:23-26, EmojiPaletteView.kt
The system leverages modern Android UI frameworks like Jetpack Compose for the palette view and integrates with the EmojiCompat library to ensure consistent rendering across different Android versions and target applications. Sources: EmojiPaletteView.kt:56-61, FlorisEditorInfo.kt:82-86
UI Architecture and Components
The primary user interface for emoji selection is the EmojiPaletteView. This component organizes emojis into a scrollable grid and provides a tab-based navigation system to switch between different categories.
Component Structure
The UI is composed of several key layers:
- Category Tab Row: Uses a
PrimaryTabRowto display category icons. Clicking a tab scrolls the pager to the associated category. Sources: EmojiPaletteView.kt:182-192 - Horizontal Pager: Manages the transitions between different emoji categories. Sources: EmojiPaletteView.kt:225-231
- Lazy Vertical Grid: Displays the individual emoji keys within a category. It uses adaptive columns with a minimum size (currently 42.dp). Sources: EmojiPaletteView.kt:100, EmojiPaletteView.kt:279-285
- Popups: Handles long-press actions to show variations (skin tones) or history management (pinning/removing). Sources: EmojiPaletteView.kt:348-360, EmojiPaletteView.kt:407-422
Component Relationship Diagram
The following diagram illustrates how the different UI components of the emoji palette interact:
The EmojiPaletteView acts as the container for category navigation and the horizontal pager that hosts the grids. Sources: EmojiPaletteView.kt:98-150
Emoji Categories and History
Emojis are grouped into standard Unicode categories, with an additional "Recently Used" category for quick access to frequently used items.
| Category | Description |
|---|---|
| Recently Used | Stores pinned and recently used emojis. |
| Smileys & Emotions | Standard face emojis and emotional symbols. |
| People & Body | Human figures and body parts with skin tone support. |
| Animals & Nature | Flora, fauna, and environmental symbols. |
| Food & Drink | Food items and beverages. |
| Travel & Places | Transportation and geographic locations. |
| Activities | Sports, hobbies, and events. |
| Objects | Various inanimate items. |
| Symbols | Mathematical, religious, and technical symbols. |
| Flags | National and regional flags. |
Sources: strings.xml:51-60, EmojiPaletteView.kt:100-112
History Management
The "Recently Used" category is partitioned into two sections: "Pinned" and "Recent". Users can manage their history through long-press actions:
- Mark Used: Every time an emoji is input, it is sent to
EmojiHistoryHelperto update the usage frequency. Sources: EmojiPaletteView.kt:156-161 - Pin/Unpin: Fixes specific emojis at the top of the history list. Sources: EmojiPaletteView.kt:457-471
- Remove: Deletes a specific emoji from the history. Sources: EmojiPaletteView.kt:489-497
Data Flow for Emoji Input
When a user selects an emoji, the event flows from the UI component through the keyboard manager to the active text editor.
Selection Logic Sequence
The sequence below shows how an emoji input event is processed:
Input events are dispatched through the keyboardManager.inputEventDispatcher, while usage statistics are updated asynchronously in a coroutine scope. Sources: EmojiPaletteView.kt:156-161
Integration with EmojiCompat
To prevent "tofu" characters (missing glyphs), Ownkey Keyboard integrates with the androidx.emoji2 library. This allows the keyboard to render emojis even if the system font does not support them.
- Metadata Tracking: The
FlorisEditorInfoclass extractsemojiCompatMetadataVersionandemojiCompatReplaceAllfrom the editor's extras. Sources: FlorisEditorInfo.kt:82-86 - Filtering Support: The
EmojiPaletteViewfilters available emojis based on whether the currentEmojiCompatinstance supports them or if the system font has a glyph for them. Sources: EmojiPaletteView.kt:119-125 - Rendering: Custom
EmojiTextVieworTextViewinstances are used within the UI to render the emoji strings correctly. Sources: EmojiPaletteView.kt:510-540
Configuration Options
Users can customize the emoji and media experience through several preferences defined in the application settings.
| Preference | Type | Description |
|---|---|---|
| Preferred Skin Tone | Enum | Default skin tone for emojis supporting variations. |
| Preferred Hair Style | Enum | Default hair style for emojis. |
| Enable Emoji History | Boolean | Whether to track recently used emojis. |
| Max History Size | Integer | Maximum number of items to keep in the history. |
| Update Strategy | Enum | Sort strategy for history (e.g., auto-sort prepend/append). |
| Enable Suggestions | Boolean | Provide emoji suggestions in the Smartbar while typing. |
| Trigger Type | Enum | Trigger via inline text or leading colon (e.g., :smile). |
Sources: strings.xml:27-48, strings.xml:750-770
Future Roadmap Features
The project has planned several enhancements for the emoji and media input system:
- Emoji Search: Implementing a search interface within the emoji panel. Sources: ROADMAP.md:65
- Scrollable Transitions: Reworking the category borders to be "soft" (continuous scrolling) or side-scrollable. Sources: ROADMAP.md:66-67
- Stickers & GIFs: Expanding input capabilities to include richer media types. Sources: ROADMAP.md:80
- Kaomoji Panel: A dedicated panel implementation for Kaomoji (currently listed as a tab). Sources: ROADMAP.md:81
Summary
The Emoji & Media Input system provides a robust and customizable way to insert non-textual characters. It is built on a modular architecture using Jetpack Compose, ensuring efficient rendering and a responsive user experience. By integrating with EmojiCompat and providing detailed history management, the system offers both compatibility and convenience for the user. Sources: EmojiPaletteView.kt, AGENTS.md