@ -0,0 +1,28 @@ |
|||||
|
package gr.thmmy.mthmmy.activities; |
||||
|
|
||||
|
import android.os.Bundle; |
||||
|
import android.support.v7.app.AppCompatActivity; |
||||
|
import android.text.InputType; |
||||
|
import android.view.inputmethod.EditorInfo; |
||||
|
import android.view.inputmethod.InputConnection; |
||||
|
import android.widget.EditText; |
||||
|
|
||||
|
import gr.thmmy.mthmmy.R; |
||||
|
import gr.thmmy.mthmmy.utils.EmojiKeyboard; |
||||
|
|
||||
|
public class TestEditView extends AppCompatActivity { |
||||
|
|
||||
|
@Override |
||||
|
protected void onCreate(Bundle savedInstanceState) { |
||||
|
super.onCreate(savedInstanceState); |
||||
|
setContentView(R.layout.activity_test_edit_view); |
||||
|
|
||||
|
EditText testEdittext = (EditText) findViewById(R.id.test_edittext); |
||||
|
EmojiKeyboard emojiKeyboard = (EmojiKeyboard) findViewById(R.id.emoji_keyboard); |
||||
|
|
||||
|
testEdittext.setRawInputType(InputType.TYPE_CLASS_TEXT); |
||||
|
testEdittext.setTextIsSelectable(true); |
||||
|
InputConnection ic = testEdittext.onCreateInputConnection(new EditorInfo()); |
||||
|
emojiKeyboard.setInputConnection(ic); |
||||
|
} |
||||
|
} |
@ -0,0 +1,162 @@ |
|||||
|
package gr.thmmy.mthmmy.utils; |
||||
|
|
||||
|
import android.content.Context; |
||||
|
import android.util.AttributeSet; |
||||
|
import android.util.SparseArray; |
||||
|
import android.view.LayoutInflater; |
||||
|
import android.view.inputmethod.InputConnection; |
||||
|
import android.widget.GridView; |
||||
|
import android.widget.LinearLayout; |
||||
|
|
||||
|
import gr.thmmy.mthmmy.R; |
||||
|
import timber.log.Timber; |
||||
|
|
||||
|
public class EmojiKeyboard extends LinearLayout { |
||||
|
|
||||
|
private SparseArray<String> emojis = new SparseArray<>(); |
||||
|
|
||||
|
InputConnection inputConnection; |
||||
|
|
||||
|
public EmojiKeyboard(Context context) { |
||||
|
this(context, null, 0); |
||||
|
} |
||||
|
|
||||
|
public EmojiKeyboard(Context context, AttributeSet attrs) { |
||||
|
this(context, attrs, 0); |
||||
|
} |
||||
|
|
||||
|
public EmojiKeyboard(Context context, AttributeSet attrs, int defStyleAttrs) { |
||||
|
super(context, attrs, defStyleAttrs); |
||||
|
init(context, attrs); |
||||
|
} |
||||
|
|
||||
|
public void init(Context context, AttributeSet attrs) { |
||||
|
LayoutInflater.from(context).inflate(R.layout.emoji_keyboard, this, true); |
||||
|
|
||||
|
// add space before emoji
|
||||
|
emojis.append(R.drawable.heart, "<3"); |
||||
|
// this was copied twice in the original page for some reason
|
||||
|
emojis.append(R.drawable.locked, "^lock^"); |
||||
|
emojis.append(R.drawable.roll_over, "^rollover^"); |
||||
|
emojis.append(R.drawable.redface, "^redface^"); |
||||
|
emojis.append(R.drawable.confused, "^confused^"); |
||||
|
emojis.append(R.drawable.innocent, "^innocent^"); |
||||
|
emojis.append(R.drawable.sleep, "^sleep^"); |
||||
|
emojis.append(R.drawable.lips_sealed, "^sealed^"); |
||||
|
emojis.append(R.drawable.cool, "^cool^"); |
||||
|
emojis.append(R.drawable.crazy, "^crazy^"); |
||||
|
emojis.append(R.drawable.mad, "^mad^"); |
||||
|
emojis.append(R.drawable.wav, "^wav^"); |
||||
|
emojis.append(R.drawable.binkybaby, "^binkybaby^"); |
||||
|
// maybe renamed
|
||||
|
emojis.append(R.drawable.police, "^police^"); |
||||
|
emojis.append(R.drawable.dontknow, "^dontknow^"); |
||||
|
// the next two are the same thing?
|
||||
|
emojis.append(R.drawable.angry4, ":angry4:"); |
||||
|
emojis.append(R.drawable.angry_hot, "^angryhot^"); |
||||
|
emojis.append(R.drawable.angry, "^angry^"); |
||||
|
emojis.append(R.drawable.foyska, "^fouska^"); |
||||
|
// changed icon name to become valid drawable name
|
||||
|
emojis.append(R.drawable.e10_7_3e, "^sfinaki^"); |
||||
|
emojis.append(R.drawable.bang_head, "^banghead^"); |
||||
|
emojis.append(R.drawable.crybaby, "^crybaby^"); |
||||
|
emojis.append(R.drawable.hello, "^hello^"); |
||||
|
emojis.append(R.drawable.jerk, "^jerk^"); |
||||
|
emojis.append(R.drawable.nono, "^nono^"); |
||||
|
emojis.append(R.drawable.notworthy, "^notworthy^"); |
||||
|
// changed icon name to become valid drawable name
|
||||
|
emojis.append(R.drawable.off_topic, "^off-topic^"); |
||||
|
emojis.append(R.drawable.puke, "^puke^"); |
||||
|
emojis.append(R.drawable.shout, "^shout^"); |
||||
|
emojis.append(R.drawable.slurp, "^slurp^"); |
||||
|
emojis.append(R.drawable.superconfused, "^superconfused^"); |
||||
|
emojis.append(R.drawable.superinnocent, "^superinnocent^"); |
||||
|
emojis.append(R.drawable.cell_phone, "^cellPhone^"); |
||||
|
emojis.append(R.drawable.idiot, "^idiot^"); |
||||
|
emojis.append(R.drawable.knuppel, "^knuppel^"); |
||||
|
emojis.append(R.drawable.tickedoff, "^tickedOff^"); |
||||
|
emojis.append(R.drawable.peace, "^peace^"); |
||||
|
emojis.append(R.drawable.suspicious, "^suspicious^"); |
||||
|
emojis.append(R.drawable.caffine, "^caffine^"); |
||||
|
emojis.append(R.drawable.argue, "^argue^"); |
||||
|
emojis.append(R.drawable.banned2, "^banned2^"); |
||||
|
emojis.append(R.drawable.banned, "^banned^"); |
||||
|
emojis.append(R.drawable.bath, "^bath^"); |
||||
|
emojis.append(R.drawable.beg, "^beg^"); |
||||
|
emojis.append(R.drawable.bluescreen, "^bluescreen^"); |
||||
|
emojis.append(R.drawable.boil, "^boil^"); |
||||
|
emojis.append(R.drawable.bye, "^bye^"); |
||||
|
emojis.append(R.drawable.callmerip, "^callmerip^"); |
||||
|
emojis.append(R.drawable.carnaval, "^carnaval^"); |
||||
|
emojis.append(R.drawable.clap, "^clap^"); |
||||
|
emojis.append(R.drawable.coffeepot, "^coffepot^"); |
||||
|
emojis.append(R.drawable.crap, "^crap^"); |
||||
|
emojis.append(R.drawable.curses, "^curses^"); |
||||
|
emojis.append(R.drawable.funny, "^funny^"); |
||||
|
emojis.append(R.drawable.guitar1, "^guitar^"); |
||||
|
emojis.append(R.drawable.icon_kissy, "^kissy^"); |
||||
|
emojis.append(R.drawable.band, "^band^"); |
||||
|
emojis.append(R.drawable.ivres, "^ivres^"); |
||||
|
emojis.append(R.drawable.kaloe, "^kaloe^"); |
||||
|
emojis.append(R.drawable.kremala, "^kremala^"); |
||||
|
emojis.append(R.drawable.moon, "^moon^"); |
||||
|
emojis.append(R.drawable.mopping, "^mopping^"); |
||||
|
emojis.append(R.drawable.mountza, "^mountza^"); |
||||
|
emojis.append(R.drawable.pcsleep, "^pcsleep^"); |
||||
|
emojis.append(R.drawable.pinokio, "^pinokio^"); |
||||
|
emojis.append(R.drawable.poke, "^poke^"); |
||||
|
emojis.append(R.drawable.seestars, "^seestars^"); |
||||
|
emojis.append(R.drawable.sfyri, "^sfyri^"); |
||||
|
emojis.append(R.drawable.spam2, "^spam^"); |
||||
|
// changed icon name to become valid drawable name
|
||||
|
emojis.append(R.drawable.esuper, "^super^"); |
||||
|
emojis.append(R.drawable.tafos, "^tafos^"); |
||||
|
emojis.append(R.drawable.tomatomourh, "^tomato^"); |
||||
|
emojis.append(R.drawable.ytold, "^ytold^"); |
||||
|
emojis.append(R.drawable.beer2, "^beer^"); |
||||
|
emojis.append(R.drawable.yu, "^yue^"); |
||||
|
emojis.append(R.drawable.a_eatpaper, "^eatpaper^"); |
||||
|
emojis.append(R.drawable.fritz, "^fritz^"); |
||||
|
emojis.append(R.drawable.wade, "^wade^"); |
||||
|
emojis.append(R.drawable.lypi, "^lypi^"); |
||||
|
emojis.append(R.drawable.megashok1wq, "^aytoxeir^"); |
||||
|
emojis.append(R.drawable.victory, "^victory^"); |
||||
|
emojis.append(R.drawable.filarakia, "^filarakia^"); |
||||
|
emojis.append(R.drawable.bonjour_97213, "^hat^"); |
||||
|
emojis.append(R.drawable.curtseyqi9, "^miss^"); |
||||
|
emojis.append(R.drawable.rofl, "^rolfmao^"); |
||||
|
emojis.append(R.drawable.question, "^que^"); |
||||
|
emojis.append(R.drawable.shifty, "^shifty^"); |
||||
|
emojis.append(R.drawable.shy, "^shy^"); |
||||
|
emojis.append(R.drawable.music, "^music_listen^"); |
||||
|
emojis.append(R.drawable.shamed_bag, "^bagface^"); |
||||
|
emojis.append(R.drawable.rotfl, "^rotate^"); |
||||
|
emojis.append(R.drawable.love, "^love^"); |
||||
|
emojis.append(R.drawable.speech, "^speech^"); |
||||
|
emojis.append(R.drawable.facepalm, "^facepalm^"); |
||||
|
emojis.append(R.drawable.shocked, "^shocked^"); |
||||
|
emojis.append(R.drawable.extremely_shocked, "^ex_shocked^"); |
||||
|
emojis.append(R.drawable.smurf, "^smurf^"); |
||||
|
|
||||
|
GridView emojiGridView = (GridView) findViewById(R.id.emoji_gridview); |
||||
|
Timber.e("size of array = " + getEmojiArray().length); |
||||
|
emojiGridView.setAdapter(new ImageKeyboardAdapter(context, getEmojiArray())); |
||||
|
emojiGridView.setOnItemClickListener((parent, view, position, id) -> { |
||||
|
if (inputConnection == null) return; |
||||
|
String value = emojis.valueAt(position); |
||||
|
inputConnection.commitText(value, 1); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
public void setInputConnection(InputConnection inputConnection) { |
||||
|
this.inputConnection = inputConnection; |
||||
|
} |
||||
|
|
||||
|
public int[] getEmojiArray() { |
||||
|
int[] emojiArray = new int[emojis.size()]; |
||||
|
for (int i = 0; i < emojiArray.length; i++) { |
||||
|
emojiArray[i] = emojis.keyAt(i); |
||||
|
} |
||||
|
return emojiArray; |
||||
|
} |
||||
|
} |
@ -0,0 +1,48 @@ |
|||||
|
package gr.thmmy.mthmmy.utils; |
||||
|
|
||||
|
import android.content.Context; |
||||
|
import android.view.View; |
||||
|
import android.view.ViewGroup; |
||||
|
import android.widget.BaseAdapter; |
||||
|
import android.widget.ImageView; |
||||
|
|
||||
|
public class ImageKeyboardAdapter extends BaseAdapter { |
||||
|
|
||||
|
private Context context; |
||||
|
private int[] emojiIds; |
||||
|
|
||||
|
public ImageKeyboardAdapter(Context context, int[] emojiIds) { |
||||
|
this.context = context; |
||||
|
this.emojiIds = emojiIds; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public int getCount() { |
||||
|
return emojiIds.length; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public Object getItem(int position) { |
||||
|
return null; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public long getItemId(int position) { |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public View getView(int position, View convertView, ViewGroup parent) { |
||||
|
ImageView emoji; |
||||
|
if (convertView == null) { |
||||
|
emoji = new ImageView(context); |
||||
|
emoji.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); |
||||
|
emoji.setScaleType(ImageView.ScaleType.CENTER_CROP); |
||||
|
emoji.setPadding(8, 8, 8, 8); |
||||
|
} else { |
||||
|
emoji = (ImageView) convertView; |
||||
|
} |
||||
|
emoji.setImageResource(emojiIds[position]); |
||||
|
return emoji; |
||||
|
} |
||||
|
} |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 243 B |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 9.6 KiB |
After Width: | Height: | Size: 7.2 KiB |
After Width: | Height: | Size: 904 B |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 199 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 952 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 708 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 969 B |
After Width: | Height: | Size: 291 B |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 275 B |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 2.8 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 4.8 KiB |
After Width: | Height: | Size: 1012 B |
After Width: | Height: | Size: 584 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 175 B |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1016 B |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1020 B |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 759 B |
After Width: | Height: | Size: 11 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 4.7 KiB |
After Width: | Height: | Size: 189 B |
After Width: | Height: | Size: 359 B |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 159 B |
After Width: | Height: | Size: 234 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 573 B |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 753 B |
After Width: | Height: | Size: 761 B |
After Width: | Height: | Size: 1019 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 482 B |
After Width: | Height: | Size: 8.9 KiB |
After Width: | Height: | Size: 4.3 KiB |
After Width: | Height: | Size: 417 B |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.9 KiB |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 901 B |
After Width: | Height: | Size: 552 B |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 777 B |
After Width: | Height: | Size: 834 B |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 131 B |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 525 B |
After Width: | Height: | Size: 6.4 KiB |