Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79d8cc49 authored by James Nylen's avatar James Nylen
Browse files

LatinIME: Add setting for long-press key delay

Change-Id: Ie4298ce484fc907deac7f6fd622bd359998082a2
parent 8f59df45
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:gravity="center_vertical"
    android:paddingRight="?android:attr/scrollbarSize">

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="15dip"
        android:layout_marginRight="16dip"
        android:layout_marginTop="6dip"
        android:layout_marginBottom="6dip"
        android:layout_weight="1">
        <TextView android:id="@+android:id/dialogMessage"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@android:id/title"
            android:layout_alignLeft="@android:id/title"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:maxLines="2" />
		<SeekBar android:id="@+android:id/myBar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_below="@android:id/dialogMessage"
            android:layout_alignLeft="@android:id/dialogMessage" />
        <TextView android:id="@+android:id/actualValue"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@android:id/myBar"
            android:layout_alignLeft="@android:id/myBar"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:maxLines="1" />
    </RelativeLayout>
</LinearLayout>
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -76,6 +76,11 @@
    <!-- Description for auto punctuate -->
    <string name="auto_punctuate_summary"></string>

    <!-- Option to set long press delay -->
    <string name="long_press_delay">Long press delay</string>
    <!-- Description for long press delay -->
    <string name="long_press_delay_summary">%d milliseconds</string>
    
    <!-- Option to enable quick fixes -->
    <string name="quick_fixes">Quick fixes</string>
    <!-- Description for quick fixes -->
+10 −0
Original line number Diff line number Diff line
@@ -61,6 +61,16 @@
            android:defaultValue="@string/settings_key_mode_auto"
            />

	<com.android.inputmethod.latin.DialogSeekBarPreference
            android:key="long_press_delay"
            android:title="@string/long_press_delay"
            android:persistent="true"
            min="100"
            max="1000"
            step="25"
            android:defaultValue="@integer/config_long_press_key_timeout"
            />

    <ListPreference
            android:key="voice_mode"
            android:title="@string/voice_input"
+110 −0
Original line number Diff line number Diff line
package com.android.inputmethod.latin;

// Kanged from ADW

import android.content.Context;
import android.content.res.TypedArray;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.SeekBar;
import android.widget.TextView;

public class DialogSeekBarPreference extends DialogPreference implements
        SeekBar.OnSeekBarChangeListener {
    private static final String androidns = "http://schemas.android.com/apk/res/android";

    private SeekBar mSeekBar;

    private TextView mValueText;

    private String mSuffix;

    private int mMax, mMin, mStep, mValue = 0;

    public DialogSeekBarPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        setPersistent(true);

        mSuffix = attrs.getAttributeValue(androidns, "text");
        mMin = attrs.getAttributeIntValue(null, "min", 0);
        mMax = attrs.getAttributeIntValue(null, "max", 100);
        mStep = attrs.getAttributeIntValue(null, "step", 1);

        setDialogLayoutResource(R.layout.my_seekbar_preference);
    }

    @Override
    protected void onBindDialogView(View v) {
        super.onBindDialogView(v);
        TextView dialogMessage = (TextView)v.findViewById(R.id.dialogMessage);
        dialogMessage.setText(getDialogMessage());

        mValueText = (TextView)v.findViewById(R.id.actualValue);

        mSeekBar = (SeekBar)v.findViewById(R.id.myBar);
        mSeekBar.setOnSeekBarChangeListener(this);
        mSeekBar.setMax((mMax - mMin) / mStep);
        mSeekBar.setProgress((mValue - mMin) / mStep);

        String t = String.valueOf(mValue);
        mValueText.setText(mSuffix == null ? t : t.concat(mSuffix));
    }

    @Override
    protected Object onGetDefaultValue(TypedArray a, int index) {
        return a.getInt(index, 0);
    }

    @Override
    protected void onSetInitialValue(boolean restore, Object defaultValue) {
        mValue = getPersistedInt(defaultValue == null ? 0 : (Integer)defaultValue);
    }

    @Override
    protected void onDialogClosed(boolean positiveResult) {
        super.onDialogClosed(positiveResult);

        if (positiveResult) {
            int value = mSeekBar.getProgress() * mStep + mMin;
            if (callChangeListener(value)) {
                setValue(value);
            }
        }
    }

    public void setValue(int value) {
        if (value > mMax) {
            value = mMax;
        } else if (value < mMin) {
            value = mMin;
        }
        mValue = value;
        persistInt(value);
    }

    public void setMax(int max) {
        mMax = max;
        if (mValue > mMax) {
            setValue(mMax);
        }
    }

    public void setMin(int min) {
        if (min < mMax) {
            mMin = min;
        }
    }

    public void onProgressChanged(SeekBar seek, int value, boolean fromTouch) {
        String t = String.valueOf(value * mStep + mMin);
        mValueText.setText(mSuffix == null ? t : t.concat(mSuffix));
    }

    public void onStartTrackingTouch(SeekBar seek) {
    }

    public void onStopTrackingTouch(SeekBar seek) {
    }

}
+5 −0
Original line number Diff line number Diff line
@@ -202,6 +202,7 @@ public class LatinIME extends InputMethodService
    private boolean mSoundOn;
    private boolean mPopupOn;
    private boolean mAutoCap;
    private int     mLongPressDelay;
    private boolean mQuickFixes;
    private boolean mHasUsedVoiceInput;
    private boolean mHasUsedVoiceInputUnsupportedLocale;
@@ -675,6 +676,7 @@ public class LatinIME extends InputMethodService
        updateCorrectionMode();

        inputView.setPreviewEnabled(mPopupOn);
        inputView.setLongPressDelay(mLongPressDelay);
        inputView.setProximityCorrectionEnabled(true);
        mPredictionOn = mPredictionOn && (mCorrectionMode > 0 || mShowSuggestions);
        // If we just entered a text field, maybe it has some old text that requires correction
@@ -2469,6 +2471,9 @@ public class LatinIME extends InputMethodService
        mPopupOn = sp.getBoolean(PREF_POPUP_ON,
                mResources.getBoolean(R.bool.default_popup_preview));
        mAutoCap = sp.getBoolean(PREF_AUTO_CAP, true);
        mLongPressDelay = sp.getInt(LatinIMESettings.PREF_LONG_PRESS_DELAY,
                getResources().getInteger(R.integer.config_long_press_key_timeout));
        Log.d(TAG, "mLongPressDelay = " + mLongPressDelay);
        mQuickFixes = sp.getBoolean(PREF_QUICK_FIXES, true);
        mHasUsedVoiceInput = sp.getBoolean(PREF_HAS_USED_VOICE_INPUT, false);
        mHasUsedVoiceInputUnsupportedLocale =
Loading