preview_enabled settings

This commit is contained in:
jaguillo 2015-10-28 22:54:38 +01:00
parent da72455d35
commit ffba149934
3 changed files with 28 additions and 12 deletions

View File

@ -23,7 +23,7 @@
<string name="pref_category_vibrate">Vibration</string> <string name="pref_category_vibrate">Vibration</string>
<string name="pref_vibrate_title">Vibration</string> <string name="pref_vibrate_title">Vibration</string>
<string name="pref_vibrate_summary">Enable/Disable vibrations</string> <string name="pref_vibrate_summary">Enable/Disable vibrations on key down</string>
<string name="pref_vibrate_duration_title">Duration</string> <string name="pref_vibrate_duration_title">Duration</string>
<string name="pref_vibrate_duration_summary">%sms</string> <string name="pref_vibrate_duration_summary">%sms</string>
@ -35,4 +35,7 @@
<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_category_preview">Preview</string>
<string name="pref_preview_title">Preview</string>
<string name="pref_preview_summary">Enable/Disable preview on key down</string>
</resources> </resources>

View File

@ -7,7 +7,8 @@
android:summary="@string/pref_layout_summary" android:summary="@string/pref_layout_summary"
android:defaultValue="azerty" android:defaultValue="azerty"
android:entries="@array/pref_layout_entries" android:entries="@array/pref_layout_entries"
android:entryValues="@array/pref_layout_values" /> android:entryValues="@array/pref_layout_values"
/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_typing"> <PreferenceCategory android:title="@string/pref_category_typing">
<juloo.common.SlideBarPreference <juloo.common.SlideBarPreference
@ -17,7 +18,7 @@
android:defaultValue="10.0" android:defaultValue="10.0"
min="5.0" min="5.0"
max="25.0" max="25.0"
/> />
<juloo.common.IntSlideBarPreference <juloo.common.IntSlideBarPreference
android:key="longpress_timeout" android:key="longpress_timeout"
android:title="@string/pref_long_timeout_title" android:title="@string/pref_long_timeout_title"
@ -25,7 +26,7 @@
android:defaultValue="600" android:defaultValue="600"
min="50" min="50"
max="2000" max="2000"
/> />
<juloo.common.IntSlideBarPreference <juloo.common.IntSlideBarPreference
android:key="longpress_interval" android:key="longpress_interval"
android:title="@string/pref_long_interval_title" android:title="@string/pref_long_interval_title"
@ -33,14 +34,15 @@
android:defaultValue="25" android:defaultValue="25"
min="5" min="5"
max="100" max="100"
/> />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_vibrate"> <PreferenceCategory android:title="@string/pref_category_vibrate">
<CheckBoxPreference <CheckBoxPreference
android:key="vibrate_enabled" android:key="vibrate_enabled"
android:title="@string/pref_vibrate_title" android:title="@string/pref_vibrate_title"
android:summary="@string/pref_vibrate_summary" android:summary="@string/pref_vibrate_summary"
android:defaultValue="true" /> android:defaultValue="true"
/>
<juloo.common.IntSlideBarPreference <juloo.common.IntSlideBarPreference
android:key="vibrate_duration" android:key="vibrate_duration"
android:title="@string/pref_vibrate_duration_title" android:title="@string/pref_vibrate_duration_title"
@ -48,7 +50,15 @@
android:defaultValue="20" android:defaultValue="20"
min="5" min="5"
max="50" max="50"
/> />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_preview">
<CheckBoxPreference
android:key="preview_enabled"
android:title="@string/pref_preview_title"
android:summary="@string/pref_preview_summary"
android:defaultValue="false"
/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_style"> <PreferenceCategory android:title="@string/pref_category_style">
<juloo.common.IntSlideBarPreference <juloo.common.IntSlideBarPreference
@ -58,7 +68,7 @@
android:defaultValue="5" android:defaultValue="5"
min="0" min="0"
max="100" max="100"
/> />
<juloo.common.IntSlideBarPreference <juloo.common.IntSlideBarPreference
android:key="key_height" android:key="key_height"
android:title="@string/pref_key_height_title" android:title="@string/pref_key_height_title"
@ -66,7 +76,7 @@
android:defaultValue="50" android:defaultValue="50"
min="30" min="30"
max="60" max="60"
/> />
<juloo.common.IntSlideBarPreference <juloo.common.IntSlideBarPreference
android:key="horizontal_margin" android:key="horizontal_margin"
android:title="@string/pref_horizontal_margin_title" android:title="@string/pref_horizontal_margin_title"
@ -74,6 +84,6 @@
android:defaultValue="3" android:defaultValue="3"
min="0" min="0"
max="20" max="20"
/> />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -41,12 +41,12 @@ public class Keyboard2View extends View
/* /*
** TODO: move config values in a Config object ** TODO: move config values in a Config object
** TODO: settings: preview_enabled
** TODO: settings: preview_text_size ** TODO: settings: preview_text_size
** TODO: settings: preview_timeout ** TODO: settings: preview_timeout
** TODO: disable preview in password fields ** TODO: disable preview in password fields
*/ */
private long _previewDismissTimeout = 150; // especialy this one private long _previewDismissTimeout = 150; // especialy this one
private boolean _previewEnabled = false;
private float _marginTop; private float _marginTop;
private float _keyWidth; private float _keyWidth;
@ -121,6 +121,7 @@ public class Keyboard2View extends View
{ {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
_previewEnabled = prefs.getBoolean("preview_enabled", _previewEnabled);
_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);
@ -316,6 +317,8 @@ public class Keyboard2View extends View
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);
// previewNextKeyDown // previewNextKeyDown
if (!_previewEnabled)
return ;
for (KeyDown k : _downKeys) for (KeyDown k : _downKeys)
if ((k.value.getFlags() & (KeyValue.FLAG_KEY_FONT | KeyValue.FLAG_NOREPEAT | KeyValue.FLAG_NOCHAR)) == 0) if ((k.value.getFlags() & (KeyValue.FLAG_KEY_FONT | KeyValue.FLAG_NOREPEAT | KeyValue.FLAG_NOCHAR)) == 0)
{ {
@ -329,7 +332,7 @@ public class Keyboard2View extends View
{ {
if (key == null) if (key == null)
return ; return ;
if ((key.getFlags() & (KeyValue.FLAG_KEY_FONT | KeyValue.FLAG_NOREPEAT | KeyValue.FLAG_NOCHAR)) == 0) if (_previewEnabled && (key.getFlags() & (KeyValue.FLAG_KEY_FONT | KeyValue.FLAG_NOREPEAT | KeyValue.FLAG_NOCHAR)) == 0)
_previewPopup.setPreview(key, _flags); _previewPopup.setPreview(key, _flags);
vibrate(); vibrate();
} }