abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Keyboard2.java
blob: ce2f011c5ad40c198db5ffe1a41a89c36a9198ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package juloo.keyboard2;

import android.inputmethodservice.InputMethodService;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;

public class Keyboard2 extends InputMethodService
{
	public static final String		TAG = "Keyboard_2.0";

	private KeyboardData	_keyboardData;
	private Keyboard2View	_inputView;

	@Override
	public void				onCreate()
	{
		super.onCreate();
		_keyboardData = new KeyboardData(getResources().getXml(R.xml.azerty));
	}

	@Override
	public View				onCreateInputView()
	{
		_inputView = (Keyboard2View)getLayoutInflater().inflate(R.layout.input, null);
		_inputView.setKeyboard(this, _keyboardData);
		return (_inputView);
	}

	public void				handleKeyUp(KeyValue key)
	{
		int			eventCode = key.getEventCode();

		switch (eventCode)
		{
		case KeyValue.EVENT_NONE:
			sendKeyChar(key.getChar());
			break ;
		case KeyValue.EVENT_DELETE:
			getCurrentInputConnection().deleteSurroundingText(0, 1);
			break ;
		case KeyValue.EVENT_BACKSPACE:
			getCurrentInputConnection().deleteSurroundingText(1, 0);
			break ;
		default:
			getCurrentInputConnection().sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, eventCode));
			getCurrentInputConnection().sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, eventCode));
			break ;
		}
	}

	public static void		log(String str)
	{
		Log.d(TAG, str);
	}
}