mirror of
https://github.com/Julow/Unexpected-Keyboard.git
synced 2025-06-21 02:09:09 +02:00
More settings
This commit is contained in:
parent
6f09c971c0
commit
9d614bc4fe
@ -1,5 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<string name="app_name">Keyboard 2.0</string>
|
<string name="app_name">Keyboard 2.0</string>
|
||||||
|
|
||||||
<string name="settings_activity_label">Keyboard 2.0 Settings</string>
|
<string name="settings_activity_label">Keyboard 2.0 Settings</string>
|
||||||
@ -15,13 +16,15 @@
|
|||||||
<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_summary">%sms</string>
|
||||||
|
<string name="pref_long_interval_title">Long press interval</string>
|
||||||
|
<string name="pref_long_interval_summary">%sms</string>
|
||||||
|
|
||||||
<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</string>
|
||||||
<string name="pref_vibrate_duration_title">Duration</string>
|
<string name="pref_vibrate_duration_title">Duration</string>
|
||||||
<string name="pref_vibrate_duration_summary">Change vibrations duration</string>
|
<string name="pref_vibrate_duration_summary">%sms</string>
|
||||||
|
|
||||||
<string name="pref_category_misc">Other</string>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -14,13 +14,26 @@
|
|||||||
android:key="sub_value_dist"
|
android:key="sub_value_dist"
|
||||||
android:title="@string/pref_preci_title"
|
android:title="@string/pref_preci_title"
|
||||||
android:summary="@string/pref_preci_summary"
|
android:summary="@string/pref_preci_summary"
|
||||||
android:defaultValue="8.0"
|
android:defaultValue="10.0"
|
||||||
min="5.0"
|
min="5.0"
|
||||||
max="20.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"
|
||||||
/>
|
/>
|
||||||
<!-- Precision (sub_value_dist) -->
|
|
||||||
<!-- Key repeat timeout (longpress_timeout) -->
|
|
||||||
<!-- Key repeat interval (longpress_interval) -->
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
<PreferenceCategory android:title="@string/pref_category_vibrate">
|
<PreferenceCategory android:title="@string/pref_category_vibrate">
|
||||||
<CheckBoxPreference
|
<CheckBoxPreference
|
||||||
@ -28,9 +41,13 @@
|
|||||||
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" />
|
||||||
<!-- Duration (vibrate_duration) -->
|
<juloo.common.IntSlideBarPreference
|
||||||
</PreferenceCategory>
|
android:key="vibrate_duration"
|
||||||
<PreferenceCategory android:title="@string/pref_category_misc">
|
android:title="@string/pref_vibrate_duration_title"
|
||||||
<!-- Offset height (margin_bottom) -->
|
android:summary="@string/pref_vibrate_duration_summary"
|
||||||
|
android:defaultValue="20"
|
||||||
|
min="5"
|
||||||
|
max="50"
|
||||||
|
/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
116
srcs/juloo.common/IntSlideBarPreference.java
Normal file
116
srcs/juloo.common/IntSlideBarPreference.java
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package juloo.common;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.TypedArray;
|
||||||
|
import android.preference.DialogPreference;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.SeekBar;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** IntSlideBarPreference
|
||||||
|
** -
|
||||||
|
** Open a dialog showing a seekbar
|
||||||
|
** -
|
||||||
|
** xml attrs:
|
||||||
|
** android:defaultValue Default value (int)
|
||||||
|
** min min value (int)
|
||||||
|
** max max value (int)
|
||||||
|
** -
|
||||||
|
** Summary field allow to show the current value using %s flag
|
||||||
|
*/
|
||||||
|
public class IntSlideBarPreference extends DialogPreference
|
||||||
|
implements SeekBar.OnSeekBarChangeListener
|
||||||
|
{
|
||||||
|
private LinearLayout _layout;
|
||||||
|
private TextView _textView;
|
||||||
|
private SeekBar _seekBar;
|
||||||
|
|
||||||
|
private int _min;
|
||||||
|
|
||||||
|
private String _initialSummary;
|
||||||
|
|
||||||
|
public IntSlideBarPreference(Context context, AttributeSet attrs)
|
||||||
|
{
|
||||||
|
super(context, attrs);
|
||||||
|
_initialSummary = getSummary().toString();
|
||||||
|
_textView = new TextView(context);
|
||||||
|
_textView.setPadding(48, 40, 48, 40);
|
||||||
|
_seekBar = new SeekBar(context);
|
||||||
|
_seekBar.setOnSeekBarChangeListener(this);
|
||||||
|
_min = attrs.getAttributeIntValue(null, "min", 0);
|
||||||
|
int max = attrs.getAttributeIntValue(null, "max", 0);
|
||||||
|
_seekBar.setMax(max - _min);
|
||||||
|
_layout = new LinearLayout(getContext());
|
||||||
|
_layout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
_layout.addView(_textView);
|
||||||
|
_layout.addView(_seekBar);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
|
||||||
|
{
|
||||||
|
updateText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStartTrackingTouch(SeekBar seekBar)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopTrackingTouch(SeekBar seekBar)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onSetInitialValue(boolean restorePersistedValue, Object defaultValue)
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
|
||||||
|
if (restorePersistedValue)
|
||||||
|
{
|
||||||
|
value = getPersistedInt(_min);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = (Integer)defaultValue;
|
||||||
|
persistInt(value);
|
||||||
|
}
|
||||||
|
_seekBar.setProgress(value - _min);
|
||||||
|
updateText();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object onGetDefaultValue(TypedArray a, int index)
|
||||||
|
{
|
||||||
|
return (a.getInt(index, _min));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDialogClosed(boolean positiveResult)
|
||||||
|
{
|
||||||
|
if (positiveResult)
|
||||||
|
persistInt(_seekBar.getProgress() + _min);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected View onCreateDialogView()
|
||||||
|
{
|
||||||
|
ViewGroup parent = (ViewGroup)_layout.getParent();
|
||||||
|
|
||||||
|
if (parent != null)
|
||||||
|
parent.removeView(_layout);
|
||||||
|
return (_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateText()
|
||||||
|
{
|
||||||
|
String f = String.format(_initialSummary, _seekBar.getProgress() + _min);
|
||||||
|
|
||||||
|
_textView.setText(f);
|
||||||
|
setSummary(f);
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@ import android.widget.SeekBar;
|
|||||||
public class SlideBarPreference extends DialogPreference
|
public class SlideBarPreference extends DialogPreference
|
||||||
implements SeekBar.OnSeekBarChangeListener
|
implements SeekBar.OnSeekBarChangeListener
|
||||||
{
|
{
|
||||||
private static final int SEEKBAR_MAX = 1000;
|
private static final int SEEKBAR_MAX = 100000;
|
||||||
|
|
||||||
private LinearLayout _layout;
|
private LinearLayout _layout;
|
||||||
private TextView _textView;
|
private TextView _textView;
|
||||||
|
@ -43,7 +43,7 @@ public class Keyboard2View extends View
|
|||||||
private float _keyBgPadding;
|
private float _keyBgPadding;
|
||||||
private float _keyRound;
|
private float _keyRound;
|
||||||
|
|
||||||
private float _subValueDist = 7f;
|
private float _subValueDist = 10f;
|
||||||
private boolean _vibrateEnabled = true;
|
private boolean _vibrateEnabled = true;
|
||||||
private long _vibrateDuration = 20;
|
private long _vibrateDuration = 20;
|
||||||
private long _longPressTimeout = 600;
|
private long _longPressTimeout = 600;
|
||||||
@ -86,18 +86,11 @@ public class Keyboard2View extends View
|
|||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ime);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ime);
|
||||||
|
|
||||||
_ime = ime;
|
_ime = ime;
|
||||||
try
|
|
||||||
{
|
|
||||||
_subValueDist = prefs.getFloat("sub_value_dist", _subValueDist);
|
_subValueDist = prefs.getFloat("sub_value_dist", _subValueDist);
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
_subValueDist = 7.0f;
|
|
||||||
}
|
|
||||||
_vibrateEnabled = prefs.getBoolean("vibrate_enabled", _vibrateEnabled);
|
_vibrateEnabled = prefs.getBoolean("vibrate_enabled", _vibrateEnabled);
|
||||||
_vibrateDuration = prefs.getLong("vibrate_duration", _vibrateDuration);
|
_vibrateDuration = prefs.getInt("vibrate_duration", (int)_vibrateDuration);
|
||||||
_longPressTimeout = prefs.getLong("longpress_timeout", _longPressTimeout);
|
_longPressTimeout = prefs.getInt("longpress_timeout", (int)_longPressTimeout);
|
||||||
_longPressInterval = prefs.getLong("longpress_interval", _longPressInterval);
|
_longPressInterval = prefs.getInt("longpress_interval", (int)_longPressInterval);
|
||||||
_marginBottom = prefs.getFloat("margin_bottom", _marginBottom);
|
_marginBottom = prefs.getFloat("margin_bottom", _marginBottom);
|
||||||
|
|
||||||
String keyboardLayout = prefs.getString("keyboard_layout", null);
|
String keyboardLayout = prefs.getString("keyboard_layout", null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user