forked from extern/Unexpected-Keyboard
Auto-format Java and XML files
Use xmllint. Re-indent Java files using spaces.
This commit is contained in:
parent
988d8db7e8
commit
1cfecbdf48
@ -1,38 +1,18 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="juloo.keyboard2" android:versionCode="13" android:versionName="1.10.0" android:hardwareAccelerated="false">
|
||||||
package="juloo.keyboard2"
|
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="30"/>
|
||||||
android:versionCode="13"
|
<application android:label="@string/app_name" android:allowBackup="true" android:icon="@drawable/ic_launcher" android:hardwareAccelerated="false">
|
||||||
android:versionName="1.10.0"
|
<service android:name="juloo.keyboard2.Keyboard2" android:label="@string/app_name" android:permission="android.permission.BIND_INPUT_METHOD">
|
||||||
android:hardwareAccelerated="false">
|
<intent-filter>
|
||||||
|
<action android:name="android.view.InputMethod"/>
|
||||||
<uses-sdk android:minSdkVersion="4"
|
</intent-filter>
|
||||||
android:targetSdkVersion="30" />
|
<meta-data android:name="android.view.im" android:resource="@xml/method"/>
|
||||||
|
</service>
|
||||||
<application android:label="@string/app_name"
|
<activity android:name="juloo.keyboard2.SettingsActivity" android:icon="@drawable/ic_launcher" android:label="@string/settings_activity_label">
|
||||||
android:allowBackup="true"
|
<intent-filter>
|
||||||
android:icon="@drawable/ic_launcher"
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
android:hardwareAccelerated="false">
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
<service android:name="juloo.keyboard2.Keyboard2"
|
</application>
|
||||||
android:label="@string/app_name"
|
<uses-permission android:name="android.permission.VIBRATE"/>
|
||||||
android:permission="android.permission.BIND_INPUT_METHOD">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.view.InputMethod" />
|
|
||||||
</intent-filter>
|
|
||||||
<meta-data android:name="android.view.im"
|
|
||||||
android:resource="@xml/method" />
|
|
||||||
</service>
|
|
||||||
|
|
||||||
<activity android:name="juloo.keyboard2.SettingsActivity"
|
|
||||||
android:icon="@drawable/ic_launcher"
|
|
||||||
android:label="@string/settings_activity_label">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
</application>
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.VIBRATE" />
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -1,38 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:hardwareAccelerated="false">
|
||||||
android:orientation="vertical"
|
<juloo.keyboard2.EmojiGroupButtonsBar android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
|
||||||
android:hardwareAccelerated="false">
|
<juloo.keyboard2.EmojiGridView android:id="@+id/emoji_grid" android:background="@color/bg" android:layout_width="fill_parent" android:layout_height="@dimen/emoji_grid_height"/>
|
||||||
<juloo.keyboard2.EmojiGroupButtonsBar
|
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content">
|
||||||
android:orientation="horizontal"
|
<juloo.keyboard2.EmojiKeyButton style="@style/emojiKeyButton" key="switch_back_emoji"/>
|
||||||
android:layout_width="fill_parent"
|
<juloo.keyboard2.EmojiKeyButton style="@style/emojiKeyButton" android:layout_weight="4" key="space"/>
|
||||||
android:layout_height="wrap_content" />
|
<juloo.keyboard2.EmojiKeyButton style="@style/emojiKeyButton" key="backspace"/>
|
||||||
<juloo.keyboard2.EmojiGridView
|
<juloo.keyboard2.EmojiKeyButton style="@style/emojiKeyButton" key="enter"/>
|
||||||
android:id="@+id/emoji_grid"
|
</LinearLayout>
|
||||||
android:background="@color/bg"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="@dimen/emoji_grid_height"
|
|
||||||
/>
|
|
||||||
<LinearLayout
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="fill_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
>
|
|
||||||
<juloo.keyboard2.EmojiKeyButton
|
|
||||||
style="@style/emojiKeyButton"
|
|
||||||
key="switch_back_emoji"
|
|
||||||
/>
|
|
||||||
<juloo.keyboard2.EmojiKeyButton
|
|
||||||
style="@style/emojiKeyButton"
|
|
||||||
android:layout_weight="4"
|
|
||||||
key="space"
|
|
||||||
/>
|
|
||||||
<juloo.keyboard2.EmojiKeyButton
|
|
||||||
style="@style/emojiKeyButton"
|
|
||||||
key="backspace"
|
|
||||||
/>
|
|
||||||
<juloo.keyboard2.EmojiKeyButton
|
|
||||||
style="@style/emojiKeyButton"
|
|
||||||
key="enter"
|
|
||||||
/>
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -1,5 +1,2 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<juloo.keyboard2.Keyboard2View xmlns:android="http://schemas.android.com/apk/res/android"
|
<juloo.keyboard2.Keyboard2View xmlns:android="http://schemas.android.com/apk/res/android" android:background="@color/bg" android:hardwareAccelerated="false"/>
|
||||||
android:background="@color/bg"
|
|
||||||
android:hardwareAccelerated="false"
|
|
||||||
/>
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="horizontal_margin">12dp</dimen>
|
<dimen name="horizontal_margin">12dp</dimen>
|
||||||
<dimen name="margin_bottom">3dp</dimen>
|
<dimen name="margin_bottom">3dp</dimen>
|
||||||
<dimen name="key_padding">3dp</dimen>
|
<dimen name="key_padding">3dp</dimen>
|
||||||
<dimen name="key_height">36dp</dimen>
|
<dimen name="key_height">36dp</dimen>
|
||||||
<dimen name="label_text_size">18dp</dimen>
|
<dimen name="label_text_size">18dp</dimen>
|
||||||
<dimen name="sublabel_text_size">11dp</dimen>
|
<dimen name="sublabel_text_size">11dp</dimen>
|
||||||
<dimen name="emoji_type_button_height">48dp</dimen>
|
<dimen name="emoji_type_button_height">48dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
<item>azerty</item>
|
<item>azerty</item>
|
||||||
<item>qwerty</item>
|
<item>qwerty</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string name="pref_accents_default">1</string>
|
<string name="pref_accents_default">1</string>
|
||||||
|
|
||||||
<string-array name="pref_accents_entries">
|
<string-array name="pref_accents_entries">
|
||||||
<item>@string/pref_accents_e_all_installed</item>
|
<item>@string/pref_accents_e_all_installed</item>
|
||||||
<item>@string/pref_accents_e_selected</item>
|
<item>@string/pref_accents_e_selected</item>
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<item name="bg" type="color">#1B1B1B</item>
|
<item name="bg" type="color">#1B1B1B</item>
|
||||||
<item name="key_bg" type="color">#303030</item>
|
<item name="key_bg" type="color">#303030</item>
|
||||||
<item name="key_down_bg" type="color">#1B1B1B</item>
|
<item name="key_down_bg" type="color">#1B1B1B</item>
|
||||||
<item name="key_label" type="color">#FFFFFF</item>
|
<item name="key_label" type="color">#FFFFFF</item>
|
||||||
<item name="key_label_locked" type="color">#229933</item>
|
<item name="key_label_locked" type="color">#229933</item>
|
||||||
<item name="key_label_activated" type="color">#226b99</item>
|
<item name="key_label_activated" type="color">#226b99</item>
|
||||||
<item name="key_sub_label" type="color">#A0A0A0</item>
|
<item name="key_sub_label" type="color">#A0A0A0</item>
|
||||||
<item name="emoji_button_bg" type="color">#202020</item>
|
<item name="emoji_button_bg" type="color">#202020</item>
|
||||||
<item name="emoji_color" type="color">#FFFFFF</item>
|
<item name="emoji_color" type="color">#FFFFFF</item>
|
||||||
<item name="emoji_key_bg" type="color">@color/emoji_button_bg</item>
|
<item name="emoji_key_bg" type="color">@color/emoji_button_bg</item>
|
||||||
<item name="emoji_key_text" type="color">@color/key_label</item>
|
<item name="emoji_key_text" type="color">@color/key_label</item>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<dimen name="horizontal_margin">3dp</dimen>
|
<dimen name="horizontal_margin">3dp</dimen>
|
||||||
<dimen name="margin_top">3dp</dimen>
|
<dimen name="margin_top">3dp</dimen>
|
||||||
<dimen name="margin_bottom">7dp</dimen>
|
<dimen name="margin_bottom">7dp</dimen>
|
||||||
<dimen name="key_padding">2dp</dimen>
|
<dimen name="key_padding">2dp</dimen>
|
||||||
<dimen name="key_vertical_interval">2dp</dimen>
|
<dimen name="key_vertical_interval">2dp</dimen>
|
||||||
<dimen name="key_horizontal_interval">2dp</dimen>
|
<dimen name="key_horizontal_interval">2dp</dimen>
|
||||||
<dimen name="key_height">51dp</dimen>
|
<dimen name="key_height">51dp</dimen>
|
||||||
<dimen name="key_round">5dp</dimen>
|
<dimen name="key_round">5dp</dimen>
|
||||||
<dimen name="label_text_size">18dp</dimen>
|
<dimen name="label_text_size">18dp</dimen>
|
||||||
<dimen name="sublabel_text_size">12dp</dimen>
|
<dimen name="sublabel_text_size">12dp</dimen>
|
||||||
<dimen name="emoji_type_button_height">56dp</dimen>
|
<dimen name="emoji_type_button_height">56dp</dimen>
|
||||||
<dimen name="emoji_grid_height">250dp</dimen>
|
<dimen name="emoji_grid_height">250dp</dimen>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="app_name">Unexpected Keyboard</string>
|
||||||
<string name="app_name">Unexpected Keyboard</string>
|
<string name="settings_activity_label">Unexpected Keyboard Settings</string>
|
||||||
|
|
||||||
<string name="settings_activity_label">Unexpected Keyboard Settings</string>
|
|
||||||
|
|
||||||
<string name="subtype_label">%s</string>
|
<string name="subtype_label">%s</string>
|
||||||
|
<string name="pref_category_layout">Layout</string>
|
||||||
<string name="pref_category_layout">Layout</string>
|
|
||||||
<string name="pref_layout_title">Change keyboard layout</string>
|
<string name="pref_layout_title">Change keyboard layout</string>
|
||||||
<string name="pref_layout_summary">%s</string>
|
<string name="pref_layout_summary">%s</string>
|
||||||
<string-array name="pref_layout_entries">
|
<string-array name="pref_layout_entries">
|
||||||
@ -15,37 +11,33 @@
|
|||||||
<item>Azerty</item>
|
<item>Azerty</item>
|
||||||
<item>Qwerty</item>
|
<item>Qwerty</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string name="pref_accents_title">Accents</string>
|
<string name="pref_accents_title">Accents</string>
|
||||||
<string name="pref_accents_summary">%s</string>
|
<string name="pref_accents_summary">%s</string>
|
||||||
<string name="pref_accents_e_all_installed">Show accents for all the installed languages</string>
|
<string name="pref_accents_e_all_installed">Show accents for all the installed languages</string>
|
||||||
<string name="pref_accents_e_selected">Show accents for the selected language</string>
|
<string name="pref_accents_e_selected">Show accents for the selected language</string>
|
||||||
<string name="pref_accents_e_all">Show every accents</string>
|
<string name="pref_accents_e_all">Show every accents</string>
|
||||||
<string name="pref_accents_e_none">Hide accents</string>
|
<string name="pref_accents_e_none">Hide accents</string>
|
||||||
|
<string name="pref_category_typing">Typing</string>
|
||||||
<string name="pref_category_typing">Typing</string>
|
<string name="pref_preci_title">Precision</string>
|
||||||
<string name="pref_preci_title">Precision</string>
|
<string name="pref_preci_summary">Distance of corner values (%spx)</string>
|
||||||
<string name="pref_preci_summary">Distance of corner values (%spx)</string>
|
<string name="pref_long_timeout_title">Long press timeout</string>
|
||||||
<string name="pref_long_timeout_title">Long press timeout</string>
|
<string name="pref_long_timeout_summary">%sms</string>
|
||||||
<string name="pref_long_timeout_summary">%sms</string>
|
<string name="pref_long_interval_title">Long press interval</string>
|
||||||
<string name="pref_long_interval_title">Long press interval</string>
|
<string name="pref_long_interval_summary">%sms</string>
|
||||||
<string name="pref_long_interval_summary">%sms</string>
|
<string name="pref_category_vibrate">Vibration</string>
|
||||||
|
<string name="pref_vibrate_title">Vibration</string>
|
||||||
<string name="pref_category_vibrate">Vibration</string>
|
<string name="pref_vibrate_summary">Enable/Disable vibrations on key down</string>
|
||||||
<string name="pref_vibrate_title">Vibration</string>
|
<string name="pref_vibrate_duration_title">Duration</string>
|
||||||
<string name="pref_vibrate_summary">Enable/Disable vibrations on key down</string>
|
<string name="pref_vibrate_duration_summary">%sms</string>
|
||||||
<string name="pref_vibrate_duration_title">Duration</string>
|
|
||||||
<string name="pref_vibrate_duration_summary">%sms</string>
|
|
||||||
<string name="pref_precise_repeat_title">Precise cursor movements</string>
|
<string name="pref_precise_repeat_title">Precise cursor movements</string>
|
||||||
<string name="pref_precise_repeat_summary">Modulate the speed of movements by swiping more or less</string>
|
<string name="pref_precise_repeat_summary">Modulate the speed of movements by swiping more or less</string>
|
||||||
|
<string name="pref_category_style">Style</string>
|
||||||
<string name="pref_category_style">Style</string>
|
<string name="pref_margin_bottom_title">Margin bottom</string>
|
||||||
<string name="pref_margin_bottom_title">Margin bottom</string>
|
<string name="pref_margin_bottom_summary">%sdp</string>
|
||||||
<string name="pref_margin_bottom_summary">%sdp</string>
|
<string name="pref_key_height_title">Key height</string>
|
||||||
<string name="pref_key_height_title">Key height</string>
|
<string name="pref_key_height_summary">%sdp</string>
|
||||||
<string name="pref_key_height_summary">%sdp</string>
|
<string name="pref_horizontal_margin_title">Horizontal margin</string>
|
||||||
<string name="pref_horizontal_margin_title">Horizontal margin</string>
|
<string name="pref_horizontal_margin_summary">%sdp</string>
|
||||||
<string name="pref_horizontal_margin_summary">%sdp</string>
|
|
||||||
<string name="pref_character_size_title">Label size</string>
|
<string name="pref_character_size_title">Label size</string>
|
||||||
<string name="pref_character_size_summary">Size of characters displayed on the keyboard (%.2fx)</string>
|
<string name="pref_character_size_summary">Size of characters displayed on the keyboard (%.2fx)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<style name="emojiTypeButton">
|
<style name="emojiTypeButton">
|
||||||
<item name="android:padding">1px</item>
|
<item name="android:padding">1px</item>
|
||||||
<item name="android:gravity">center</item>
|
<item name="android:gravity">center</item>
|
||||||
<item name="android:minHeight">@dimen/label_text_size</item>
|
<item name="android:minHeight">@dimen/label_text_size</item>
|
||||||
<item name="android:background">@color/emoji_button_bg</item>
|
<item name="android:background">@color/emoji_button_bg</item>
|
||||||
<item name="android:textColor">@color/emoji_key_text</item>
|
<item name="android:textColor">@color/emoji_key_text</item>
|
||||||
<item name="android:textSize">@dimen/label_text_size</item>
|
<item name="android:textSize">@dimen/label_text_size</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="emojiKeyButton">
|
<style name="emojiKeyButton">
|
||||||
<item name="android:layout_width">0px</item>
|
<item name="android:layout_width">0px</item>
|
||||||
<item name="android:layout_height">wrap_content</item>
|
<item name="android:layout_height">wrap_content</item>
|
||||||
<item name="android:layout_weight">1</item>
|
<item name="android:layout_weight">1</item>
|
||||||
<item name="android:padding">0px</item>
|
<item name="android:padding">0px</item>
|
||||||
<item name="android:background">@color/emoji_key_bg</item>
|
<item name="android:background">@color/emoji_key_bg</item>
|
||||||
<item name="android:textColor">@color/emoji_key_text</item>
|
<item name="android:textColor">@color/emoji_key_text</item>
|
||||||
<item name="android:textSize">@dimen/label_text_size</item>
|
<item name="android:textSize">@dimen/label_text_size</item>
|
||||||
</style>
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<keyboard>
|
<keyboard>
|
||||||
<row>
|
<row>
|
||||||
<key key0="a" key1="esc" key2="1" key3="&" />
|
<key key0="a" key1="esc" key2="1" key3="&"/>
|
||||||
<key key0="z" key2="2" key4="~" />
|
<key key0="z" key2="2" key4="~"/>
|
||||||
<key key0="e" key2="3" key3=""" key4="\#" />
|
<key key0="e" key2="3" key3=""" key4="\#"/>
|
||||||
<key key0="r" key2="4" key3="'" />
|
<key key0="r" key2="4" key3="'"/>
|
||||||
<key key0="t" key2="5" key3="(" key4=")" />
|
<key key0="t" key2="5" key3="(" key4=")"/>
|
||||||
<key key0="y" key2="6" key3="-" key4="|" />
|
<key key0="y" key2="6" key3="-" key4="|"/>
|
||||||
<key key0="u" key2="7" key4="`" />
|
<key key0="u" key2="7" key4="`"/>
|
||||||
<key key0="i" key2="8" key3="_" key4="\\" />
|
<key key0="i" key2="8" key3="_" key4="\\"/>
|
||||||
<key key0="o" key2="9" />
|
<key key0="o" key2="9"/>
|
||||||
<key key0="p" key2="0" key4="\@" />
|
<key key0="p" key2="0" key4="\@"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<key key0="q" key1="tab" />
|
<key key0="q" key1="tab"/>
|
||||||
<key key0="s" key1="accent_ring" />
|
<key key0="s" key1="accent_ring"/>
|
||||||
<key key0="d" key1="accent_grave" key3="accent_aigu" />
|
<key key0="d" key1="accent_grave" key3="accent_aigu"/>
|
||||||
<key key0="f" key3="{" key4="}" />
|
<key key0="f" key3="{" key4="}"/>
|
||||||
<key key0="g" key3="[" key4="]" />
|
<key key0="g" key3="[" key4="]"/>
|
||||||
<key key0="h" key3="=" key4="+" />
|
<key key0="h" key3="=" key4="+"/>
|
||||||
<key key0="j" key1="accent_trema" key2="accent_circonflexe" key3="^" />
|
<key key0="j" key1="accent_trema" key2="accent_circonflexe" key3="^"/>
|
||||||
<key key0="k" key2="€" key3="$" key4="£" />
|
<key key0="k" key2="€" key3="$" key4="£"/>
|
||||||
<key key0="l" key2="%" />
|
<key key0="l" key2="%"/>
|
||||||
<key key0="m" key4="*" />
|
<key key0="m" key4="*"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<key width="2.0" key0="shift" />
|
<key width="2.0" key0="shift"/>
|
||||||
<key key0="w" key3="<" key4=">" />
|
<key key0="w" key3="<" key4=">"/>
|
||||||
<key key0="x" />
|
<key key0="x"/>
|
||||||
<key key0="c" key1="accent_cedille" key3="," key4="\?" />
|
<key key0="c" key1="accent_cedille" key3="," key4="\?"/>
|
||||||
<key key0="v" key3=";" key4="." />
|
<key key0="v" key3=";" key4="."/>
|
||||||
<key key0="b" key3=":" key4="/" />
|
<key key0="b" key3=":" key4="/"/>
|
||||||
<key key0="n" key1="accent_tilde" key2="§" key4="!" />
|
<key key0="n" key1="accent_tilde" key2="§" key4="!"/>
|
||||||
<key width="2.0" key0="backspace" key2="delete" />
|
<key width="2.0" key0="backspace" key2="delete"/>
|
||||||
</row>
|
</row>
|
||||||
<row height="0.95">
|
<row height="0.95">
|
||||||
<key width="1.8" key0="ctrl" key3="switch_numeric" />
|
<key width="1.8" key0="ctrl" key3="switch_numeric"/>
|
||||||
<key width="1.2" key0="alt" key1="fn" key2="change_method" key3="switch_emoji" key4="config" />
|
<key width="1.2" key0="alt" key1="fn" key2="change_method" key3="switch_emoji" key4="config"/>
|
||||||
<key width="4.0" key0="space" />
|
<key width="4.0" key0="space"/>
|
||||||
<key width="1.2" key1="up" key2="right" key3="left" key4="down" />
|
<key width="1.2" key1="up" key2="right" key3="left" key4="down"/>
|
||||||
<key width="1.8" key0="enter" />
|
<key width="1.8" key0="enter"/>
|
||||||
</row>
|
</row>
|
||||||
</keyboard>
|
</keyboard>
|
||||||
|
@ -1,40 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<input-method xmlns:android="http://schemas.android.com/apk/res/android"
|
<input-method xmlns:android="http://schemas.android.com/apk/res/android" android:settingsActivity="juloo.keyboard2.SettingsActivity" android:supportsSwitchingToNextInputMethod="true">
|
||||||
android:settingsActivity="juloo.keyboard2.SettingsActivity"
|
<subtype android:label="@string/subtype_label" android:languageTag="en" android:imeSubtypeLocale="en_US" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty"/>
|
||||||
android:supportsSwitchingToNextInputMethod="true">
|
<subtype android:label="@string/subtype_label" android:languageTag="fr" android:imeSubtypeLocale="fr_FR" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=azerty,accents=grave|aigu|circonflexe|cedille|trema"/>
|
||||||
<subtype android:label="@string/subtype_label"
|
<subtype android:label="@string/subtype_label" android:languageTag="es" android:imeSubtypeLocale="es_ES" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,accents=aigu|tilde|trema"/>
|
||||||
android:languageTag="en"
|
<subtype android:label="@string/subtype_label" android:languageTag="it" android:imeSubtypeLocale="it_IT" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,accents=grave|aigu"/>
|
||||||
android:imeSubtypeLocale="en_US"
|
<subtype android:label="@string/subtype_label" android:languageTag="sv" android:imeSubtypeLocale="sv_SE" android:imeSubtypeMode="keyboard" android:isAsciiCapable="true" android:imeSubtypeExtraValue="default_layout=qwerty,accents=aigu|trema|ring"/>
|
||||||
android:imeSubtypeMode="keyboard"
|
|
||||||
android:isAsciiCapable="true"
|
|
||||||
android:imeSubtypeExtraValue="default_layout=qwerty"
|
|
||||||
/>
|
|
||||||
<subtype android:label="@string/subtype_label"
|
|
||||||
android:languageTag="fr"
|
|
||||||
android:imeSubtypeLocale="fr_FR"
|
|
||||||
android:imeSubtypeMode="keyboard"
|
|
||||||
android:isAsciiCapable="true"
|
|
||||||
android:imeSubtypeExtraValue="default_layout=azerty,accents=grave|aigu|circonflexe|cedille|trema"
|
|
||||||
/>
|
|
||||||
<subtype android:label="@string/subtype_label"
|
|
||||||
android:languageTag="es"
|
|
||||||
android:imeSubtypeLocale="es_ES"
|
|
||||||
android:imeSubtypeMode="keyboard"
|
|
||||||
android:isAsciiCapable="true"
|
|
||||||
android:imeSubtypeExtraValue="default_layout=qwerty,accents=aigu|tilde|trema"
|
|
||||||
/>
|
|
||||||
<subtype android:label="@string/subtype_label"
|
|
||||||
android:languageTag="it"
|
|
||||||
android:imeSubtypeLocale="it_IT"
|
|
||||||
android:imeSubtypeMode="keyboard"
|
|
||||||
android:isAsciiCapable="true"
|
|
||||||
android:imeSubtypeExtraValue="default_layout=qwerty,accents=grave|aigu"
|
|
||||||
/>
|
|
||||||
<subtype android:label="@string/subtype_label"
|
|
||||||
android:languageTag="sv"
|
|
||||||
android:imeSubtypeLocale="sv_SE"
|
|
||||||
android:imeSubtypeMode="keyboard"
|
|
||||||
android:isAsciiCapable="true"
|
|
||||||
android:imeSubtypeExtraValue="default_layout=qwerty,accents=aigu|trema|ring"
|
|
||||||
/>
|
|
||||||
</input-method>
|
</input-method>
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<keyboard>
|
<keyboard>
|
||||||
<row>
|
<row>
|
||||||
<key width="0.75" key0="esc" key2="~" key4="!" />
|
<key width="0.75" key0="esc" key2="~" key4="!"/>
|
||||||
<key width="0.75" key0="(" key2="[" key4="{" />
|
<key width="0.75" key0="(" key2="[" key4="{"/>
|
||||||
<key key0="7" key3="<" key4=">" />
|
<key key0="7" key3="<" key4=">"/>
|
||||||
<key key0="8" key2="∞" />
|
<key key0="8" key2="∞"/>
|
||||||
<key key0="9" key2="π" />
|
<key key0="9" key2="π"/>
|
||||||
<key width="0.75" key0="*" key1="√" key2="×" />
|
<key width="0.75" key0="*" key1="√" key2="×"/>
|
||||||
<key width="0.75" key0="/" key1="%" key3="÷" />
|
<key width="0.75" key0="/" key1="%" key3="÷"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<key width="0.75" key0="tab" key1=";" key2="|" key4="\\" />
|
<key width="0.75" key0="tab" key1=";" key2="|" key4="\\"/>
|
||||||
<key width="0.75" key0=")" key2="]" key4="}" />
|
<key width="0.75" key0=")" key2="]" key4="}"/>
|
||||||
<key key0="4" />
|
<key key0="4"/>
|
||||||
<key key0="5" key1="up" key2="right" key3="left" key4="down" />
|
<key key0="5" key1="up" key2="right" key3="left" key4="down"/>
|
||||||
<key key0="6" />
|
<key key0="6"/>
|
||||||
<key width="0.75" key0="+" key1="Σ" key2="$" />
|
<key width="0.75" key0="+" key1="Σ" key2="$"/>
|
||||||
<key width="0.75" key0="-" key2="^" />
|
<key width="0.75" key0="-" key2="^"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<key shift="0.35" width="1.15" key0="shift" key2="fn" key4="alt" />
|
<key shift="0.35" width="1.15" key0="shift" key2="fn" key4="alt"/>
|
||||||
<key key0="1" key1="superscript" key3="subscript" />
|
<key key0="1" key1="superscript" key3="subscript"/>
|
||||||
<key key0="2" />
|
<key key0="2"/>
|
||||||
<key key0="3" />
|
<key key0="3"/>
|
||||||
<key width="1.15" key0="backspace" key2="delete" />
|
<key width="1.15" key0="backspace" key2="delete"/>
|
||||||
</row>
|
</row>
|
||||||
<row height="0.95">
|
<row height="0.95">
|
||||||
<key width="1.5" key0="ctrl" key3="switch_text" />
|
<key width="1.5" key0="ctrl" key3="switch_text"/>
|
||||||
<key width="1.5" key0="0" />
|
<key width="1.5" key0="0"/>
|
||||||
<key width="0.75" key0="." key2="," />
|
<key width="0.75" key0="." key2=","/>
|
||||||
<key width="0.75" key0="space" key1=""" key2="'" key4="_" />
|
<key width="0.75" key0="space" key1=""" key2="'" key4="_"/>
|
||||||
<key width="1.5" key0="enter" key2="±" key3="=" />
|
<key width="1.5" key0="enter" key2="±" key3="="/>
|
||||||
</row>
|
</row>
|
||||||
</keyboard>
|
</keyboard>
|
||||||
|
@ -1,44 +1,44 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<keyboard>
|
<keyboard>
|
||||||
<row>
|
<row>
|
||||||
<key key0="q" key1="esc" key2="1" key3="~" key4="!" />
|
<key key0="q" key1="esc" key2="1" key3="~" key4="!"/>
|
||||||
<key key0="w" key2="2" key3="\@" />
|
<key key0="w" key2="2" key3="\@"/>
|
||||||
<key key0="e" key2="3" key3="\#" />
|
<key key0="e" key2="3" key3="\#"/>
|
||||||
<key key0="r" key2="4" key3="$" />
|
<key key0="r" key2="4" key3="$"/>
|
||||||
<key key0="t" key2="5" key3="%" />
|
<key key0="t" key2="5" key3="%"/>
|
||||||
<key key0="y" key2="6" key3="^" />
|
<key key0="y" key2="6" key3="^"/>
|
||||||
<key key0="u" key2="7" key3="&" />
|
<key key0="u" key2="7" key3="&"/>
|
||||||
<key key0="i" key2="8" key3="*" />
|
<key key0="i" key2="8" key3="*"/>
|
||||||
<key key0="o" key2="9" key3="(" key4=")" />
|
<key key0="o" key2="9" key3="(" key4=")"/>
|
||||||
<key key0="p" key2="0" />
|
<key key0="p" key2="0"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<key shift="0.5" key0="a" key1="tab" key2="`" />
|
<key shift="0.5" key0="a" key1="tab" key2="`"/>
|
||||||
<key key0="s" key1="accent_ring" />
|
<key key0="s" key1="accent_ring"/>
|
||||||
<key key0="d" key1="accent_grave" key3="accent_aigu" />
|
<key key0="d" key1="accent_grave" key3="accent_aigu"/>
|
||||||
<key key0="f" />
|
<key key0="f"/>
|
||||||
<key key0="g" key2="-" key3="_" />
|
<key key0="g" key2="-" key3="_"/>
|
||||||
<key key0="h" key2="=" key3="+" />
|
<key key0="h" key2="=" key3="+"/>
|
||||||
<key key0="j" key1="accent_trema" key2="accent_circonflexe" key4="}" key3="{" />
|
<key key0="j" key1="accent_trema" key2="accent_circonflexe" key4="}" key3="{"/>
|
||||||
<key key0="k" key4="]" key3="[" />
|
<key key0="k" key4="]" key3="["/>
|
||||||
<key key0="l" key2="|" key3="\\" />
|
<key key0="l" key2="|" key3="\\"/>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<key width="1.5" key0="shift" />
|
<key width="1.5" key0="shift"/>
|
||||||
<key key0="z" />
|
<key key0="z"/>
|
||||||
<key key0="x" />
|
<key key0="x"/>
|
||||||
<key key0="c" key1="accent_cedille" key2="<" key3="." />
|
<key key0="c" key1="accent_cedille" key2="<" key3="."/>
|
||||||
<key key0="v" key2=">" key3="," />
|
<key key0="v" key2=">" key3=","/>
|
||||||
<key key0="b" key2="\?" key3="/" />
|
<key key0="b" key2="\?" key3="/"/>
|
||||||
<key key0="n" key1="accent_tilde" key2=":" key3=";" />
|
<key key0="n" key1="accent_tilde" key2=":" key3=";"/>
|
||||||
<key key0="m" key2=""" key3="'" />
|
<key key0="m" key2=""" key3="'"/>
|
||||||
<key width="1.5" key0="backspace" key2="delete" />
|
<key width="1.5" key0="backspace" key2="delete"/>
|
||||||
</row>
|
</row>
|
||||||
<row height="0.95">
|
<row height="0.95">
|
||||||
<key width="1.8" key0="ctrl" key3="switch_numeric" />
|
<key width="1.8" key0="ctrl" key3="switch_numeric"/>
|
||||||
<key width="1.2" key0="alt" key1="fn" key2="change_method" key3="switch_emoji" key4="config" />
|
<key width="1.2" key0="alt" key1="fn" key2="change_method" key3="switch_emoji" key4="config"/>
|
||||||
<key width="4.0" key0="space" />
|
<key width="4.0" key0="space"/>
|
||||||
<key width="1.2" key1="up" key2="right" key3="left" key4="down" />
|
<key width="1.2" key1="up" key2="right" key3="left" key4="down"/>
|
||||||
<key width="1.8" key0="enter" />
|
<key width="1.8" key0="enter"/>
|
||||||
</row>
|
</row>
|
||||||
</keyboard>
|
</keyboard>
|
||||||
|
@ -1,102 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<PreferenceCategory android:title="@string/pref_category_layout">
|
<PreferenceCategory android:title="@string/pref_category_layout">
|
||||||
<ListPreference
|
<ListPreference android:key="layout" android:title="@string/pref_layout_title" android:summary="@string/pref_layout_summary" android:defaultValue="system" android:entries="@array/pref_layout_entries" android:entryValues="@array/pref_layout_values"/>
|
||||||
android:key="layout"
|
/>
|
||||||
android:title="@string/pref_layout_title"
|
<ListPreference android:key="accents" android:title="@string/pref_accents_title" android:summary="@string/pref_accents_summary" android:defaultValue="@string/pref_accents_default" android:entries="@array/pref_accents_entries" android:entryValues="@array/pref_accents_values"/>
|
||||||
android:summary="@string/pref_layout_summary"
|
</PreferenceCategory>
|
||||||
android:defaultValue="system"
|
<PreferenceCategory android:title="@string/pref_category_typing">
|
||||||
android:entries="@array/pref_layout_entries"
|
<juloo.common.SlideBarPreference android:key="sub_value_dist" android:title="@string/pref_preci_title" android:summary="@string/pref_preci_summary" android:defaultValue="10.0" min="5.0" max="25.0"/>
|
||||||
android:entryValues="@array/pref_layout_values" />
|
<juloo.common.IntSlideBarPreference android:key="longpress_timeout" android:title="@string/pref_long_timeout_title" android:summary="@string/pref_long_timeout_summary" android:defaultValue="600" min="50" max="2000"/>
|
||||||
/>
|
<juloo.common.IntSlideBarPreference android:key="longpress_interval" android:title="@string/pref_long_interval_title" android:summary="@string/pref_long_interval_summary" android:defaultValue="25" min="5" max="100"/>
|
||||||
<ListPreference
|
<CheckBoxPreference android:key="precise_repeat" android:title="@string/pref_precise_repeat_title" android:summary="@string/pref_precise_repeat_summary" android:defaultValue="true"/>
|
||||||
android:key="accents"
|
</PreferenceCategory>
|
||||||
android:title="@string/pref_accents_title"
|
<PreferenceCategory android:title="@string/pref_category_vibrate">
|
||||||
android:summary="@string/pref_accents_summary"
|
<CheckBoxPreference android:key="vibrate_enabled" android:title="@string/pref_vibrate_title" android:summary="@string/pref_vibrate_summary" android:defaultValue="true"/>
|
||||||
android:defaultValue="@string/pref_accents_default"
|
<juloo.common.IntSlideBarPreference android:key="vibrate_duration" android:title="@string/pref_vibrate_duration_title" android:summary="@string/pref_vibrate_duration_summary" android:defaultValue="20" min="5" max="50"/>
|
||||||
android:entries="@array/pref_accents_entries"
|
</PreferenceCategory>
|
||||||
android:entryValues="@array/pref_accents_values" />
|
<PreferenceCategory android:title="@string/pref_category_style">
|
||||||
</PreferenceCategory>
|
<juloo.common.IntSlideBarPreference android:key="margin_bottom" android:title="@string/pref_margin_bottom_title" android:summary="@string/pref_margin_bottom_summary" android:defaultValue="5" min="0" max="100"/>
|
||||||
<PreferenceCategory android:title="@string/pref_category_typing">
|
<juloo.common.IntSlideBarPreference android:key="key_height" android:title="@string/pref_key_height_title" android:summary="@string/pref_key_height_summary" android:defaultValue="50" min="30" max="90"/>
|
||||||
<juloo.common.SlideBarPreference
|
<juloo.common.IntSlideBarPreference android:key="horizontal_margin" android:title="@string/pref_horizontal_margin_title" android:summary="@string/pref_horizontal_margin_summary" android:defaultValue="3" min="0" max="20"/>
|
||||||
android:key="sub_value_dist"
|
<juloo.common.SlideBarPreference android:key="character_size" android:title="@string/pref_character_size_title" android:summary="@string/pref_character_size_summary" android:defaultValue="1.0" min="0.8" max="1.2"/>
|
||||||
android:title="@string/pref_preci_title"
|
</PreferenceCategory>
|
||||||
android:summary="@string/pref_preci_summary"
|
|
||||||
android:defaultValue="10.0"
|
|
||||||
min="5.0"
|
|
||||||
max="25.0"
|
|
||||||
/>
|
|
||||||
<juloo.common.IntSlideBarPreference
|
|
||||||
android:key="longpress_timeout"
|
|
||||||
android:title="@string/pref_long_timeout_title"
|
|
||||||
android:summary="@string/pref_long_timeout_summary"
|
|
||||||
android:defaultValue="600"
|
|
||||||
min="50"
|
|
||||||
max="2000"
|
|
||||||
/>
|
|
||||||
<juloo.common.IntSlideBarPreference
|
|
||||||
android:key="longpress_interval"
|
|
||||||
android:title="@string/pref_long_interval_title"
|
|
||||||
android:summary="@string/pref_long_interval_summary"
|
|
||||||
android:defaultValue="25"
|
|
||||||
min="5"
|
|
||||||
max="100"
|
|
||||||
/>
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="precise_repeat"
|
|
||||||
android:title="@string/pref_precise_repeat_title"
|
|
||||||
android:summary="@string/pref_precise_repeat_summary"
|
|
||||||
android:defaultValue="true"
|
|
||||||
/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
<PreferenceCategory android:title="@string/pref_category_vibrate">
|
|
||||||
<CheckBoxPreference
|
|
||||||
android:key="vibrate_enabled"
|
|
||||||
android:title="@string/pref_vibrate_title"
|
|
||||||
android:summary="@string/pref_vibrate_summary"
|
|
||||||
android:defaultValue="true"
|
|
||||||
/>
|
|
||||||
<juloo.common.IntSlideBarPreference
|
|
||||||
android:key="vibrate_duration"
|
|
||||||
android:title="@string/pref_vibrate_duration_title"
|
|
||||||
android:summary="@string/pref_vibrate_duration_summary"
|
|
||||||
android:defaultValue="20"
|
|
||||||
min="5"
|
|
||||||
max="50"
|
|
||||||
/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
<PreferenceCategory android:title="@string/pref_category_style">
|
|
||||||
<juloo.common.IntSlideBarPreference
|
|
||||||
android:key="margin_bottom"
|
|
||||||
android:title="@string/pref_margin_bottom_title"
|
|
||||||
android:summary="@string/pref_margin_bottom_summary"
|
|
||||||
android:defaultValue="5"
|
|
||||||
min="0"
|
|
||||||
max="100"
|
|
||||||
/>
|
|
||||||
<juloo.common.IntSlideBarPreference
|
|
||||||
android:key="key_height"
|
|
||||||
android:title="@string/pref_key_height_title"
|
|
||||||
android:summary="@string/pref_key_height_summary"
|
|
||||||
android:defaultValue="50"
|
|
||||||
min="30"
|
|
||||||
max="90"
|
|
||||||
/>
|
|
||||||
<juloo.common.IntSlideBarPreference
|
|
||||||
android:key="horizontal_margin"
|
|
||||||
android:title="@string/pref_horizontal_margin_title"
|
|
||||||
android:summary="@string/pref_horizontal_margin_summary"
|
|
||||||
android:defaultValue="3"
|
|
||||||
min="0"
|
|
||||||
max="20"
|
|
||||||
/>
|
|
||||||
<juloo.common.SlideBarPreference
|
|
||||||
android:key="character_size"
|
|
||||||
android:title="@string/pref_character_size_title"
|
|
||||||
android:summary="@string/pref_character_size_summary"
|
|
||||||
android:defaultValue="1.0"
|
|
||||||
min="0.8"
|
|
||||||
max="1.2"
|
|
||||||
/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -11,106 +11,106 @@ import android.widget.TextView;
|
|||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** IntSlideBarPreference
|
** IntSlideBarPreference
|
||||||
** -
|
** -
|
||||||
** Open a dialog showing a seekbar
|
** Open a dialog showing a seekbar
|
||||||
** -
|
** -
|
||||||
** xml attrs:
|
** xml attrs:
|
||||||
** android:defaultValue Default value (int)
|
** android:defaultValue Default value (int)
|
||||||
** min min value (int)
|
** min min value (int)
|
||||||
** max max value (int)
|
** max max value (int)
|
||||||
** -
|
** -
|
||||||
** Summary field allow to show the current value using %s flag
|
** Summary field allow to show the current value using %s flag
|
||||||
*/
|
*/
|
||||||
public class IntSlideBarPreference extends DialogPreference
|
public class IntSlideBarPreference extends DialogPreference
|
||||||
implements SeekBar.OnSeekBarChangeListener
|
implements SeekBar.OnSeekBarChangeListener
|
||||||
{
|
{
|
||||||
private LinearLayout _layout;
|
private LinearLayout _layout;
|
||||||
private TextView _textView;
|
private TextView _textView;
|
||||||
private SeekBar _seekBar;
|
private SeekBar _seekBar;
|
||||||
|
|
||||||
private int _min;
|
private int _min;
|
||||||
|
|
||||||
private String _initialSummary;
|
private String _initialSummary;
|
||||||
|
|
||||||
public IntSlideBarPreference(Context context, AttributeSet attrs)
|
public IntSlideBarPreference(Context context, AttributeSet attrs)
|
||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
_initialSummary = getSummary().toString();
|
_initialSummary = getSummary().toString();
|
||||||
_textView = new TextView(context);
|
_textView = new TextView(context);
|
||||||
_textView.setPadding(48, 40, 48, 40);
|
_textView.setPadding(48, 40, 48, 40);
|
||||||
_seekBar = new SeekBar(context);
|
_seekBar = new SeekBar(context);
|
||||||
_seekBar.setOnSeekBarChangeListener(this);
|
_seekBar.setOnSeekBarChangeListener(this);
|
||||||
_min = attrs.getAttributeIntValue(null, "min", 0);
|
_min = attrs.getAttributeIntValue(null, "min", 0);
|
||||||
int max = attrs.getAttributeIntValue(null, "max", 0);
|
int max = attrs.getAttributeIntValue(null, "max", 0);
|
||||||
_seekBar.setMax(max - _min);
|
_seekBar.setMax(max - _min);
|
||||||
_layout = new LinearLayout(getContext());
|
_layout = new LinearLayout(getContext());
|
||||||
_layout.setOrientation(LinearLayout.VERTICAL);
|
_layout.setOrientation(LinearLayout.VERTICAL);
|
||||||
_layout.addView(_textView);
|
_layout.addView(_textView);
|
||||||
_layout.addView(_seekBar);
|
_layout.addView(_seekBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
||||||
{
|
{
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartTrackingTouch(SeekBar seekBar)
|
public void onStartTrackingTouch(SeekBar seekBar)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStopTrackingTouch(SeekBar seekBar)
|
public void onStopTrackingTouch(SeekBar seekBar)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue)
|
protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue)
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
if (restorePersistedValue)
|
if (restorePersistedValue)
|
||||||
{
|
{
|
||||||
value = getPersistedInt(_min);
|
value = getPersistedInt(_min);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value = (Integer)defaultValue;
|
value = (Integer)defaultValue;
|
||||||
persistInt(value);
|
persistInt(value);
|
||||||
}
|
}
|
||||||
_seekBar.setProgress(value - _min);
|
_seekBar.setProgress(value - _min);
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object onGetDefaultValue(TypedArray a, int index)
|
protected Object onGetDefaultValue(TypedArray a, int index)
|
||||||
{
|
{
|
||||||
return (a.getInt(index, _min));
|
return (a.getInt(index, _min));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDialogClosed(boolean positiveResult)
|
protected void onDialogClosed(boolean positiveResult)
|
||||||
{
|
{
|
||||||
if (positiveResult)
|
if (positiveResult)
|
||||||
persistInt(_seekBar.getProgress() + _min);
|
persistInt(_seekBar.getProgress() + _min);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected View onCreateDialogView()
|
protected View onCreateDialogView()
|
||||||
{
|
{
|
||||||
ViewGroup parent = (ViewGroup)_layout.getParent();
|
ViewGroup parent = (ViewGroup)_layout.getParent();
|
||||||
|
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
parent.removeView(_layout);
|
parent.removeView(_layout);
|
||||||
return (_layout);
|
return (_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateText()
|
private void updateText()
|
||||||
{
|
{
|
||||||
String f = String.format(_initialSummary, _seekBar.getProgress() + _min);
|
String f = String.format(_initialSummary, _seekBar.getProgress() + _min);
|
||||||
|
|
||||||
_textView.setText(f);
|
_textView.setText(f);
|
||||||
setSummary(f);
|
setSummary(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,117 +11,117 @@ import android.widget.TextView;
|
|||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** SideBarPreference
|
** SideBarPreference
|
||||||
** -
|
** -
|
||||||
** Open a dialog showing a seekbar
|
** Open a dialog showing a seekbar
|
||||||
** -
|
** -
|
||||||
** xml attrs:
|
** xml attrs:
|
||||||
** android:defaultValue Default value (float)
|
** android:defaultValue Default value (float)
|
||||||
** min min value (float)
|
** min min value (float)
|
||||||
** max max value (float)
|
** max max value (float)
|
||||||
** -
|
** -
|
||||||
** Summary field allow to show the current value using %f or %s flag
|
** Summary field allow to show the current value using %f or %s flag
|
||||||
*/
|
*/
|
||||||
public class SlideBarPreference extends DialogPreference
|
public class SlideBarPreference extends DialogPreference
|
||||||
implements SeekBar.OnSeekBarChangeListener
|
implements SeekBar.OnSeekBarChangeListener
|
||||||
{
|
{
|
||||||
private static final int STEPS = 100;
|
private static final int STEPS = 100;
|
||||||
|
|
||||||
private LinearLayout _layout;
|
private LinearLayout _layout;
|
||||||
private TextView _textView;
|
private TextView _textView;
|
||||||
private SeekBar _seekBar;
|
private SeekBar _seekBar;
|
||||||
|
|
||||||
private float _min;
|
private float _min;
|
||||||
private float _max;
|
private float _max;
|
||||||
private float _value;
|
private float _value;
|
||||||
|
|
||||||
private String _initialSummary;
|
private String _initialSummary;
|
||||||
|
|
||||||
public SlideBarPreference(Context context, AttributeSet attrs)
|
public SlideBarPreference(Context context, AttributeSet attrs)
|
||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
_initialSummary = getSummary().toString();
|
_initialSummary = getSummary().toString();
|
||||||
_textView = new TextView(context);
|
_textView = new TextView(context);
|
||||||
_textView.setPadding(48, 40, 48, 40);
|
_textView.setPadding(48, 40, 48, 40);
|
||||||
_seekBar = new SeekBar(context);
|
_seekBar = new SeekBar(context);
|
||||||
_seekBar.setOnSeekBarChangeListener(this);
|
_seekBar.setOnSeekBarChangeListener(this);
|
||||||
_seekBar.setMax(STEPS);
|
_seekBar.setMax(STEPS);
|
||||||
_min = float_of_string(attrs.getAttributeValue(null, "min"));
|
_min = float_of_string(attrs.getAttributeValue(null, "min"));
|
||||||
_value = _min;
|
_value = _min;
|
||||||
_max = Math.max(1f, float_of_string(attrs.getAttributeValue(null, "max")));
|
_max = Math.max(1f, float_of_string(attrs.getAttributeValue(null, "max")));
|
||||||
_layout = new LinearLayout(getContext());
|
_layout = new LinearLayout(getContext());
|
||||||
_layout.setOrientation(LinearLayout.VERTICAL);
|
_layout.setOrientation(LinearLayout.VERTICAL);
|
||||||
_layout.addView(_textView);
|
_layout.addView(_textView);
|
||||||
_layout.addView(_seekBar);
|
_layout.addView(_seekBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
||||||
{
|
{
|
||||||
_value = Math.round(progress * (_max - _min)) / (float)STEPS + _min;
|
_value = Math.round(progress * (_max - _min)) / (float)STEPS + _min;
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartTrackingTouch(SeekBar seekBar)
|
public void onStartTrackingTouch(SeekBar seekBar)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStopTrackingTouch(SeekBar seekBar)
|
public void onStopTrackingTouch(SeekBar seekBar)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue)
|
protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue)
|
||||||
{
|
{
|
||||||
if (restorePersistedValue)
|
if (restorePersistedValue)
|
||||||
{
|
{
|
||||||
_value = getPersistedFloat(_min);
|
_value = getPersistedFloat(_min);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_value = (Float)defaultValue;
|
_value = (Float)defaultValue;
|
||||||
persistFloat(_value);
|
persistFloat(_value);
|
||||||
}
|
}
|
||||||
_seekBar.setProgress((int)((_value - _min) * STEPS / (_max - _min)));
|
_seekBar.setProgress((int)((_value - _min) * STEPS / (_max - _min)));
|
||||||
updateText();
|
updateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Object onGetDefaultValue(TypedArray a, int index)
|
protected Object onGetDefaultValue(TypedArray a, int index)
|
||||||
{
|
{
|
||||||
return (a.getFloat(index, _min));
|
return (a.getFloat(index, _min));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDialogClosed(boolean positiveResult)
|
protected void onDialogClosed(boolean positiveResult)
|
||||||
{
|
{
|
||||||
if (positiveResult)
|
if (positiveResult)
|
||||||
persistFloat(_value);
|
persistFloat(_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected View onCreateDialogView()
|
protected View onCreateDialogView()
|
||||||
{
|
{
|
||||||
ViewGroup parent = (ViewGroup)_layout.getParent();
|
ViewGroup parent = (ViewGroup)_layout.getParent();
|
||||||
|
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
parent.removeView(_layout);
|
parent.removeView(_layout);
|
||||||
return (_layout);
|
return (_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateText()
|
private void updateText()
|
||||||
{
|
{
|
||||||
String f = String.format(_initialSummary, _value);
|
String f = String.format(_initialSummary, _value);
|
||||||
|
|
||||||
_textView.setText(f);
|
_textView.setText(f);
|
||||||
setSummary(f);
|
setSummary(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float float_of_string(String str)
|
private static float float_of_string(String str)
|
||||||
{
|
{
|
||||||
if (str == null)
|
if (str == null)
|
||||||
return (0f);
|
return (0f);
|
||||||
return (Float.parseFloat(str));
|
return (Float.parseFloat(str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,25 +7,25 @@ import android.util.TypedValue;
|
|||||||
|
|
||||||
class Config
|
class Config
|
||||||
{
|
{
|
||||||
private Keyboard2 _context;
|
private Keyboard2 _context;
|
||||||
|
|
||||||
// From resources
|
// From resources
|
||||||
public final float marginTop;
|
public final float marginTop;
|
||||||
public final float keyPadding;
|
public final float keyPadding;
|
||||||
public final float keyVerticalInterval;
|
public final float keyVerticalInterval;
|
||||||
public final float keyHorizontalInterval;
|
public final float keyHorizontalInterval;
|
||||||
public final float keyRound;
|
public final float keyRound;
|
||||||
|
|
||||||
// From preferences
|
// From preferences
|
||||||
public int layout; // Or '-1' for the system defaults
|
public int layout; // Or '-1' for the system defaults
|
||||||
public float subValueDist;
|
public float subValueDist;
|
||||||
public boolean vibrateEnabled;
|
public boolean vibrateEnabled;
|
||||||
public long vibrateDuration;
|
public long vibrateDuration;
|
||||||
public long longPressTimeout;
|
public long longPressTimeout;
|
||||||
public long longPressInterval;
|
public long longPressInterval;
|
||||||
public float marginBottom;
|
public float marginBottom;
|
||||||
public float keyHeight;
|
public float keyHeight;
|
||||||
public float horizontalMargin;
|
public float horizontalMargin;
|
||||||
public boolean preciseRepeat;
|
public boolean preciseRepeat;
|
||||||
public float characterSize; // Ratio
|
public float characterSize; // Ratio
|
||||||
public int accents; // Values are R.values.pref_accents_v_*
|
public int accents; // Values are R.values.pref_accents_v_*
|
||||||
@ -34,67 +34,67 @@ class Config
|
|||||||
public boolean shouldOfferSwitchingToNextInputMethod;
|
public boolean shouldOfferSwitchingToNextInputMethod;
|
||||||
public int accent_flags_to_remove;
|
public int accent_flags_to_remove;
|
||||||
|
|
||||||
public Config(Keyboard2 context)
|
public Config(Keyboard2 context)
|
||||||
{
|
{
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
|
|
||||||
_context = context;
|
_context = context;
|
||||||
// static values
|
// static values
|
||||||
marginTop = res.getDimension(R.dimen.margin_top);
|
marginTop = res.getDimension(R.dimen.margin_top);
|
||||||
keyPadding = res.getDimension(R.dimen.key_padding);
|
keyPadding = res.getDimension(R.dimen.key_padding);
|
||||||
keyVerticalInterval = res.getDimension(R.dimen.key_vertical_interval);
|
keyVerticalInterval = res.getDimension(R.dimen.key_vertical_interval);
|
||||||
keyHorizontalInterval = res.getDimension(R.dimen.key_horizontal_interval);
|
keyHorizontalInterval = res.getDimension(R.dimen.key_horizontal_interval);
|
||||||
keyRound = res.getDimension(R.dimen.key_round);
|
keyRound = res.getDimension(R.dimen.key_round);
|
||||||
// default values
|
// default values
|
||||||
layout = -1;
|
layout = -1;
|
||||||
subValueDist = 10f;
|
subValueDist = 10f;
|
||||||
vibrateEnabled = true;
|
vibrateEnabled = true;
|
||||||
vibrateDuration = 20;
|
vibrateDuration = 20;
|
||||||
longPressTimeout = 600;
|
longPressTimeout = 600;
|
||||||
longPressInterval = 65;
|
longPressInterval = 65;
|
||||||
marginBottom = res.getDimension(R.dimen.margin_bottom);
|
marginBottom = res.getDimension(R.dimen.margin_bottom);
|
||||||
keyHeight = res.getDimension(R.dimen.key_height);
|
keyHeight = res.getDimension(R.dimen.key_height);
|
||||||
horizontalMargin = res.getDimension(R.dimen.horizontal_margin);
|
horizontalMargin = res.getDimension(R.dimen.horizontal_margin);
|
||||||
preciseRepeat = true;
|
preciseRepeat = true;
|
||||||
characterSize = 1.f;
|
characterSize = 1.f;
|
||||||
accents = 1;
|
accents = 1;
|
||||||
// from prefs
|
// from prefs
|
||||||
refresh();
|
refresh();
|
||||||
// initialized later
|
// initialized later
|
||||||
shouldOfferSwitchingToNextInputMethod = false;
|
shouldOfferSwitchingToNextInputMethod = false;
|
||||||
accent_flags_to_remove = 0;
|
accent_flags_to_remove = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Reload prefs
|
** Reload prefs
|
||||||
*/
|
*/
|
||||||
public void refresh()
|
public void refresh()
|
||||||
{
|
{
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(_context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(_context);
|
||||||
|
|
||||||
layout = layoutId_of_string(prefs.getString("layout", "system"));
|
layout = layoutId_of_string(prefs.getString("layout", "system"));
|
||||||
subValueDist = prefs.getFloat("sub_value_dist", subValueDist);
|
subValueDist = prefs.getFloat("sub_value_dist", subValueDist);
|
||||||
vibrateEnabled = prefs.getBoolean("vibrate_enabled", vibrateEnabled);
|
vibrateEnabled = prefs.getBoolean("vibrate_enabled", vibrateEnabled);
|
||||||
vibrateDuration = prefs.getInt("vibrate_duration", (int)vibrateDuration);
|
vibrateDuration = prefs.getInt("vibrate_duration", (int)vibrateDuration);
|
||||||
longPressTimeout = prefs.getInt("longpress_timeout", (int)longPressTimeout);
|
longPressTimeout = prefs.getInt("longpress_timeout", (int)longPressTimeout);
|
||||||
longPressInterval = prefs.getInt("longpress_interval", (int)longPressInterval);
|
longPressInterval = prefs.getInt("longpress_interval", (int)longPressInterval);
|
||||||
marginBottom = getDipPref(prefs, "margin_bottom", marginBottom);
|
marginBottom = getDipPref(prefs, "margin_bottom", marginBottom);
|
||||||
keyHeight = getDipPref(prefs, "key_height", keyHeight);
|
keyHeight = getDipPref(prefs, "key_height", keyHeight);
|
||||||
horizontalMargin = getDipPref(prefs, "horizontal_margin", horizontalMargin);
|
horizontalMargin = getDipPref(prefs, "horizontal_margin", horizontalMargin);
|
||||||
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
|
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
|
||||||
characterSize = prefs.getFloat("character_size", characterSize);
|
characterSize = prefs.getFloat("character_size", characterSize);
|
||||||
accents = Integer.valueOf(prefs.getString("accents", "1"));
|
accents = Integer.valueOf(prefs.getString("accents", "1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getDipPref(SharedPreferences prefs, String pref_name, float def)
|
private float getDipPref(SharedPreferences prefs, String pref_name, float def)
|
||||||
{
|
{
|
||||||
int value = prefs.getInt(pref_name, -1);
|
int value = prefs.getInt(pref_name, -1);
|
||||||
|
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
return (def);
|
return (def);
|
||||||
return (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value,
|
return (TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, value,
|
||||||
_context.getResources().getDisplayMetrics()));
|
_context.getResources().getDisplayMetrics()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int layoutId_of_string(String name)
|
public static int layoutId_of_string(String name)
|
||||||
{
|
{
|
||||||
|
@ -10,35 +10,35 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
public class Emoji extends KeyValue
|
public class Emoji extends KeyValue
|
||||||
{
|
{
|
||||||
private final String _desc;
|
private final String _desc;
|
||||||
|
|
||||||
private static HashMap<String, Emoji> emojis_by_name = new HashMap<String, Emoji>();
|
private static HashMap<String, Emoji> emojis_by_name = new HashMap<String, Emoji>();
|
||||||
|
|
||||||
protected Emoji(String name, String bytecode, String desc)
|
protected Emoji(String name, String bytecode, String desc)
|
||||||
{
|
{
|
||||||
super(name, bytecode, CHAR_NONE, EVENT_NONE, 0);
|
super(name, bytecode, CHAR_NONE, EVENT_NONE, 0);
|
||||||
_desc = desc;
|
_desc = desc;
|
||||||
emojis_by_name.put(name, this);
|
emojis_by_name.put(name, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription()
|
public String getDescription()
|
||||||
{
|
{
|
||||||
return (_desc);
|
return (_desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int num_groups = 0;
|
public static int num_groups = 0;
|
||||||
|
|
||||||
private static Emoji[][] emojis_by_group = new Emoji[][]{};
|
private static Emoji[][] emojis_by_group = new Emoji[][]{};
|
||||||
|
|
||||||
public static Emoji getEmojiByName(String name)
|
public static Emoji getEmojiByName(String name)
|
||||||
{
|
{
|
||||||
return emojis_by_name.get(name);
|
return emojis_by_name.get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Emoji[] getEmojisByGroup(int group_id)
|
public static Emoji[] getEmojisByGroup(int group_id)
|
||||||
{
|
{
|
||||||
return (emojis_by_group[group_id]);
|
return (emojis_by_group[group_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the list of emojis from a raw file. Will initialize only once. */
|
/* Read the list of emojis from a raw file. Will initialize only once. */
|
||||||
public static void init(Resources res)
|
public static void init(Resources res)
|
||||||
|
@ -19,158 +19,158 @@ import java.util.Set;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class EmojiGridView extends GridView
|
public class EmojiGridView extends GridView
|
||||||
implements GridView.OnItemClickListener
|
implements GridView.OnItemClickListener
|
||||||
{
|
{
|
||||||
public static final int GROUP_LAST_USE = -1;
|
public static final int GROUP_LAST_USE = -1;
|
||||||
|
|
||||||
public static final int COLUMN_WIDTH = 192;
|
public static final int COLUMN_WIDTH = 192;
|
||||||
public static final float EMOJI_SIZE = 32.f;
|
public static final float EMOJI_SIZE = 32.f;
|
||||||
|
|
||||||
private static final String LAST_USE_PREF = "emoji_last_use";
|
private static final String LAST_USE_PREF = "emoji_last_use";
|
||||||
|
|
||||||
private Emoji[] _emojiArray;
|
private Emoji[] _emojiArray;
|
||||||
private HashMap<Emoji, Integer> _lastUsed;
|
private HashMap<Emoji, Integer> _lastUsed;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** TODO: adapt column width and emoji size
|
** TODO: adapt column width and emoji size
|
||||||
** TODO: use ArraySet instead of Emoji[]
|
** TODO: use ArraySet instead of Emoji[]
|
||||||
*/
|
*/
|
||||||
public EmojiGridView(Context context, AttributeSet attrs)
|
public EmojiGridView(Context context, AttributeSet attrs)
|
||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
Emoji.init(context.getResources());
|
Emoji.init(context.getResources());
|
||||||
setOnItemClickListener(this);
|
setOnItemClickListener(this);
|
||||||
setColumnWidth(COLUMN_WIDTH);
|
setColumnWidth(COLUMN_WIDTH);
|
||||||
loadLastUsed();
|
loadLastUsed();
|
||||||
setEmojiGroup((_lastUsed.size() == 0) ? 0 : GROUP_LAST_USE);
|
setEmojiGroup((_lastUsed.size() == 0) ? 0 : GROUP_LAST_USE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmojiGroup(int group)
|
public void setEmojiGroup(int group)
|
||||||
{
|
{
|
||||||
_emojiArray = (group == GROUP_LAST_USE) ? getLastEmojis() : Emoji.getEmojisByGroup(group);
|
_emojiArray = (group == GROUP_LAST_USE) ? getLastEmojis() : Emoji.getEmojisByGroup(group);
|
||||||
setAdapter(new EmojiViewAdpater((Keyboard2)getContext(), _emojiArray));
|
setAdapter(new EmojiViewAdpater((Keyboard2)getContext(), _emojiArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onItemClick(AdapterView<?> parent, View v, int pos, long id)
|
public void onItemClick(AdapterView<?> parent, View v, int pos, long id)
|
||||||
{
|
{
|
||||||
Keyboard2 main = (Keyboard2)getContext();
|
Keyboard2 main = (Keyboard2)getContext();
|
||||||
Integer used = _lastUsed.get(_emojiArray[pos]);
|
Integer used = _lastUsed.get(_emojiArray[pos]);
|
||||||
|
|
||||||
_lastUsed.put(_emojiArray[pos], (used == null) ? 1 : used.intValue() + 1);
|
_lastUsed.put(_emojiArray[pos], (used == null) ? 1 : used.intValue() + 1);
|
||||||
main.handleKeyUp(_emojiArray[pos], 0);
|
main.handleKeyUp(_emojiArray[pos], 0);
|
||||||
saveLastUsed(); // TODO: opti
|
saveLastUsed(); // TODO: opti
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMeasure(int wSpec, int hSpec)
|
public void onMeasure(int wSpec, int hSpec)
|
||||||
{
|
{
|
||||||
super.onMeasure(wSpec, hSpec);
|
super.onMeasure(wSpec, hSpec);
|
||||||
setNumColumns(getMeasuredWidth() / COLUMN_WIDTH);
|
setNumColumns(getMeasuredWidth() / COLUMN_WIDTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Emoji[] getLastEmojis()
|
private Emoji[] getLastEmojis()
|
||||||
{
|
{
|
||||||
final HashMap<Emoji, Integer> map = _lastUsed;
|
final HashMap<Emoji, Integer> map = _lastUsed;
|
||||||
Emoji[] array = new Emoji[map.size()];
|
Emoji[] array = new Emoji[map.size()];
|
||||||
|
|
||||||
map.keySet().toArray(array);
|
map.keySet().toArray(array);
|
||||||
Arrays.sort(array, 0, array.length, new Comparator<Emoji>()
|
Arrays.sort(array, 0, array.length, new Comparator<Emoji>()
|
||||||
{
|
{
|
||||||
public int compare(Emoji a, Emoji b)
|
public int compare(Emoji a, Emoji b)
|
||||||
{
|
{
|
||||||
return (map.get(b).intValue() - map.get(a).intValue());
|
return (map.get(b).intValue() - map.get(a).intValue());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return (array);
|
return (array);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveLastUsed()
|
private void saveLastUsed()
|
||||||
{
|
{
|
||||||
SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(getContext()).edit();
|
SharedPreferences.Editor edit = PreferenceManager.getDefaultSharedPreferences(getContext()).edit();
|
||||||
HashSet<String> set = new HashSet<String>();
|
HashSet<String> set = new HashSet<String>();
|
||||||
|
|
||||||
for (Emoji emoji : _lastUsed.keySet())
|
for (Emoji emoji : _lastUsed.keySet())
|
||||||
set.add(String.valueOf(_lastUsed.get(emoji)) + "-" + emoji.name);
|
set.add(String.valueOf(_lastUsed.get(emoji)) + "-" + emoji.name);
|
||||||
edit.putStringSet(LAST_USE_PREF, set);
|
edit.putStringSet(LAST_USE_PREF, set);
|
||||||
edit.apply();
|
edit.apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadLastUsed()
|
private void loadLastUsed()
|
||||||
{
|
{
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
Set<String> lastUseSet = prefs.getStringSet(LAST_USE_PREF, null);
|
Set<String> lastUseSet = prefs.getStringSet(LAST_USE_PREF, null);
|
||||||
|
|
||||||
_lastUsed = new HashMap<Emoji, Integer>();
|
_lastUsed = new HashMap<Emoji, Integer>();
|
||||||
if (lastUseSet != null)
|
if (lastUseSet != null)
|
||||||
for (String emojiData : lastUseSet)
|
for (String emojiData : lastUseSet)
|
||||||
{
|
{
|
||||||
String[] data = emojiData.split("-", 2);
|
String[] data = emojiData.split("-", 2);
|
||||||
Emoji emoji;
|
Emoji emoji;
|
||||||
|
|
||||||
if (data.length != 2)
|
if (data.length != 2)
|
||||||
continue ;
|
continue ;
|
||||||
emoji = Emoji.getEmojiByName(data[1]);
|
emoji = Emoji.getEmojiByName(data[1]);
|
||||||
if (emoji == null)
|
if (emoji == null)
|
||||||
continue ;
|
continue ;
|
||||||
_lastUsed.put(emoji, Integer.valueOf(data[0]));
|
_lastUsed.put(emoji, Integer.valueOf(data[0]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EmojiView extends TextView
|
private static class EmojiView extends TextView
|
||||||
{
|
{
|
||||||
public EmojiView(Keyboard2 context)
|
public EmojiView(Keyboard2 context)
|
||||||
{
|
{
|
||||||
super(context);
|
super(context);
|
||||||
setTextSize(EMOJI_SIZE);
|
setTextSize(EMOJI_SIZE);
|
||||||
setGravity(Gravity.CENTER);
|
setGravity(Gravity.CENTER);
|
||||||
setBackgroundColor(0x0);
|
setBackgroundColor(0x0);
|
||||||
setTextColor(getResources().getColor(R.color.emoji_color));
|
setTextColor(getResources().getColor(R.color.emoji_color));
|
||||||
setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.WRAP_CONTENT, GridView.LayoutParams.WRAP_CONTENT));
|
setLayoutParams(new GridView.LayoutParams(GridView.LayoutParams.WRAP_CONTENT, GridView.LayoutParams.WRAP_CONTENT));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEmoji(Emoji emoji)
|
public void setEmoji(Emoji emoji)
|
||||||
{
|
{
|
||||||
setText(emoji.symbol);
|
setText(emoji.symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EmojiViewAdpater extends BaseAdapter
|
private static class EmojiViewAdpater extends BaseAdapter
|
||||||
{
|
{
|
||||||
private Keyboard2 _main;
|
private Keyboard2 _main;
|
||||||
|
|
||||||
private Emoji[] _emojiArray;
|
private Emoji[] _emojiArray;
|
||||||
|
|
||||||
public EmojiViewAdpater(Keyboard2 main, Emoji[] emojiArray)
|
public EmojiViewAdpater(Keyboard2 main, Emoji[] emojiArray)
|
||||||
{
|
{
|
||||||
_main = main;
|
_main = main;
|
||||||
_emojiArray = emojiArray;
|
_emojiArray = emojiArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount()
|
public int getCount()
|
||||||
{
|
{
|
||||||
if (_emojiArray == null)
|
if (_emojiArray == null)
|
||||||
return (0);
|
return (0);
|
||||||
return (_emojiArray.length);
|
return (_emojiArray.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getItem(int pos)
|
public Object getItem(int pos)
|
||||||
{
|
{
|
||||||
return (_emojiArray[pos]);
|
return (_emojiArray[pos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getItemId(int pos)
|
public long getItemId(int pos)
|
||||||
{
|
{
|
||||||
return (pos);
|
return (pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public View getView(int pos, View convertView, ViewGroup parent)
|
public View getView(int pos, View convertView, ViewGroup parent)
|
||||||
{
|
{
|
||||||
EmojiView view = (EmojiView)convertView;
|
EmojiView view = (EmojiView)convertView;
|
||||||
|
|
||||||
if (view == null)
|
if (view == null)
|
||||||
view = new EmojiView(_main);
|
view = new EmojiView(_main);
|
||||||
view.setEmoji(_emojiArray[pos]);
|
view.setEmoji(_emojiArray[pos]);
|
||||||
return (view);
|
return (view);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,24 +6,24 @@ import android.view.View;
|
|||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
public class EmojiKeyButton extends Button
|
public class EmojiKeyButton extends Button
|
||||||
implements View.OnClickListener
|
implements View.OnClickListener
|
||||||
{
|
{
|
||||||
KeyValue _key;
|
KeyValue _key;
|
||||||
|
|
||||||
public EmojiKeyButton(Context context, AttributeSet attrs)
|
public EmojiKeyButton(Context context, AttributeSet attrs)
|
||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
setOnClickListener(this);
|
setOnClickListener(this);
|
||||||
_key = KeyValue.getKeyByName(attrs.getAttributeValue(null, "key"));
|
_key = KeyValue.getKeyByName(attrs.getAttributeValue(null, "key"));
|
||||||
setText(_key.symbol);
|
setText(_key.symbol);
|
||||||
if ((_key.flags & KeyValue.FLAG_KEY_FONT) != 0)
|
if ((_key.flags & KeyValue.FLAG_KEY_FONT) != 0)
|
||||||
setTypeface(((Keyboard2)context).getSpecialKeyFont());
|
setTypeface(((Keyboard2)context).getSpecialKeyFont());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v)
|
public void onClick(View v)
|
||||||
{
|
{
|
||||||
Keyboard2 main = (Keyboard2)getContext();
|
Keyboard2 main = (Keyboard2)getContext();
|
||||||
|
|
||||||
main.handleKeyUp(_key, 0);
|
main.handleKeyUp(_key, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,28 +10,28 @@ import android.widget.Button;
|
|||||||
/* Emoji "types" are groups. This class is misnamed. */
|
/* Emoji "types" are groups. This class is misnamed. */
|
||||||
|
|
||||||
public class EmojiTypeButton extends Button
|
public class EmojiTypeButton extends Button
|
||||||
implements View.OnTouchListener
|
implements View.OnTouchListener
|
||||||
{
|
{
|
||||||
private int _emojiType;
|
private int _emojiType;
|
||||||
|
|
||||||
static private final int DEFAULT_GROUP = 0;
|
static private final int DEFAULT_GROUP = 0;
|
||||||
|
|
||||||
public EmojiTypeButton(Context context, int group_id, String symbol)
|
public EmojiTypeButton(Context context, int group_id, String symbol)
|
||||||
{
|
{
|
||||||
super(new ContextThemeWrapper(context, R.style.emojiTypeButton), null, 0);
|
super(new ContextThemeWrapper(context, R.style.emojiTypeButton), null, 0);
|
||||||
_emojiType = group_id;
|
_emojiType = group_id;
|
||||||
setText(symbol);
|
setText(symbol);
|
||||||
setOnTouchListener(this);
|
setOnTouchListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onTouch(View view, MotionEvent event)
|
public boolean onTouch(View view, MotionEvent event)
|
||||||
{
|
{
|
||||||
EmojiGridView emojiGrid;
|
EmojiGridView emojiGrid;
|
||||||
|
|
||||||
if (event.getAction() != MotionEvent.ACTION_DOWN)
|
if (event.getAction() != MotionEvent.ACTION_DOWN)
|
||||||
return (false);
|
return (false);
|
||||||
emojiGrid = (EmojiGridView)((ViewGroup)(getParent().getParent())).findViewById(R.id.emoji_grid);
|
emojiGrid = (EmojiGridView)((ViewGroup)(getParent().getParent())).findViewById(R.id.emoji_grid);
|
||||||
emojiGrid.setEmojiGroup(_emojiType);
|
emojiGrid.setEmojiGroup(_emojiType);
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,14 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
class KeyValue
|
class KeyValue
|
||||||
{
|
{
|
||||||
public static final int EVENT_NONE = -1;
|
public static final int EVENT_NONE = -1;
|
||||||
public static final int EVENT_CONFIG = -2;
|
public static final int EVENT_CONFIG = -2;
|
||||||
public static final int EVENT_SWITCH_TEXT = -3;
|
public static final int EVENT_SWITCH_TEXT = -3;
|
||||||
public static final int EVENT_SWITCH_NUMERIC = -4;
|
public static final int EVENT_SWITCH_NUMERIC = -4;
|
||||||
public static final int EVENT_SWITCH_EMOJI = -5;
|
public static final int EVENT_SWITCH_EMOJI = -5;
|
||||||
public static final int EVENT_SWITCH_BACK_EMOJI = -6;
|
public static final int EVENT_SWITCH_BACK_EMOJI = -6;
|
||||||
public static final int EVENT_CHANGE_METHOD = -7;
|
public static final int EVENT_CHANGE_METHOD = -7;
|
||||||
public static final char CHAR_NONE = '\0';
|
public static final char CHAR_NONE = '\0';
|
||||||
|
|
||||||
// Behavior flags
|
// Behavior flags
|
||||||
public static final int FLAG_KEEP_ON = 1;
|
public static final int FLAG_KEEP_ON = 1;
|
||||||
@ -75,7 +75,7 @@ class KeyValue
|
|||||||
flags = f;
|
flags = f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KeyValue getKeyByName(String name)
|
public static KeyValue getKeyByName(String name)
|
||||||
{
|
{
|
||||||
if (name == null)
|
if (name == null)
|
||||||
return null;
|
return null;
|
||||||
@ -222,7 +222,7 @@ class KeyValue
|
|||||||
addEventKey("f9", "F9", KeyEvent.KEYCODE_F9);
|
addEventKey("f9", "F9", KeyEvent.KEYCODE_F9);
|
||||||
addEventKey("f10", "F10", KeyEvent.KEYCODE_F10);
|
addEventKey("f10", "F10", KeyEvent.KEYCODE_F10);
|
||||||
|
|
||||||
addKey("tab", "↹", '\t', KeyEvent.KEYCODE_TAB, 0);
|
addKey("tab", "↹", '\t', KeyEvent.KEYCODE_TAB, 0);
|
||||||
addKey("space", " ", ' ', KeyEvent.KEYCODE_SPACE, 0);
|
addKey("space", " ", ' ', KeyEvent.KEYCODE_SPACE, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,14 +25,14 @@ import java.util.Locale;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Keyboard2 extends InputMethodService
|
public class Keyboard2 extends InputMethodService
|
||||||
implements SharedPreferences.OnSharedPreferenceChangeListener
|
implements SharedPreferences.OnSharedPreferenceChangeListener
|
||||||
{
|
{
|
||||||
private Keyboard2View _keyboardView;
|
private Keyboard2View _keyboardView;
|
||||||
private int _currentTextLayout;
|
private int _currentTextLayout;
|
||||||
private ViewGroup _emojiPane = null;
|
private ViewGroup _emojiPane = null;
|
||||||
private Typeface _specialKeyFont = null;
|
private Typeface _specialKeyFont = null;
|
||||||
|
|
||||||
private Config _config;
|
private Config _config;
|
||||||
|
|
||||||
private Map<Integer, KeyboardData> _layoutCache = new HashMap<Integer, KeyboardData>();
|
private Map<Integer, KeyboardData> _layoutCache = new HashMap<Integer, KeyboardData>();
|
||||||
|
|
||||||
@ -47,27 +47,27 @@ public class Keyboard2 extends InputMethodService
|
|||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate()
|
public void onCreate()
|
||||||
{
|
{
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
_specialKeyFont = Typeface.createFromAsset(getAssets(), "fonts/keys.ttf");
|
_specialKeyFont = Typeface.createFromAsset(getAssets(), "fonts/keys.ttf");
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.settings, false);
|
PreferenceManager.setDefaultValues(this, R.xml.settings, false);
|
||||||
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
|
PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);
|
||||||
_config = new Config(this);
|
_config = new Config(this);
|
||||||
_keyboardView = (Keyboard2View)getLayoutInflater().inflate(R.layout.keyboard, null);
|
_keyboardView = (Keyboard2View)getLayoutInflater().inflate(R.layout.keyboard, null);
|
||||||
_keyboardView.reset();
|
_keyboardView.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Config getConfig()
|
public Config getConfig()
|
||||||
{
|
{
|
||||||
return (_config);
|
return (_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Typeface getSpecialKeyFont()
|
public Typeface getSpecialKeyFont()
|
||||||
{
|
{
|
||||||
return (_specialKeyFont);
|
return (_specialKeyFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm)
|
private List<InputMethodSubtype> getEnabledSubtypes(InputMethodManager imm)
|
||||||
{
|
{
|
||||||
@ -148,26 +148,26 @@ public class Keyboard2 extends InputMethodService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateInputView()
|
public View onCreateInputView()
|
||||||
{
|
{
|
||||||
ViewGroup parent = (ViewGroup)_keyboardView.getParent();
|
ViewGroup parent = (ViewGroup)_keyboardView.getParent();
|
||||||
|
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
parent.removeView(_keyboardView);
|
parent.removeView(_keyboardView);
|
||||||
return (_keyboardView);
|
return (_keyboardView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartInputView(EditorInfo info, boolean restarting)
|
public void onStartInputView(EditorInfo info, boolean restarting)
|
||||||
{
|
{
|
||||||
refreshSubtypeImm();
|
refreshSubtypeImm();
|
||||||
if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0)
|
if ((info.inputType & InputType.TYPE_CLASS_NUMBER) != 0)
|
||||||
_keyboardView.setKeyboard(getLayout(R.xml.numeric));
|
_keyboardView.setKeyboard(getLayout(R.xml.numeric));
|
||||||
else
|
else
|
||||||
_keyboardView.setKeyboard(getLayout(_currentTextLayout));
|
_keyboardView.setKeyboard(getLayout(_currentTextLayout));
|
||||||
_keyboardView.reset(); // Layout might need to change due to rotation
|
_keyboardView.reset(); // Layout might need to change due to rotation
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype)
|
public void onCurrentInputMethodSubtypeChanged(InputMethodSubtype subtype)
|
||||||
@ -183,92 +183,92 @@ public class Keyboard2 extends InputMethodService
|
|||||||
_keyboardView.reset();
|
_keyboardView.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
|
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key)
|
||||||
{
|
{
|
||||||
_config.refresh();
|
_config.refresh();
|
||||||
refreshSubtypeImm();
|
refreshSubtypeImm();
|
||||||
_keyboardView.refreshConfig(_config, getLayout(_currentTextLayout));
|
_keyboardView.refreshConfig(_config, getLayout(_currentTextLayout));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfigurationChanged(Configuration newConfig)
|
public void onConfigurationChanged(Configuration newConfig)
|
||||||
{
|
{
|
||||||
_keyboardView.reset();
|
_keyboardView.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleKeyUp(KeyValue key, int flags)
|
public void handleKeyUp(KeyValue key, int flags)
|
||||||
{
|
{
|
||||||
if (getCurrentInputConnection() == null)
|
if (getCurrentInputConnection() == null)
|
||||||
return ;
|
return ;
|
||||||
key = KeyModifier.handleFlags(key, flags);
|
key = KeyModifier.handleFlags(key, flags);
|
||||||
if (key.eventCode == KeyValue.EVENT_CONFIG)
|
if (key.eventCode == KeyValue.EVENT_CONFIG)
|
||||||
{
|
{
|
||||||
Intent intent = new Intent(this, SettingsActivity.class);
|
Intent intent = new Intent(this, SettingsActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
else if (key.eventCode == KeyValue.EVENT_SWITCH_TEXT)
|
else if (key.eventCode == KeyValue.EVENT_SWITCH_TEXT)
|
||||||
_keyboardView.setKeyboard(getLayout(_currentTextLayout));
|
_keyboardView.setKeyboard(getLayout(_currentTextLayout));
|
||||||
else if (key.eventCode == KeyValue.EVENT_SWITCH_NUMERIC)
|
else if (key.eventCode == KeyValue.EVENT_SWITCH_NUMERIC)
|
||||||
_keyboardView.setKeyboard(getLayout(R.xml.numeric));
|
_keyboardView.setKeyboard(getLayout(R.xml.numeric));
|
||||||
else if (key.eventCode == KeyValue.EVENT_SWITCH_EMOJI)
|
else if (key.eventCode == KeyValue.EVENT_SWITCH_EMOJI)
|
||||||
{
|
{
|
||||||
if (_emojiPane == null)
|
if (_emojiPane == null)
|
||||||
_emojiPane = (ViewGroup)getLayoutInflater().inflate(R.layout.emoji_pane, null);
|
_emojiPane = (ViewGroup)getLayoutInflater().inflate(R.layout.emoji_pane, null);
|
||||||
setInputView(_emojiPane);
|
setInputView(_emojiPane);
|
||||||
}
|
}
|
||||||
else if (key.eventCode == KeyValue.EVENT_SWITCH_BACK_EMOJI)
|
else if (key.eventCode == KeyValue.EVENT_SWITCH_BACK_EMOJI)
|
||||||
setInputView(_keyboardView);
|
setInputView(_keyboardView);
|
||||||
else if (key.eventCode == KeyValue.EVENT_CHANGE_METHOD)
|
else if (key.eventCode == KeyValue.EVENT_CHANGE_METHOD)
|
||||||
{
|
{
|
||||||
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager)getSystemService(INPUT_METHOD_SERVICE);
|
||||||
imm.switchToNextInputMethod(getConnectionToken(), false);
|
imm.switchToNextInputMethod(getConnectionToken(), false);
|
||||||
}
|
}
|
||||||
else if ((flags & (KeyValue.FLAG_CTRL | KeyValue.FLAG_ALT)) != 0)
|
else if ((flags & (KeyValue.FLAG_CTRL | KeyValue.FLAG_ALT)) != 0)
|
||||||
handleMetaKeyUp(key, flags);
|
handleMetaKeyUp(key, flags);
|
||||||
// else if (eventCode == KeyEvent.KEYCODE_DEL)
|
// else if (eventCode == KeyEvent.KEYCODE_DEL)
|
||||||
// handleDelKey(1, 0);
|
// handleDelKey(1, 0);
|
||||||
// else if (eventCode == KeyEvent.KEYCODE_FORWARD_DEL)
|
// else if (eventCode == KeyEvent.KEYCODE_FORWARD_DEL)
|
||||||
// handleDelKey(0, 1);
|
// handleDelKey(0, 1);
|
||||||
else if (key.char_ == KeyValue.CHAR_NONE)
|
else if (key.char_ == KeyValue.CHAR_NONE)
|
||||||
{
|
{
|
||||||
if (key.eventCode != KeyValue.EVENT_NONE)
|
if (key.eventCode != KeyValue.EVENT_NONE)
|
||||||
handleMetaKeyUp(key, flags);
|
handleMetaKeyUp(key, flags);
|
||||||
else
|
else
|
||||||
getCurrentInputConnection().commitText(key.symbol, 1);
|
getCurrentInputConnection().commitText(key.symbol, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sendKeyChar(key.char_);
|
sendKeyChar(key.char_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void handleDelKey(int before, int after)
|
// private void handleDelKey(int before, int after)
|
||||||
// {
|
// {
|
||||||
// CharSequence selection = getCurrentInputConnection().getSelectedText(0);
|
// CharSequence selection = getCurrentInputConnection().getSelectedText(0);
|
||||||
|
|
||||||
// if (selection != null && selection.length() > 0)
|
// if (selection != null && selection.length() > 0)
|
||||||
// getCurrentInputConnection().commitText("", 1);
|
// getCurrentInputConnection().commitText("", 1);
|
||||||
// else
|
// else
|
||||||
// getCurrentInputConnection().deleteSurroundingText(before, after);
|
// getCurrentInputConnection().deleteSurroundingText(before, after);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private void handleMetaKeyUp(KeyValue key, int flags)
|
private void handleMetaKeyUp(KeyValue key, int flags)
|
||||||
{
|
{
|
||||||
int metaState = 0;
|
int metaState = 0;
|
||||||
KeyEvent event;
|
KeyEvent event;
|
||||||
|
|
||||||
if (key.eventCode == KeyValue.EVENT_NONE)
|
if (key.eventCode == KeyValue.EVENT_NONE)
|
||||||
return ;
|
return ;
|
||||||
if ((flags & KeyValue.FLAG_CTRL) != 0)
|
if ((flags & KeyValue.FLAG_CTRL) != 0)
|
||||||
metaState |= KeyEvent.META_CTRL_LEFT_ON | KeyEvent.META_CTRL_ON;
|
metaState |= KeyEvent.META_CTRL_LEFT_ON | KeyEvent.META_CTRL_ON;
|
||||||
if ((flags & KeyValue.FLAG_ALT) != 0)
|
if ((flags & KeyValue.FLAG_ALT) != 0)
|
||||||
metaState |= KeyEvent.META_ALT_LEFT_ON | KeyEvent.META_ALT_ON;
|
metaState |= KeyEvent.META_ALT_LEFT_ON | KeyEvent.META_ALT_ON;
|
||||||
if ((flags & KeyValue.FLAG_SHIFT) != 0)
|
if ((flags & KeyValue.FLAG_SHIFT) != 0)
|
||||||
metaState |= KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON;
|
metaState |= KeyEvent.META_SHIFT_LEFT_ON | KeyEvent.META_SHIFT_ON;
|
||||||
event = new KeyEvent(1, 1, KeyEvent.ACTION_DOWN, key.eventCode, 0, metaState);
|
event = new KeyEvent(1, 1, KeyEvent.ACTION_DOWN, key.eventCode, 0, metaState);
|
||||||
getCurrentInputConnection().sendKeyEvent(event);
|
getCurrentInputConnection().sendKeyEvent(event);
|
||||||
getCurrentInputConnection().sendKeyEvent(KeyEvent.changeAction(event, KeyEvent.ACTION_UP));
|
getCurrentInputConnection().sendKeyEvent(KeyEvent.changeAction(event, KeyEvent.ACTION_UP));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IBinder getConnectionToken()
|
private IBinder getConnectionToken()
|
||||||
{
|
{
|
||||||
|
@ -17,32 +17,32 @@ import android.widget.PopupWindow;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Keyboard2View extends View
|
public class Keyboard2View extends View
|
||||||
implements View.OnTouchListener, Handler.Callback
|
implements View.OnTouchListener, Handler.Callback
|
||||||
{
|
{
|
||||||
private static final long VIBRATE_MIN_INTERVAL = 100;
|
private static final long VIBRATE_MIN_INTERVAL = 100;
|
||||||
|
|
||||||
private KeyboardData _keyboard;
|
private KeyboardData _keyboard;
|
||||||
|
|
||||||
private ArrayList<KeyDown> _downKeys = new ArrayList<KeyDown>();
|
private ArrayList<KeyDown> _downKeys = new ArrayList<KeyDown>();
|
||||||
|
|
||||||
private int _flags = 0;
|
private int _flags = 0;
|
||||||
|
|
||||||
private Vibrator _vibratorService;
|
private Vibrator _vibratorService;
|
||||||
private long _lastVibration = 0;
|
private long _lastVibration = 0;
|
||||||
|
|
||||||
private Handler _handler;
|
private Handler _handler;
|
||||||
private static int _currentWhat = 0;
|
private static int _currentWhat = 0;
|
||||||
|
|
||||||
private Config _config;
|
private Config _config;
|
||||||
|
|
||||||
private float _keyWidth;
|
private float _keyWidth;
|
||||||
|
|
||||||
private Paint _keyBgPaint = new Paint();
|
private Paint _keyBgPaint = new Paint();
|
||||||
private Paint _keyDownBgPaint = new Paint();
|
private Paint _keyDownBgPaint = new Paint();
|
||||||
private Paint _keyLabelPaint;
|
private Paint _keyLabelPaint;
|
||||||
private Paint _keySubLabelPaint;
|
private Paint _keySubLabelPaint;
|
||||||
private Paint _specialKeyLabelPaint;
|
private Paint _specialKeyLabelPaint;
|
||||||
private Paint _specialKeySubLabelPaint;
|
private Paint _specialKeySubLabelPaint;
|
||||||
private int _lockedColor;
|
private int _lockedColor;
|
||||||
private int _activatedColor;
|
private int _activatedColor;
|
||||||
private int _labelColor;
|
private int _labelColor;
|
||||||
@ -50,49 +50,49 @@ public class Keyboard2View extends View
|
|||||||
private float _labelTextSize;
|
private float _labelTextSize;
|
||||||
private float _sublabelTextSize;
|
private float _sublabelTextSize;
|
||||||
|
|
||||||
private static RectF _tmpRect = new RectF();
|
private static RectF _tmpRect = new RectF();
|
||||||
|
|
||||||
public Keyboard2View(Context context, AttributeSet attrs)
|
public Keyboard2View(Context context, AttributeSet attrs)
|
||||||
{
|
{
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
_vibratorService = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
|
_vibratorService = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
|
||||||
_handler = new Handler(this);
|
_handler = new Handler(this);
|
||||||
refreshConfig(((Keyboard2)context).getConfig(), null);
|
refreshConfig(((Keyboard2)context).getConfig(), null);
|
||||||
setOnTouchListener(this);
|
setOnTouchListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Internally calls [reset()]. */
|
/* Internally calls [reset()]. */
|
||||||
public void refreshConfig(Config config, KeyboardData kw)
|
public void refreshConfig(Config config, KeyboardData kw)
|
||||||
{
|
{
|
||||||
Resources res = getResources();
|
Resources res = getResources();
|
||||||
_config = config;
|
_config = config;
|
||||||
_lockedColor = res.getColor(R.color.key_label_locked);
|
_lockedColor = res.getColor(R.color.key_label_locked);
|
||||||
_activatedColor = res.getColor(R.color.key_label_activated);
|
_activatedColor = res.getColor(R.color.key_label_activated);
|
||||||
_labelColor = res.getColor(R.color.key_label);
|
_labelColor = res.getColor(R.color.key_label);
|
||||||
_subLabelColor = res.getColor(R.color.key_sub_label);
|
_subLabelColor = res.getColor(R.color.key_sub_label);
|
||||||
_labelTextSize = res.getDimension(R.dimen.label_text_size) * config.characterSize;
|
_labelTextSize = res.getDimension(R.dimen.label_text_size) * config.characterSize;
|
||||||
_sublabelTextSize = res.getDimension(R.dimen.sublabel_text_size) * config.characterSize;
|
_sublabelTextSize = res.getDimension(R.dimen.sublabel_text_size) * config.characterSize;
|
||||||
_keyBgPaint.setColor(res.getColor(R.color.key_bg));
|
_keyBgPaint.setColor(res.getColor(R.color.key_bg));
|
||||||
_keyDownBgPaint.setColor(res.getColor(R.color.key_down_bg));
|
_keyDownBgPaint.setColor(res.getColor(R.color.key_down_bg));
|
||||||
_keyLabelPaint = initLabelPaint(Paint.Align.CENTER, null);
|
_keyLabelPaint = initLabelPaint(Paint.Align.CENTER, null);
|
||||||
_keySubLabelPaint = initLabelPaint(Paint.Align.LEFT, null);
|
_keySubLabelPaint = initLabelPaint(Paint.Align.LEFT, null);
|
||||||
Typeface specialKeysFont = ((Keyboard2)getContext()).getSpecialKeyFont();
|
Typeface specialKeysFont = ((Keyboard2)getContext()).getSpecialKeyFont();
|
||||||
_specialKeyLabelPaint = initLabelPaint(Paint.Align.CENTER, specialKeysFont);
|
_specialKeyLabelPaint = initLabelPaint(Paint.Align.CENTER, specialKeysFont);
|
||||||
_specialKeySubLabelPaint = initLabelPaint(Paint.Align.LEFT, specialKeysFont);
|
_specialKeySubLabelPaint = initLabelPaint(Paint.Align.LEFT, specialKeysFont);
|
||||||
if (kw != null)
|
if (kw != null)
|
||||||
setKeyboard(kw); // handle layout options then calls reset().
|
setKeyboard(kw); // handle layout options then calls reset().
|
||||||
}
|
}
|
||||||
|
|
||||||
private Paint initLabelPaint(Paint.Align align, Typeface font)
|
private Paint initLabelPaint(Paint.Align align, Typeface font)
|
||||||
{
|
{
|
||||||
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||||
paint.setTextAlign(align);
|
paint.setTextAlign(align);
|
||||||
if (font != null)
|
if (font != null)
|
||||||
paint.setTypeface(font);
|
paint.setTypeface(font);
|
||||||
return (paint);
|
return (paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeyboard(KeyboardData kw)
|
public void setKeyboard(KeyboardData kw)
|
||||||
{
|
{
|
||||||
if (!_config.shouldOfferSwitchingToNextInputMethod)
|
if (!_config.shouldOfferSwitchingToNextInputMethod)
|
||||||
kw = kw.removeKeys(new KeyboardData.RemoveKeysByEvent(KeyValue.EVENT_CHANGE_METHOD));
|
kw = kw.removeKeys(new KeyboardData.RemoveKeysByEvent(KeyValue.EVENT_CHANGE_METHOD));
|
||||||
@ -102,155 +102,155 @@ public class Keyboard2View extends View
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
_flags = 0;
|
_flags = 0;
|
||||||
_downKeys.clear();
|
_downKeys.clear();
|
||||||
requestLayout();
|
requestLayout();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onTouch(View v, MotionEvent event)
|
public boolean onTouch(View v, MotionEvent event)
|
||||||
{
|
{
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
float keyW;
|
float keyW;
|
||||||
int p;
|
int p;
|
||||||
|
|
||||||
switch (event.getActionMasked())
|
switch (event.getActionMasked())
|
||||||
{
|
{
|
||||||
case MotionEvent.ACTION_UP:
|
case MotionEvent.ACTION_UP:
|
||||||
case MotionEvent.ACTION_POINTER_UP:
|
case MotionEvent.ACTION_POINTER_UP:
|
||||||
onTouchUp(event.getPointerId(event.getActionIndex()));
|
onTouchUp(event.getPointerId(event.getActionIndex()));
|
||||||
break ;
|
break ;
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
case MotionEvent.ACTION_POINTER_DOWN:
|
case MotionEvent.ACTION_POINTER_DOWN:
|
||||||
p = event.getActionIndex();
|
p = event.getActionIndex();
|
||||||
onTouchDown(event.getX(p), event.getY(p), event.getPointerId(p));
|
onTouchDown(event.getX(p), event.getY(p), event.getPointerId(p));
|
||||||
break ;
|
break ;
|
||||||
case MotionEvent.ACTION_MOVE:
|
case MotionEvent.ACTION_MOVE:
|
||||||
for (p = 0; p < event.getPointerCount(); p++)
|
for (p = 0; p < event.getPointerCount(); p++)
|
||||||
onTouchMove(event.getX(p), event.getY(p), event.getPointerId(p));
|
onTouchMove(event.getX(p), event.getY(p), event.getPointerId(p));
|
||||||
break ;
|
break ;
|
||||||
default:
|
default:
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyDown getKeyDown(int pointerId)
|
private KeyDown getKeyDown(int pointerId)
|
||||||
{
|
{
|
||||||
for (KeyDown k : _downKeys)
|
for (KeyDown k : _downKeys)
|
||||||
{
|
{
|
||||||
if (k.pointerId == pointerId)
|
if (k.pointerId == pointerId)
|
||||||
return (k);
|
return (k);
|
||||||
}
|
}
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyDown getKeyDown(KeyboardData.Key key)
|
private KeyDown getKeyDown(KeyboardData.Key key)
|
||||||
{
|
{
|
||||||
for (KeyDown k : _downKeys)
|
for (KeyDown k : _downKeys)
|
||||||
{
|
{
|
||||||
if (k.key == key)
|
if (k.key == key)
|
||||||
return (k);
|
return (k);
|
||||||
}
|
}
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private KeyDown getKeyDown(KeyValue kv)
|
private KeyDown getKeyDown(KeyValue kv)
|
||||||
{
|
{
|
||||||
for (KeyDown k : _downKeys)
|
for (KeyDown k : _downKeys)
|
||||||
{
|
{
|
||||||
if (k.value == kv)
|
if (k.value == kv)
|
||||||
return (k);
|
return (k);
|
||||||
}
|
}
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTouchMove(float moveX, float moveY, int pointerId)
|
private void onTouchMove(float moveX, float moveY, int pointerId)
|
||||||
{
|
{
|
||||||
KeyDown key = getKeyDown(pointerId);
|
KeyDown key = getKeyDown(pointerId);
|
||||||
KeyValue newValue;
|
KeyValue newValue;
|
||||||
|
|
||||||
if (key != null)
|
if (key != null)
|
||||||
{
|
{
|
||||||
moveX -= key.downX;
|
moveX -= key.downX;
|
||||||
moveY -= key.downY;
|
moveY -= key.downY;
|
||||||
float absDist = Math.abs(moveX) + Math.abs(moveY);
|
float absDist = Math.abs(moveX) + Math.abs(moveY);
|
||||||
key.ptrDist = absDist;
|
key.ptrDist = absDist;
|
||||||
if (absDist < _config.subValueDist)
|
if (absDist < _config.subValueDist)
|
||||||
newValue = key.key.key0;
|
newValue = key.key.key0;
|
||||||
else if (moveX < 0)
|
else if (moveX < 0)
|
||||||
newValue = (moveY < 0) ? key.key.key1 : key.key.key3;
|
newValue = (moveY < 0) ? key.key.key1 : key.key.key3;
|
||||||
else if (moveY < 0)
|
else if (moveY < 0)
|
||||||
newValue = key.key.key2;
|
newValue = key.key.key2;
|
||||||
else
|
else
|
||||||
newValue = key.key.key4;
|
newValue = key.key.key4;
|
||||||
if (newValue != null && newValue != key.value)
|
if (newValue != null && newValue != key.value)
|
||||||
{
|
{
|
||||||
if (key.timeoutWhat != -1)
|
if (key.timeoutWhat != -1)
|
||||||
{
|
{
|
||||||
_handler.removeMessages(key.timeoutWhat);
|
_handler.removeMessages(key.timeoutWhat);
|
||||||
if ((newValue.flags & KeyValue.FLAG_NOREPEAT) == 0)
|
if ((newValue.flags & KeyValue.FLAG_NOREPEAT) == 0)
|
||||||
_handler.sendEmptyMessageDelayed(key.timeoutWhat, _config.longPressTimeout);
|
_handler.sendEmptyMessageDelayed(key.timeoutWhat, _config.longPressTimeout);
|
||||||
}
|
}
|
||||||
key.value = newValue;
|
key.value = newValue;
|
||||||
key.flags = newValue.flags;
|
key.flags = newValue.flags;
|
||||||
updateFlags();
|
updateFlags();
|
||||||
invalidate();
|
invalidate();
|
||||||
handleKeyDown(newValue);
|
handleKeyDown(newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTouchDown(float touchX, float touchY, int pointerId)
|
private void onTouchDown(float touchX, float touchY, int pointerId)
|
||||||
{
|
{
|
||||||
float y = _config.marginTop - _config.keyHeight;
|
float y = _config.marginTop - _config.keyHeight;
|
||||||
for (KeyboardData.Row row : _keyboard.rows)
|
for (KeyboardData.Row row : _keyboard.rows)
|
||||||
{
|
{
|
||||||
y += _config.keyHeight;
|
y += _config.keyHeight;
|
||||||
if (touchY < y || touchY >= (y + _config.keyHeight))
|
if (touchY < y || touchY >= (y + _config.keyHeight))
|
||||||
continue ;
|
continue ;
|
||||||
float x = _config.horizontalMargin;
|
float x = _config.horizontalMargin;
|
||||||
for (KeyboardData.Key key : row.keys)
|
for (KeyboardData.Key key : row.keys)
|
||||||
{
|
{
|
||||||
x += key.shift * _keyWidth;
|
x += key.shift * _keyWidth;
|
||||||
float keyW = _keyWidth * key.width;
|
float keyW = _keyWidth * key.width;
|
||||||
if (touchX >= x && touchX < (x + keyW))
|
if (touchX >= x && touchX < (x + keyW))
|
||||||
{
|
{
|
||||||
int what = _currentWhat++;
|
int what = _currentWhat++;
|
||||||
if (key.key0 != null && (key.key0.flags & KeyValue.FLAG_NOREPEAT) == 0)
|
if (key.key0 != null && (key.key0.flags & KeyValue.FLAG_NOREPEAT) == 0)
|
||||||
_handler.sendEmptyMessageDelayed(what, _config.longPressTimeout);
|
_handler.sendEmptyMessageDelayed(what, _config.longPressTimeout);
|
||||||
_downKeys.add(new KeyDown(pointerId, key, touchX, touchY, what));
|
_downKeys.add(new KeyDown(pointerId, key, touchX, touchY, what));
|
||||||
handleKeyDown(key.key0);
|
handleKeyDown(key.key0);
|
||||||
updateFlags();
|
updateFlags();
|
||||||
invalidate();
|
invalidate();
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
x += keyW;
|
x += keyW;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whether a key is already activated (key down but pointer up)
|
// Whether a key is already activated (key down but pointer up)
|
||||||
private KeyDown getActivatedKey(KeyValue kv)
|
private KeyDown getActivatedKey(KeyValue kv)
|
||||||
{
|
{
|
||||||
for (KeyDown k : _downKeys)
|
for (KeyDown k : _downKeys)
|
||||||
{
|
{
|
||||||
if (k.value == kv && k.pointerId == -1)
|
if (k.value == kv && k.pointerId == -1)
|
||||||
return (k);
|
return (k);
|
||||||
}
|
}
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTouchUp(int pointerId)
|
private void onTouchUp(int pointerId)
|
||||||
{
|
{
|
||||||
KeyDown k = getKeyDown(pointerId);
|
KeyDown k = getKeyDown(pointerId);
|
||||||
|
|
||||||
if (k != null)
|
if (k != null)
|
||||||
{
|
{
|
||||||
// Stop key repeat
|
// Stop key repeat
|
||||||
if (k.timeoutWhat != -1)
|
if (k.timeoutWhat != -1)
|
||||||
{
|
{
|
||||||
@ -295,55 +295,55 @@ public class Keyboard2View extends View
|
|||||||
}
|
}
|
||||||
updateFlags();
|
updateFlags();
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleKeyUp(KeyDown key)
|
private void handleKeyUp(KeyDown key)
|
||||||
{
|
{
|
||||||
if (key.value != null && (key.flags & (KeyValue.FLAG_LOCKED | KeyValue.FLAG_NOCHAR)) == 0)
|
if (key.value != null && (key.flags & (KeyValue.FLAG_LOCKED | KeyValue.FLAG_NOCHAR)) == 0)
|
||||||
((Keyboard2)getContext()).handleKeyUp(key.value, _flags);
|
((Keyboard2)getContext()).handleKeyUp(key.value, _flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleKeyDown(KeyValue key)
|
private void handleKeyDown(KeyValue key)
|
||||||
{
|
{
|
||||||
if (key == null)
|
if (key == null)
|
||||||
return ;
|
return ;
|
||||||
vibrate();
|
vibrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateFlags()
|
private void updateFlags()
|
||||||
{
|
{
|
||||||
_flags = 0;
|
_flags = 0;
|
||||||
for (KeyDown k : _downKeys)
|
for (KeyDown k : _downKeys)
|
||||||
_flags |= k.flags;
|
_flags |= k.flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void vibrate()
|
private void vibrate()
|
||||||
{
|
{
|
||||||
if (!_config.vibrateEnabled)
|
if (!_config.vibrateEnabled)
|
||||||
return ;
|
return ;
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if ((now - _lastVibration) > VIBRATE_MIN_INTERVAL)
|
if ((now - _lastVibration) > VIBRATE_MIN_INTERVAL)
|
||||||
{
|
{
|
||||||
_lastVibration = now;
|
_lastVibration = now;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_vibratorService.vibrate(_config.vibrateDuration);
|
_vibratorService.vibrate(_config.vibrateDuration);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMessage(Message msg)
|
public boolean handleMessage(Message msg)
|
||||||
{
|
{
|
||||||
for (KeyDown key : _downKeys)
|
for (KeyDown key : _downKeys)
|
||||||
{
|
{
|
||||||
if (key.timeoutWhat == msg.what)
|
if (key.timeoutWhat == msg.what)
|
||||||
{
|
{
|
||||||
long nextInterval = _config.longPressInterval;
|
long nextInterval = _config.longPressInterval;
|
||||||
if (_config.preciseRepeat && (key.flags & KeyValue.FLAG_PRECISE_REPEAT) != 0)
|
if (_config.preciseRepeat && (key.flags & KeyValue.FLAG_PRECISE_REPEAT) != 0)
|
||||||
{
|
{
|
||||||
@ -351,17 +351,17 @@ public class Keyboard2View extends View
|
|||||||
float accel = Math.min(4.f, Math.max(0.3f, key.ptrDist / (_config.subValueDist * 15.f)));
|
float accel = Math.min(4.f, Math.max(0.3f, key.ptrDist / (_config.subValueDist * 15.f)));
|
||||||
nextInterval = (long)((float)nextInterval / accel);
|
nextInterval = (long)((float)nextInterval / accel);
|
||||||
}
|
}
|
||||||
_handler.sendEmptyMessageDelayed(msg.what, nextInterval);
|
_handler.sendEmptyMessageDelayed(msg.what, nextInterval);
|
||||||
((Keyboard2)getContext()).handleKeyUp(key.value, _flags);
|
((Keyboard2)getContext()).handleKeyUp(key.value, _flags);
|
||||||
return (true);
|
return (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMeasure(int wSpec, int hSpec)
|
public void onMeasure(int wSpec, int hSpec)
|
||||||
{
|
{
|
||||||
DisplayMetrics dm = getContext().getResources().getDisplayMetrics();
|
DisplayMetrics dm = getContext().getResources().getDisplayMetrics();
|
||||||
int width = dm.widthPixels;
|
int width = dm.widthPixels;
|
||||||
int height =
|
int height =
|
||||||
@ -370,49 +370,49 @@ public class Keyboard2View extends View
|
|||||||
+ _config.marginTop + _config.marginBottom);
|
+ _config.marginTop + _config.marginBottom);
|
||||||
setMeasuredDimension(width, height);
|
setMeasuredDimension(width, height);
|
||||||
_keyWidth = (width - (_config.horizontalMargin * 2)) / _keyboard.keysWidth;
|
_keyWidth = (width - (_config.horizontalMargin * 2)) / _keyboard.keysWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDraw(Canvas canvas)
|
protected void onDraw(Canvas canvas)
|
||||||
{
|
{
|
||||||
float y = _config.marginTop;
|
float y = _config.marginTop;
|
||||||
for (KeyboardData.Row row : _keyboard.rows)
|
for (KeyboardData.Row row : _keyboard.rows)
|
||||||
{
|
{
|
||||||
y += row.shift * _config.keyHeight;
|
y += row.shift * _config.keyHeight;
|
||||||
float x = _config.horizontalMargin;
|
float x = _config.horizontalMargin;
|
||||||
float keyH = row.height * _config.keyHeight;
|
float keyH = row.height * _config.keyHeight;
|
||||||
for (KeyboardData.Key k : row.keys)
|
for (KeyboardData.Key k : row.keys)
|
||||||
{
|
{
|
||||||
x += k.shift * _keyWidth + _config.keyHorizontalInterval;
|
x += k.shift * _keyWidth + _config.keyHorizontalInterval;
|
||||||
float keyW = _keyWidth * k.width - _config.keyHorizontalInterval;
|
float keyW = _keyWidth * k.width - _config.keyHorizontalInterval;
|
||||||
KeyDown keyDown = getKeyDown(k);
|
KeyDown keyDown = getKeyDown(k);
|
||||||
_tmpRect.set(x, y, x + keyW, y + keyH);
|
_tmpRect.set(x, y, x + keyW, y + keyH);
|
||||||
if (keyDown != null)
|
if (keyDown != null)
|
||||||
canvas.drawRect(_tmpRect, _keyDownBgPaint);
|
canvas.drawRect(_tmpRect, _keyDownBgPaint);
|
||||||
else
|
else
|
||||||
canvas.drawRoundRect(_tmpRect, _config.keyRound, _config.keyRound, _keyBgPaint);
|
canvas.drawRoundRect(_tmpRect, _config.keyRound, _config.keyRound, _keyBgPaint);
|
||||||
if (k.key0 != null)
|
if (k.key0 != null)
|
||||||
drawLabel(canvas, k.key0, keyW / 2f + x, (keyH + _labelTextSize) / 2f + y, keyDown);
|
drawLabel(canvas, k.key0, keyW / 2f + x, (keyH + _labelTextSize) / 2f + y, keyDown);
|
||||||
float subPadding = _config.keyPadding;
|
float subPadding = _config.keyPadding;
|
||||||
if (k.key1 != null)
|
if (k.key1 != null)
|
||||||
drawSubLabel(canvas, k.key1, x + subPadding, y + subPadding, false, true, keyDown);
|
drawSubLabel(canvas, k.key1, x + subPadding, y + subPadding, false, true, keyDown);
|
||||||
if (k.key3 != null)
|
if (k.key3 != null)
|
||||||
drawSubLabel(canvas, k.key3, x + subPadding, y + keyH - subPadding, false, false, keyDown);
|
drawSubLabel(canvas, k.key3, x + subPadding, y + keyH - subPadding, false, false, keyDown);
|
||||||
if (k.key2 != null)
|
if (k.key2 != null)
|
||||||
drawSubLabel(canvas, k.key2, x + keyW - subPadding, y + subPadding, true, true, keyDown);
|
drawSubLabel(canvas, k.key2, x + keyW - subPadding, y + subPadding, true, true, keyDown);
|
||||||
if (k.key4 != null)
|
if (k.key4 != null)
|
||||||
drawSubLabel(canvas, k.key4, x + keyW - subPadding, y + keyH - subPadding, true, false, keyDown);
|
drawSubLabel(canvas, k.key4, x + keyW - subPadding, y + keyH - subPadding, true, false, keyDown);
|
||||||
x += keyW;
|
x += keyW;
|
||||||
}
|
}
|
||||||
y += keyH + _config.keyVerticalInterval;
|
y += keyH + _config.keyVerticalInterval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDetachedFromWindow()
|
public void onDetachedFromWindow()
|
||||||
{
|
{
|
||||||
super.onDetachedFromWindow();
|
super.onDetachedFromWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int labelColor(KeyValue k, KeyDown hasKeyDown, int defaultColor)
|
private int labelColor(KeyValue k, KeyDown hasKeyDown, int defaultColor)
|
||||||
{
|
{
|
||||||
@ -430,17 +430,17 @@ public class Keyboard2View extends View
|
|||||||
return defaultColor;
|
return defaultColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawLabel(Canvas canvas, KeyValue k, float x, float y, KeyDown keyDown)
|
private void drawLabel(Canvas canvas, KeyValue k, float x, float y, KeyDown keyDown)
|
||||||
{
|
{
|
||||||
k = KeyModifier.handleFlags(k, _flags);
|
k = KeyModifier.handleFlags(k, _flags);
|
||||||
Paint p = ((k.flags & KeyValue.FLAG_KEY_FONT) != 0) ? _specialKeyLabelPaint : _keyLabelPaint;
|
Paint p = ((k.flags & KeyValue.FLAG_KEY_FONT) != 0) ? _specialKeyLabelPaint : _keyLabelPaint;
|
||||||
p.setColor(labelColor(k, keyDown, _labelColor));
|
p.setColor(labelColor(k, keyDown, _labelColor));
|
||||||
p.setTextSize(_labelTextSize * scaleTextSize(k));
|
p.setTextSize(_labelTextSize * scaleTextSize(k));
|
||||||
canvas.drawText(k.symbol, x, y, p);
|
canvas.drawText(k.symbol, x, y, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawSubLabel(Canvas canvas, KeyValue k, float x, float y, boolean right, boolean up, KeyDown keyDown)
|
private void drawSubLabel(Canvas canvas, KeyValue k, float x, float y, boolean right, boolean up, KeyDown keyDown)
|
||||||
{
|
{
|
||||||
k = KeyModifier.handleFlags(k, _flags);
|
k = KeyModifier.handleFlags(k, _flags);
|
||||||
Paint p = ((k.flags & KeyValue.FLAG_KEY_FONT) != 0) ? _specialKeySubLabelPaint : _keySubLabelPaint;
|
Paint p = ((k.flags & KeyValue.FLAG_KEY_FONT) != 0) ? _specialKeySubLabelPaint : _keySubLabelPaint;
|
||||||
p.setColor(labelColor(k, keyDown, _subLabelColor));
|
p.setColor(labelColor(k, keyDown, _subLabelColor));
|
||||||
@ -448,36 +448,36 @@ public class Keyboard2View extends View
|
|||||||
p.setTextSize(_sublabelTextSize * scaleTextSize(k));
|
p.setTextSize(_sublabelTextSize * scaleTextSize(k));
|
||||||
y -= up ? p.ascent() : p.descent();
|
y -= up ? p.ascent() : p.descent();
|
||||||
canvas.drawText(k.symbol, x, y, p);
|
canvas.drawText(k.symbol, x, y, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float scaleTextSize(KeyValue k)
|
private float scaleTextSize(KeyValue k)
|
||||||
{
|
{
|
||||||
return (k.symbol.length() < 2) ? 1.f : 0.8f;
|
return (k.symbol.length() < 2) ? 1.f : 0.8f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class KeyDown
|
private static class KeyDown
|
||||||
{
|
{
|
||||||
/* -1 if pointer is up. */
|
/* -1 if pointer is up. */
|
||||||
public int pointerId;
|
public int pointerId;
|
||||||
public KeyValue value;
|
public KeyValue value;
|
||||||
public KeyboardData.Key key;
|
public KeyboardData.Key key;
|
||||||
public float downX;
|
public float downX;
|
||||||
public float downY;
|
public float downY;
|
||||||
/* Manhattan distance of the pointer to the center of the key */
|
/* Manhattan distance of the pointer to the center of the key */
|
||||||
public float ptrDist;
|
public float ptrDist;
|
||||||
public int flags;
|
public int flags;
|
||||||
public int timeoutWhat;
|
public int timeoutWhat;
|
||||||
|
|
||||||
public KeyDown(int pointerId, KeyboardData.Key key, float x, float y, int what)
|
public KeyDown(int pointerId, KeyboardData.Key key, float x, float y, int what)
|
||||||
{
|
{
|
||||||
this.pointerId = pointerId;
|
this.pointerId = pointerId;
|
||||||
value = key.key0;
|
value = key.key0;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
downX = x;
|
downX = x;
|
||||||
downY = y;
|
downY = y;
|
||||||
ptrDist = 0.f;
|
ptrDist = 0.f;
|
||||||
flags = (value == null) ? 0 : value.flags;
|
flags = (value == null) ? 0 : value.flags;
|
||||||
timeoutWhat = what;
|
timeoutWhat = what;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||||||
|
|
||||||
class KeyboardData
|
class KeyboardData
|
||||||
{
|
{
|
||||||
public final List<Row> rows;
|
public final List<Row> rows;
|
||||||
/* Total width of the keyboard. Unit is abstract. */
|
/* Total width of the keyboard. Unit is abstract. */
|
||||||
public final float keysWidth;
|
public final float keysWidth;
|
||||||
/* Total height of the keyboard. Unit is abstract. */
|
/* Total height of the keyboard. Unit is abstract. */
|
||||||
@ -26,54 +26,54 @@ class KeyboardData
|
|||||||
keysHeight = kh;
|
keysHeight = kh;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KeyboardData parse(XmlResourceParser parser)
|
public static KeyboardData parse(XmlResourceParser parser)
|
||||||
{
|
{
|
||||||
ArrayList<Row> rows = new ArrayList<Row>();
|
ArrayList<Row> rows = new ArrayList<Row>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
while (parser.next() != XmlResourceParser.START_TAG)
|
while (parser.next() != XmlResourceParser.START_TAG)
|
||||||
continue ;
|
continue ;
|
||||||
if (!parser.getName().equals("keyboard"))
|
if (!parser.getName().equals("keyboard"))
|
||||||
throw new Exception("Unknow tag: " + parser.getName());
|
throw new Exception("Unknow tag: " + parser.getName());
|
||||||
while ((status = parser.next()) != XmlResourceParser.END_DOCUMENT)
|
while ((status = parser.next()) != XmlResourceParser.END_DOCUMENT)
|
||||||
{
|
{
|
||||||
if (status == XmlResourceParser.START_TAG)
|
if (status == XmlResourceParser.START_TAG)
|
||||||
{
|
{
|
||||||
String tag = parser.getName();
|
String tag = parser.getName();
|
||||||
if (tag.equals("row"))
|
if (tag.equals("row"))
|
||||||
rows.add(Row.parse(parser));
|
rows.add(Row.parse(parser));
|
||||||
else
|
else
|
||||||
throw new Exception("Unknow keyboard tag: " + tag);
|
throw new Exception("Unknow keyboard tag: " + tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return new KeyboardData(rows);
|
return new KeyboardData(rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyboardData removeKeys(MapKeys f)
|
public KeyboardData removeKeys(MapKeys f)
|
||||||
{
|
{
|
||||||
ArrayList<Row> rows_ = new ArrayList<Row>();
|
ArrayList<Row> rows_ = new ArrayList<Row>();
|
||||||
for (Row r : rows)
|
for (Row r : rows)
|
||||||
rows_.add(r.removeKeys(f));
|
rows_.add(r.removeKeys(f));
|
||||||
return new KeyboardData(rows_);
|
return new KeyboardData(rows_);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Row
|
public static class Row
|
||||||
{
|
{
|
||||||
public final List<Key> keys;
|
public final List<Key> keys;
|
||||||
/* Height of the row. Unit is abstract. */
|
/* Height of the row. Unit is abstract. */
|
||||||
public final float height;
|
public final float height;
|
||||||
/* Extra empty space on the top. */
|
/* Extra empty space on the top. */
|
||||||
public final float shift;
|
public final float shift;
|
||||||
/* Total width of very keys. Unit is abstract. */
|
/* Total width of very keys. Unit is abstract. */
|
||||||
private final float keysWidth;
|
private final float keysWidth;
|
||||||
|
|
||||||
public Row(List<Key> keys_, float h, float s)
|
public Row(List<Key> keys_, float h, float s)
|
||||||
{
|
{
|
||||||
@ -85,25 +85,25 @@ class KeyboardData
|
|||||||
keysWidth = kw;
|
keysWidth = kw;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Row parse(XmlResourceParser parser) throws Exception
|
public static Row parse(XmlResourceParser parser) throws Exception
|
||||||
{
|
{
|
||||||
ArrayList<Key> keys = new ArrayList<Key>();
|
ArrayList<Key> keys = new ArrayList<Key>();
|
||||||
int status;
|
int status;
|
||||||
float h = parser.getAttributeFloatValue(null, "height", 1f);
|
float h = parser.getAttributeFloatValue(null, "height", 1f);
|
||||||
float shift = parser.getAttributeFloatValue(null, "shift", 0f);
|
float shift = parser.getAttributeFloatValue(null, "shift", 0f);
|
||||||
while ((status = parser.next()) != XmlResourceParser.END_TAG)
|
while ((status = parser.next()) != XmlResourceParser.END_TAG)
|
||||||
{
|
{
|
||||||
if (status == XmlResourceParser.START_TAG)
|
if (status == XmlResourceParser.START_TAG)
|
||||||
{
|
{
|
||||||
String tag = parser.getName();
|
String tag = parser.getName();
|
||||||
if (tag.equals("key"))
|
if (tag.equals("key"))
|
||||||
keys.add(Key.parse(parser));
|
keys.add(Key.parse(parser));
|
||||||
else
|
else
|
||||||
throw new Exception("Unknow row tag: " + tag);
|
throw new Exception("Unknow row tag: " + tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Row(keys, h, shift);
|
return new Row(keys, h, shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Row removeKeys(MapKeys f)
|
public Row removeKeys(MapKeys f)
|
||||||
{
|
{
|
||||||
@ -112,7 +112,7 @@ class KeyboardData
|
|||||||
keys_.add(k.removeKeys(f));
|
keys_.add(k.removeKeys(f));
|
||||||
return new Row(keys_, height, shift);
|
return new Row(keys_, height, shift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Key
|
public static class Key
|
||||||
{
|
{
|
||||||
|
@ -5,10 +5,10 @@ import android.preference.PreferenceActivity;
|
|||||||
|
|
||||||
public class SettingsActivity extends PreferenceActivity
|
public class SettingsActivity extends PreferenceActivity
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState)
|
public void onCreate(Bundle savedInstanceState)
|
||||||
{
|
{
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
addPreferencesFromResource(R.xml.settings);
|
addPreferencesFromResource(R.xml.settings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user