Skip to content

Commit feb07dc

Browse files
added emojis
1 parent 3cc1be0 commit feb07dc

File tree

8 files changed

+493
-31
lines changed

8 files changed

+493
-31
lines changed

app/src/main/java/com/kharagedition/tibetankeyboard/EmojiKeyboardView.kt

Lines changed: 143 additions & 26 deletions
Large diffs are not rendered by default.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.kharagedition.tibetankeyboard
2+
3+
import android.content.Context
4+
import android.util.AttributeSet
5+
import android.view.LayoutInflater
6+
import android.view.View
7+
import android.widget.ImageView
8+
import android.widget.LinearLayout
9+
import android.widget.TextView
10+
11+
class SimpleSearchKeyboard @JvmOverloads constructor(
12+
context: Context,
13+
attrs: AttributeSet? = null,
14+
defStyleAttr: Int = 0
15+
) : LinearLayout(context, attrs, defStyleAttr) {
16+
17+
private var onKeyClickListener: ((String) -> Unit)? = null
18+
private var onDeleteClickListener: (() -> Unit)? = null
19+
20+
init {
21+
orientation = VERTICAL
22+
LayoutInflater.from(context).inflate(R.layout.simple_search_keyboard, this, true)
23+
setupKeyListeners()
24+
}
25+
26+
private fun setupKeyListeners() {
27+
setKeyListener(R.id.key_q, "q")
28+
setKeyListener(R.id.key_w, "w")
29+
setKeyListener(R.id.key_e, "e")
30+
setKeyListener(R.id.key_r, "r")
31+
setKeyListener(R.id.key_t, "t")
32+
setKeyListener(R.id.key_y, "y")
33+
setKeyListener(R.id.key_u, "u")
34+
setKeyListener(R.id.key_i, "i")
35+
setKeyListener(R.id.key_o, "o")
36+
setKeyListener(R.id.key_p, "p")
37+
38+
// Second row
39+
setKeyListener(R.id.key_a, "a")
40+
setKeyListener(R.id.key_s, "s")
41+
setKeyListener(R.id.key_d, "d")
42+
setKeyListener(R.id.key_f, "f")
43+
setKeyListener(R.id.key_g, "g")
44+
setKeyListener(R.id.key_h, "h")
45+
setKeyListener(R.id.key_j, "j")
46+
setKeyListener(R.id.key_k, "k")
47+
setKeyListener(R.id.key_l, "l")
48+
49+
// Third row
50+
setKeyListener(R.id.key_z, "z")
51+
setKeyListener(R.id.key_x, "x")
52+
setKeyListener(R.id.key_c, "c")
53+
setKeyListener(R.id.key_v, "v")
54+
setKeyListener(R.id.key_b, "b")
55+
setKeyListener(R.id.key_n, "n")
56+
setKeyListener(R.id.key_m, "m")
57+
setKeyListener(R.id.key_space, " ")
58+
59+
// Delete key
60+
findViewById<ImageView>(R.id.key_delete).setOnClickListener {
61+
onDeleteClickListener?.invoke()
62+
}
63+
}
64+
65+
private fun setKeyListener(viewId: Int, key: String) {
66+
findViewById<TextView>(viewId).setOnClickListener {
67+
onKeyClickListener?.invoke(key)
68+
}
69+
}
70+
71+
fun setOnKeyClickListener(listener: (String) -> Unit) {
72+
onKeyClickListener = listener
73+
}
74+
75+
fun setOnDeleteClickListener(listener: () -> Unit) {
76+
onDeleteClickListener = listener
77+
}
78+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:width="24dp"
4+
android:height="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path
8+
android:fillColor="#FFFFFF"
9+
android:pathData="M22,3H7C6.31,3 5.77,3.35 5.41,3.88L0.39,12L5.41,20.11C5.77,20.64 6.31,21 7,21H22A2,2 0 0,0 24,19V5A2,2 0 0,0 22,3M19,15.59L17.59,17L14,13.41L10.41,17L9,15.59L12.59,12L9,8.41L10.41,7L14,10.59L17.59,7L19,8.41L15.41,12" />
10+
</vector>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:state_pressed="true">
4+
<shape android:shape="rectangle">
5+
<corners android:radius="4dp" />
6+
<solid android:color="#AAFFFFFF" />
7+
</shape>
8+
</item>
9+
<item>
10+
<shape android:shape="rectangle">
11+
<corners android:radius="4dp" />
12+
<solid android:color="#66FFFFFF" />
13+
<stroke android:width="1dp" android:color="#99FFFFFF" />
14+
</shape>
15+
</item>
16+
</selector>

app/src/main/res/layout/emoji_item.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
android:textSize="20sp"
1414
android:text="😀" />
1515

16-
</FrameLayout>
16+
</FrameLayout>

app/src/main/res/layout/emoji_keyboard_layout.xml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
android:layout_height="wrap_content"
66
android:orientation="vertical"
77
android:background="#FF704C04"
8-
android:padding="8dp">
8+
android:paddingBottom="20dp"
9+
>
910

1011
<!-- Search and Back Button Row -->
1112
<LinearLayout
@@ -37,7 +38,9 @@
3738
android:paddingLeft="12dp"
3839
android:paddingRight="12dp"
3940
android:textSize="14sp"
40-
android:singleLine="true" />
41+
android:singleLine="true"
42+
android:focusable="true"
43+
android:focusableInTouchMode="true" />
4144

4245
</LinearLayout>
4346

@@ -49,14 +52,28 @@
4952
android:layout_marginBottom="8dp"
5053
android:clipToPadding="false"
5154
android:paddingLeft="8dp"
52-
android:paddingRight="8dp" />
55+
android:paddingRight="8dp"
56+
android:visibility="visible"/>
5357

5458
<!-- Emoji Grid -->
5559
<androidx.recyclerview.widget.RecyclerView
5660
android:id="@+id/emoji_recycler_view"
5761
android:layout_width="match_parent"
5862
android:layout_height="200dp"
5963
android:clipToPadding="false"
60-
android:padding="4dp" />
64+
android:padding="4dp"
65+
android:layout_marginBottom="20dp"/>
66+
67+
<!-- Search Keyboard Container (Initially Hidden) -->
68+
<FrameLayout
69+
android:id="@+id/search_keyboard_container"
70+
android:layout_width="match_parent"
71+
android:layout_height="wrap_content"
72+
android:visibility="gone"
73+
android:background="#E6704C04"
74+
android:paddingBottom="25dp">
75+
<!-- Simple search keyboard will be added here -->
76+
</FrameLayout>
6177

6278
</LinearLayout>
79+
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:layout_width="match_parent"
5+
android:layout_height="wrap_content"
6+
android:orientation="vertical"
7+
android:background="#E6704C04"
8+
android:padding="4dp">
9+
10+
<LinearLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="40dp"
13+
android:orientation="horizontal"
14+
android:layout_marginBottom="2dp">
15+
16+
<TextView
17+
android:id="@+id/key_q"
18+
style="@style/SearchKeyStyle"
19+
android:text="q"
20+
android:layout_weight="1" />
21+
22+
<TextView
23+
android:id="@+id/key_w"
24+
style="@style/SearchKeyStyle"
25+
android:text="w"
26+
android:layout_weight="1" />
27+
28+
<TextView
29+
android:id="@+id/key_e"
30+
style="@style/SearchKeyStyle"
31+
android:text="e"
32+
android:layout_weight="1" />
33+
34+
<TextView
35+
android:id="@+id/key_r"
36+
style="@style/SearchKeyStyle"
37+
android:text="r"
38+
android:layout_weight="1" />
39+
40+
<TextView
41+
android:id="@+id/key_t"
42+
style="@style/SearchKeyStyle"
43+
android:text="t"
44+
android:layout_weight="1" />
45+
46+
<TextView
47+
android:id="@+id/key_y"
48+
style="@style/SearchKeyStyle"
49+
android:text="y"
50+
android:layout_weight="1" />
51+
52+
<TextView
53+
android:id="@+id/key_u"
54+
style="@style/SearchKeyStyle"
55+
android:text="u"
56+
android:layout_weight="1" />
57+
58+
<TextView
59+
android:id="@+id/key_i"
60+
style="@style/SearchKeyStyle"
61+
android:text="i"
62+
android:layout_weight="1" />
63+
64+
<TextView
65+
android:id="@+id/key_o"
66+
style="@style/SearchKeyStyle"
67+
android:text="o"
68+
android:layout_weight="1" />
69+
70+
<TextView
71+
android:id="@+id/key_p"
72+
style="@style/SearchKeyStyle"
73+
android:text="p"
74+
android:layout_weight="1" />
75+
76+
</LinearLayout>
77+
78+
<!-- Third Row: ASDF -->
79+
<LinearLayout
80+
android:layout_width="match_parent"
81+
android:layout_height="40dp"
82+
android:orientation="horizontal"
83+
android:layout_marginBottom="2dp">
84+
85+
<TextView
86+
android:id="@+id/key_a"
87+
style="@style/SearchKeyStyle"
88+
android:text="a"
89+
android:layout_weight="1" />
90+
91+
<TextView
92+
android:id="@+id/key_s"
93+
style="@style/SearchKeyStyle"
94+
android:text="s"
95+
android:layout_weight="1" />
96+
97+
<TextView
98+
android:id="@+id/key_d"
99+
style="@style/SearchKeyStyle"
100+
android:text="d"
101+
android:layout_weight="1" />
102+
103+
<TextView
104+
android:id="@+id/key_f"
105+
style="@style/SearchKeyStyle"
106+
android:text="f"
107+
android:layout_weight="1" />
108+
109+
<TextView
110+
android:id="@+id/key_g"
111+
style="@style/SearchKeyStyle"
112+
android:text="g"
113+
android:layout_weight="1" />
114+
115+
<TextView
116+
android:id="@+id/key_h"
117+
style="@style/SearchKeyStyle"
118+
android:text="h"
119+
android:layout_weight="1" />
120+
121+
<TextView
122+
android:id="@+id/key_j"
123+
style="@style/SearchKeyStyle"
124+
android:text="j"
125+
android:layout_weight="1" />
126+
127+
<TextView
128+
android:id="@+id/key_k"
129+
style="@style/SearchKeyStyle"
130+
android:text="k"
131+
android:layout_weight="1" />
132+
133+
<TextView
134+
android:id="@+id/key_l"
135+
style="@style/SearchKeyStyle"
136+
android:text="l"
137+
android:layout_weight="1" />
138+
139+
</LinearLayout>
140+
141+
<!-- Fourth Row: ZXCV with Delete -->
142+
<LinearLayout
143+
android:layout_width="match_parent"
144+
android:layout_height="40dp"
145+
android:orientation="horizontal">
146+
147+
<TextView
148+
android:id="@+id/key_z"
149+
style="@style/SearchKeyStyle"
150+
android:text="z"
151+
android:layout_weight="1" />
152+
153+
<TextView
154+
android:id="@+id/key_x"
155+
style="@style/SearchKeyStyle"
156+
android:text="x"
157+
android:layout_weight="1" />
158+
159+
<TextView
160+
android:id="@+id/key_c"
161+
style="@style/SearchKeyStyle"
162+
android:text="c"
163+
android:layout_weight="1" />
164+
165+
<TextView
166+
android:id="@+id/key_v"
167+
style="@style/SearchKeyStyle"
168+
android:text="v"
169+
android:layout_weight="1" />
170+
171+
<TextView
172+
android:id="@+id/key_b"
173+
style="@style/SearchKeyStyle"
174+
android:text="b"
175+
android:layout_weight="1" />
176+
177+
<TextView
178+
android:id="@+id/key_n"
179+
style="@style/SearchKeyStyle"
180+
android:text="n"
181+
android:layout_weight="1" />
182+
183+
<TextView
184+
android:id="@+id/key_m"
185+
style="@style/SearchKeyStyle"
186+
android:text="m"
187+
android:layout_weight="1" />
188+
189+
<TextView
190+
android:id="@+id/key_space"
191+
style="@style/SearchKeyStyle"
192+
android:text="Space"
193+
android:layout_weight="2" />
194+
195+
<ImageView
196+
android:id="@+id/key_delete"
197+
android:layout_width="0dp"
198+
android:layout_height="match_parent"
199+
android:layout_weight="1.5"
200+
android:src="@drawable/ic_backspace"
201+
android:background="@drawable/search_key_background"
202+
android:scaleType="centerInside"
203+
android:padding="8dp"
204+
android:layout_margin="1dp"
205+
android:contentDescription="Delete"
206+
app:tint="#FFFFFF" />
207+
208+
</LinearLayout>
209+
210+
</LinearLayout>
211+

app/src/main/res/values/themes.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,17 @@
3939
<item name="android:textColorPrimary">@color/white</item>
4040
<item name="android:textColorSecondary">@color/white</item>
4141
</style>
42+
43+
<style name="SearchKeyStyle">
44+
<item name="android:layout_width">0dp</item>
45+
<item name="android:layout_height">match_parent</item>
46+
<item name="android:gravity">center</item>
47+
<item name="android:textColor">#FFFFFF</item>
48+
<item name="android:textSize">14sp</item>
49+
<item name="android:background">@drawable/search_key_background</item>
50+
<item name="android:layout_margin">1dp</item>
51+
<item name="android:clickable">true</item>
52+
<item name="android:focusable">true</item>
53+
</style>
54+
4255
</resources>

0 commit comments

Comments
 (0)