mirror of
				https://github.com/SimpleMobileTools/Simple-Keyboard.git
				synced 2025-06-05 21:49:26 +02:00 
			
		
		
		
	Merge pull request #122 from suttod/main
Add cleanly numeric and phone keyboards
This commit is contained in:
		@@ -28,6 +28,8 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
 | 
			
		||||
    private val KEYBOARD_LETTERS = 0
 | 
			
		||||
    private val KEYBOARD_SYMBOLS = 1
 | 
			
		||||
    private val KEYBOARD_SYMBOLS_SHIFT = 2
 | 
			
		||||
    private val KEYBOARD_NUMBERS = 3
 | 
			
		||||
    private val KEYBOARD_PHONE = 4
 | 
			
		||||
 | 
			
		||||
    private var keyboard: MyKeyboard? = null
 | 
			
		||||
    private var keyboardView: MyKeyboardView? = null
 | 
			
		||||
@@ -220,7 +222,15 @@ class SimpleKeyboardIME : InputMethodService(), MyKeyboardView.OnKeyboardActionL
 | 
			
		||||
 | 
			
		||||
    private fun getKeyBoard(): MyKeyboard {
 | 
			
		||||
        val keyboardXml = when (inputTypeClass) {
 | 
			
		||||
            TYPE_CLASS_NUMBER, TYPE_CLASS_DATETIME, TYPE_CLASS_PHONE -> {
 | 
			
		||||
            TYPE_CLASS_NUMBER -> {
 | 
			
		||||
                keyboardMode = KEYBOARD_NUMBERS
 | 
			
		||||
                R.xml.keys_numbers
 | 
			
		||||
            }
 | 
			
		||||
            TYPE_CLASS_PHONE -> {
 | 
			
		||||
                keyboardMode = KEYBOARD_PHONE
 | 
			
		||||
                R.xml.keys_phone
 | 
			
		||||
            }
 | 
			
		||||
            TYPE_CLASS_DATETIME -> {
 | 
			
		||||
                keyboardMode = KEYBOARD_SYMBOLS
 | 
			
		||||
                R.xml.keys_symbols
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										71
									
								
								app/src/main/res/xml/keys_numbers.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								app/src/main/res/xml/keys_numbers.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,71 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<Keyboard xmlns:app="http://schemas.android.com/apk/res-auto">
 | 
			
		||||
    <Row>
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="1"
 | 
			
		||||
            app:keyEdgeFlags="left"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="2"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="3"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyIcon="@drawable/ic_clear_vector"
 | 
			
		||||
            app:code="-5"
 | 
			
		||||
            app:isRepeatable="true"
 | 
			
		||||
            app:keyEdgeFlags="right"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
    </Row>
 | 
			
		||||
    <Row>
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="4"
 | 
			
		||||
            app:keyEdgeFlags="left"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="5"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="6"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="-"
 | 
			
		||||
            app:keyEdgeFlags="right"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
    </Row>
 | 
			
		||||
    <Row>
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="7"
 | 
			
		||||
            app:keyEdgeFlags="left"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="8"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="9"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="␣"
 | 
			
		||||
            app:code="32"
 | 
			
		||||
            app:keyEdgeFlags="right"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
    </Row>
 | 
			
		||||
    <Row>
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel=","
 | 
			
		||||
            app:keyEdgeFlags="left"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="0"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="."
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyIcon="@drawable/ic_enter_vector"
 | 
			
		||||
            app:code="-4"
 | 
			
		||||
            app:keyEdgeFlags="right"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
    </Row>
 | 
			
		||||
</Keyboard>
 | 
			
		||||
							
								
								
									
										73
									
								
								app/src/main/res/xml/keys_phone.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								app/src/main/res/xml/keys_phone.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,73 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<Keyboard xmlns:app="http://schemas.android.com/apk/res-auto">
 | 
			
		||||
    <Row>
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="1"
 | 
			
		||||
            app:keyEdgeFlags="left"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="2"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="3"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyIcon="@drawable/ic_clear_vector"
 | 
			
		||||
            app:code="-5"
 | 
			
		||||
            app:isRepeatable="true"
 | 
			
		||||
            app:keyEdgeFlags="right"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
    </Row>
 | 
			
		||||
    <Row>
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="4"
 | 
			
		||||
            app:keyEdgeFlags="left"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="5"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="6"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyEdgeFlags="right"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
    </Row>
 | 
			
		||||
    <Row>
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="7"
 | 
			
		||||
            app:keyEdgeFlags="left"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="8"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="9"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="abc"
 | 
			
		||||
            app:code="-2"
 | 
			
		||||
            app:keyEdgeFlags="right"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
    </Row>
 | 
			
		||||
    <Row>
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="*"
 | 
			
		||||
            app:keyEdgeFlags="left"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="0"
 | 
			
		||||
            app:topSmallNumber="+"
 | 
			
		||||
            app:popupKeyboard="@xml/keyboard_popup_template"
 | 
			
		||||
            app:popupCharacters="+-,."
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyLabel="#"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
        <Key
 | 
			
		||||
            app:keyIcon="@drawable/ic_enter_vector"
 | 
			
		||||
            app:code="-4"
 | 
			
		||||
            app:keyEdgeFlags="right"
 | 
			
		||||
            app:keyWidth="25%p" />
 | 
			
		||||
    </Row>
 | 
			
		||||
</Keyboard>
 | 
			
		||||
		Reference in New Issue
	
	Block a user