Skip to content

Sepehr1812/KeyboardForTV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KeyboardForTV

KeyboardForTV is a Jetpack Compose library designed specifically for Android TV applications. It provides a customizable on-screen keyboard with support for D-pad navigation, optimized for TV interfaces.

Features

  • TV-Optimized: Built with androidx.tv libraries, ensuring smooth D-pad navigation and focus handling.
  • Multi-language Support: Includes built-in support for English and Persian layouts, with easy switching.
  • Jetpack Compose: Fully composable and easy to integrate into modern Android apps.
  • Isolated Dependency Injection: Uses Koin with an isolated context to ensure no conflicts with the host application's DI graph.
  • Customizable Actions: callbacks for search query changes and voice search triggers.

Requirements

  • Android minSdk 21
  • Jetpack Compose (compatible with BOM 2024.12.01 or later)
  • Koin (internally used)

Usage

Integrate the Keyboard composable into your screen. The Keyboard component handles its own state (view model) internally using an isolated Koin context.

Basic Implementation

import ir.myket.keyboard.Keyboard
...

@Composable
fun SearchScreen() {
	var searchQuery by remember { mutableStateOf("") }

	Column {
		// ... Your UI content

		Keyboard(
			columnCount = 10, // Number of keys in a row
			onSearchQueryChange = { query ->
				// Handle the updated search query (e.g., filter a list)
				searchQuery = query
			},
		)
	}
}

Parameters

Parameter Type Description
modifier Modifier Modifier to be applied to the layout.
columnCount Int Defines the number of columns in the keyboard grid.
onSearchQueryChange (String) -> Unit Callback triggered whenever the input text changes (character added or removed).

Architecture & Tech Stack

The project is built using modern Android development practices:

  • Language: Kotlin
  • UI Framework: Jetpack Compose (with androidx.tv components).
  • Dependency Injection: Koin (using KoinIsolatedContext to encapsulate the library's dependencies).
  • Architecture: MVVM (Model-View-ViewModel) pattern.
    • KeyboardViewModel: Manages the state of the search query and keyboard actions.
    • ActionableViewModel: Base class for handling ViewModel actions via flows.

Project Structure

  • components: Contains individual UI components like keys (CharacterItem, ImageItem) and theSearchBox.
  • di: Koin configuration (KeyboardIsolatedKoinContext).
  • models: data classes representing keyboard keys and layouts (KeyboardItems).
  • utils: Extension functions and helper utilities.
  • viewmodels: State management logic.

About

KeyboardForTV is a Jetpack Compose library designed specifically for Android TV applications. It provides a customizable on-screen keyboard with support for D-pad navigation, optimized for TV interfaces.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages