Skip to content

Commit

Permalink
Suggestions update (#56)
Browse files Browse the repository at this point in the history
* Readme list problem fixed

* Basic keys enter animation added

* Basic suggestions list added

* Suggestions list improved

* Readme updated with new features

* Disable email suggestions option available

* Removed key codes from data models

* Email suggestions readme update added

* Suggestions image uploaded
  • Loading branch information
UmairKhalid786 authored Mar 2, 2023
1 parent e8e8806 commit ef8f849
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 119 deletions.
2 changes: 1 addition & 1 deletion .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ Basic TV custom keyboard written in jetpack compose
## Special Characters

![Screenshot_1676328680](https://user-images.githubusercontent.com/21205138/218593010-7db79c4b-7206-4849-a504-ed9480c5e1df.png)

## Email Suggestions

![suggestions](https://user-images.githubusercontent.com/21205138/222294045-08ab6242-f202-4f91-995d-99477aa73471.png)

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.techlads.composetvkeyboard.data

import android.view.KeyEvent
import com.techlads.composetvkeyboard.domain.model.UtilityKey.*
import com.techlads.composetvkeyboard.domain.model.SpecialCharactersKey.*
import com.techlads.composetvkeyboard.domain.model.Digit.*
Expand All @@ -19,7 +18,7 @@ object KeysDataSource {
val emailSuggestions: List<Key> by lazy { createEmailSuggestions() }

private fun createEmailSuggestions(): List<Key> = SuggestionHandler.emails.map {
SuggestionKey(KeyEvent.KEYCODE_UNKNOWN, it, 3)
SuggestionKey(it, 3)
}

private fun createToggleButtonsList() = mutableListOf<Key>().apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
package com.techlads.composetvkeyboard.domain.model

import android.view.KeyEvent.*

sealed class Alphabets(
override val code: Int,
override val text: String,
override val span: Int = 1
) : Key, Cloneable {
object A : Alphabets(KEYCODE_A, "a")
object B : Alphabets(KEYCODE_B, "b")
object C : Alphabets(KEYCODE_C, "c")
object D : Alphabets(KEYCODE_D, "d")
object E : Alphabets(KEYCODE_E, "e")
object F : Alphabets(KEYCODE_F, "f")
object G : Alphabets(KEYCODE_G, "g")
object H : Alphabets(KEYCODE_H, "h")
object I : Alphabets(KEYCODE_I, "i")
object J : Alphabets(KEYCODE_J, "j")
object K : Alphabets(KEYCODE_K, "k")
object L : Alphabets(KEYCODE_L, "l")
object M : Alphabets(KEYCODE_M, "m")
object N : Alphabets(KEYCODE_N, "n")
object O : Alphabets(KEYCODE_O, "o")
object P : Alphabets(KEYCODE_P, "p")
object Q : Alphabets(KEYCODE_Q, "q")
object R : Alphabets(KEYCODE_R, "r")
object S : Alphabets(KEYCODE_S, "s")
object T : Alphabets(KEYCODE_T, "t")
object U : Alphabets(KEYCODE_U, "u")
object V : Alphabets(KEYCODE_V, "v")
object W : Alphabets(KEYCODE_W, "w")
object X : Alphabets(KEYCODE_X, "x")
object Y : Alphabets(KEYCODE_Y, "y")
object Z : Alphabets(KEYCODE_Z, "z")
object A : Alphabets("a")
object B : Alphabets("b")
object C : Alphabets("c")
object D : Alphabets("d")
object E : Alphabets("e")
object F : Alphabets("f")
object G : Alphabets("g")
object H : Alphabets("h")
object I : Alphabets("i")
object J : Alphabets("j")
object K : Alphabets("k")
object L : Alphabets("l")
object M : Alphabets("m")
object N : Alphabets("n")
object O : Alphabets("o")
object P : Alphabets("p")
object Q : Alphabets("q")
object R : Alphabets("r")
object S : Alphabets("s")
object T : Alphabets("t")
object U : Alphabets("u")
object V : Alphabets("v")
object W : Alphabets("w")
object X : Alphabets("x")
object Y : Alphabets("y")
object Z : Alphabets("z")
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package com.techlads.composetvkeyboard.domain.model

import android.view.KeyEvent

sealed class Digit(
override val code: Int,
override val text: String,
override val span: Int = 1
) : Key {
object Zero : Digit(KeyEvent.KEYCODE_0, "0")
object One : Digit(KeyEvent.KEYCODE_1, "1")
object Two : Digit(KeyEvent.KEYCODE_2, "2")
object Three : Digit(KeyEvent.KEYCODE_3, "3")
object Four : Digit(KeyEvent.KEYCODE_4, "4")
object Five : Digit(KeyEvent.KEYCODE_5, "5")
object Six : Digit(KeyEvent.KEYCODE_6, "6")
object Seven : Digit(KeyEvent.KEYCODE_7, "7")
object Eight : Digit(KeyEvent.KEYCODE_8, "8")
object Nine : Digit(KeyEvent.KEYCODE_9, "9")
object Zero : Digit("0")
object One : Digit("1")
object Two : Digit("2")
object Three : Digit("3")
object Four : Digit("4")
object Five : Digit("5")
object Six : Digit("6")
object Seven : Digit("7")
object Eight : Digit("8")
object Nine : Digit("9")
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.techlads.composetvkeyboard.domain.model

interface Key {
val code: Int
val text: String
val span: Int
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.techlads.composetvkeyboard.domain.model

import android.view.KeyEvent.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.ArrowBack
import androidx.compose.material.icons.outlined.ArrowForward
Expand All @@ -10,27 +9,23 @@ import com.techlads.composetvkeyboard.data.KeysConstants

sealed class NumericUtilityKey(
override val icon: ImageVector,
override val code: Int,
override val text: String,
override val span: Int = 1
) : UtilityKey(icon, code, text, span) {
) : UtilityKey(icon, text, span) {

object Backspace : NumericUtilityKey(
Icons.Outlined.ArrowBack,
KEYCODE_BACK,
KeysConstants.BACK_SPACE_KEY
)

object Space : NumericUtilityKey(
Icons.Outlined.SpaceBar,
KEYCODE_SPACE,
KeysConstants.SPACE_KEY
)

object RightArrow :
NumericUtilityKey(
Icons.Outlined.ArrowForward,
KEYCODE_UNKNOWN,
KeysConstants.RIGHT_ARROW_KEY
)
}
Original file line number Diff line number Diff line change
@@ -1,60 +1,57 @@
package com.techlads.composetvkeyboard.domain.model

import android.view.KeyEvent.*

sealed class SpecialCharactersKey(
override val code: Int,
override val text: String,
override val span: Int = 1
) : Key {
object Dot : SpecialCharactersKey(KEYCODE_NUMPAD_DOT, ".")
object Underscore : SpecialCharactersKey(KEYCODE_UNKNOWN, "_")
object Dash : SpecialCharactersKey(KEYCODE_UNKNOWN, "-")
object Dollar : SpecialCharactersKey(KEYCODE_UNKNOWN, "$")
object Plus : SpecialCharactersKey(KEYCODE_UNKNOWN, "+")
object And : SpecialCharactersKey(KEYCODE_UNKNOWN, "&")
object ParenthesesBracketsLeft : SpecialCharactersKey(KEYCODE_UNKNOWN, "(")
object ParenthesesBracketsRight : SpecialCharactersKey(KEYCODE_UNKNOWN, ")")
object BackSlash : SpecialCharactersKey(KEYCODE_UNKNOWN, "/")
object Asterisk : SpecialCharactersKey(KEYCODE_UNKNOWN, "*")
object Quotes : SpecialCharactersKey(KEYCODE_UNKNOWN, "\"")
object SingleQuotes : SpecialCharactersKey(KEYCODE_UNKNOWN, "\'")
object Colon : SpecialCharactersKey(KEYCODE_UNKNOWN, ":")
object Semicolon : SpecialCharactersKey(KEYCODE_UNKNOWN, ";")
object Exclamation : SpecialCharactersKey(KEYCODE_UNKNOWN, "!")
object Question : SpecialCharactersKey(KEYCODE_UNKNOWN, "?")
object Percent : SpecialCharactersKey(KEYCODE_UNKNOWN, "%")
object Hash : SpecialCharactersKey(KEYCODE_UNKNOWN, "#")
object Ampersat : SpecialCharactersKey(KEYCODE_AT, "@")
object Comma : SpecialCharactersKey(KEYCODE_COMMA, ",")
object Dot : SpecialCharactersKey(".")
object Underscore : SpecialCharactersKey("_")
object Dash : SpecialCharactersKey("-")
object Dollar : SpecialCharactersKey("$")
object Plus : SpecialCharactersKey("+")
object And : SpecialCharactersKey("&")
object ParenthesesBracketsLeft : SpecialCharactersKey("(")
object ParenthesesBracketsRight : SpecialCharactersKey(")")
object BackSlash : SpecialCharactersKey("/")
object Asterisk : SpecialCharactersKey("*")
object Quotes : SpecialCharactersKey("\"")
object SingleQuotes : SpecialCharactersKey("\'")
object Colon : SpecialCharactersKey(":")
object Semicolon : SpecialCharactersKey(";")
object Exclamation : SpecialCharactersKey("!")
object Question : SpecialCharactersKey("?")
object Percent : SpecialCharactersKey("%")
object Hash : SpecialCharactersKey("#")
object Ampersat : SpecialCharactersKey("@")
object Comma : SpecialCharactersKey(",")

object Tide : SpecialCharactersKey(KEYCODE_UNKNOWN, "~")
object Grave : SpecialCharactersKey(KEYCODE_UNKNOWN, "`")
object Pipe : SpecialCharactersKey(KEYCODE_UNKNOWN, "|")
object Bullet : SpecialCharactersKey(KEYCODE_UNKNOWN, "")
object Root : SpecialCharactersKey(KEYCODE_UNKNOWN, "")
object PI : SpecialCharactersKey(KEYCODE_UNKNOWN, "π")
object Division : SpecialCharactersKey(KEYCODE_UNKNOWN, "÷")
object Multiple : SpecialCharactersKey(KEYCODE_UNKNOWN, "×")
object Paragraph : SpecialCharactersKey(KEYCODE_UNKNOWN, "")
object Triangle : SpecialCharactersKey(KEYCODE_UNKNOWN, "")
object Tide : SpecialCharactersKey("~")
object Grave : SpecialCharactersKey("`")
object Pipe : SpecialCharactersKey("|")
object Bullet : SpecialCharactersKey("")
object Root : SpecialCharactersKey("")
object PI : SpecialCharactersKey("π")
object Division : SpecialCharactersKey("÷")
object Multiple : SpecialCharactersKey("×")
object Paragraph : SpecialCharactersKey("")
object Triangle : SpecialCharactersKey("")

object Pound : SpecialCharactersKey(KEYCODE_UNKNOWN, "£")
object Cent : SpecialCharactersKey(KEYCODE_UNKNOWN, "¢")
object Euro : SpecialCharactersKey(KEYCODE_UNKNOWN, "")
object Yen : SpecialCharactersKey(KEYCODE_UNKNOWN, "¥")
object Caret : SpecialCharactersKey(KEYCODE_UNKNOWN, "^")
object Degree : SpecialCharactersKey(KEYCODE_UNKNOWN, "°")
object Equal : SpecialCharactersKey(KEYCODE_UNKNOWN, "=")
object CurlyBracketLeft : SpecialCharactersKey(KEYCODE_UNKNOWN, "{")
object CurlyBracketRight : SpecialCharactersKey(KEYCODE_UNKNOWN, "}")
object Backlash : SpecialCharactersKey(KEYCODE_UNKNOWN, "\\")
object Pound : SpecialCharactersKey("£")
object Cent : SpecialCharactersKey("¢")
object Euro : SpecialCharactersKey("")
object Yen : SpecialCharactersKey("¥")
object Caret : SpecialCharactersKey("^")
object Degree : SpecialCharactersKey("°")
object Equal : SpecialCharactersKey("=")
object CurlyBracketLeft : SpecialCharactersKey("{")
object CurlyBracketRight : SpecialCharactersKey("}")
object Backlash : SpecialCharactersKey("\\")

object CopyRight : SpecialCharactersKey(KEYCODE_UNKNOWN, "©")
object RegisterTrademark : SpecialCharactersKey(KEYCODE_UNKNOWN, "®")
object CheckMark : SpecialCharactersKey(KEYCODE_UNKNOWN, "")
object BoxBracketLeft : SpecialCharactersKey(KEYCODE_UNKNOWN, "[")
object BoxBracketRight : SpecialCharactersKey(KEYCODE_UNKNOWN, "]")
object ArrowLeft : SpecialCharactersKey(KEYCODE_UNKNOWN, "<")
object ArrowRight : SpecialCharactersKey(KEYCODE_UNKNOWN, ">")
object CopyRight : SpecialCharactersKey("©")
object RegisterTrademark : SpecialCharactersKey("®")
object CheckMark : SpecialCharactersKey("")
object BoxBracketLeft : SpecialCharactersKey("[")
object BoxBracketRight : SpecialCharactersKey("]")
object ArrowLeft : SpecialCharactersKey("<")
object ArrowRight : SpecialCharactersKey(">")
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.techlads.composetvkeyboard.domain.model

class SuggestionKey(override val code: Int, override val text: String, override val span: Int) : Key
class SuggestionKey(override val text: String, override val span: Int) : Key
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
package com.techlads.composetvkeyboard.domain.model

import android.view.KeyEvent
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Numbers
import androidx.compose.ui.graphics.vector.ImageVector
import com.techlads.composetvkeyboard.data.KeysConstants

sealed class TextUtilityKey(
override val icon: ImageVector,
override val code: Int,
override val text: String,
override val span: Int = 1
) : UtilityKey(icon, code, text, span) {
) : UtilityKey(icon, text, span) {

object Numeric : TextUtilityKey(
Icons.Outlined.Numbers,
KeyEvent.KEYCODE_NUM,
KeysConstants.NUMERIC_KEY
)

object SpecialCharacters : TextUtilityKey(
Icons.Outlined.Numbers,
KeyEvent.KEYCODE_NUM,
KeysConstants.SPECIAL_CHARACTERS_KEY
)

object ABC : TextUtilityKey(
Icons.Outlined.Numbers,
KeyEvent.KEYCODE_TV_TELETEXT,
KeysConstants.ABC_KEY
)
}
Original file line number Diff line number Diff line change
@@ -1,45 +1,40 @@
package com.techlads.composetvkeyboard.domain.model

import android.view.KeyEvent
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.*
import androidx.compose.ui.graphics.vector.ImageVector
import com.techlads.composetvkeyboard.data.KeysConstants

sealed class UtilityKey(
open val icon: ImageVector,
override val code: Int,
override val text: String,
override val span: Int = 1
) : Key {
object Uppercase : UtilityKey(
Icons.Outlined.KeyboardCapslock,
KeyEvent.KEYCODE_CAPS_LOCK,
KeysConstants.UPPER_CASE_KEY
)

object Backspace : UtilityKey(
Icons.Outlined.KeyboardBackspace,
KeyEvent.KEYCODE_BACK,
KeysConstants.BACK_SPACE_KEY
)

object Clear : UtilityKey(
Icons.Outlined.Delete,
KeyEvent.KEYCODE_CLEAR,
KeysConstants.CLEAR_KEY,
2
)

object Space : UtilityKey(
Icons.Outlined.SpaceBar,
KeyEvent.KEYCODE_SPACE,
KeysConstants.SPACE_KEY, 3
KeysConstants.SPACE_KEY,
3
)

object ActionArrow : UtilityKey(
Icons.Outlined.Search,
KeyEvent.KEYCODE_FORWARD,
KeysConstants.SEARCH_KEY, 2
KeysConstants.SEARCH_KEY,
2
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fun KeyboardView(
modifier: Modifier = Modifier,
textFieldState: MutableState<TextFieldValue>?,
focusFirstKey: Boolean = false,
enableEmailSuggestions: Boolean = false,
enableEmailSuggestions: Boolean = true,
onAction: ((key: Key) -> Unit)? = null,
onKeyPress: (key: Key) -> Unit
) {
Expand Down

0 comments on commit ef8f849

Please sign in to comment.