OSDN Git Service

Ver.1.3.0.0:
[nicownn/NicoWnn.git] / src / com / hiroshica / android / input / nicownn2 / DefaultSoftKeyboard.java
index f3dc83b..16ba92e 100644 (file)
@@ -193,7 +193,7 @@ public class DefaultSoftKeyboard implements InputViewManager, KeyboardView.OnKey
                private static final long serialVersionUID = 1L;
                {
                        put("none_flick", 0);
-                       //put("normal_stroke", 1);
+                       put("normal_stroke", 1);
                        put("nico_stroke", 2);
                }};
        
@@ -202,6 +202,7 @@ public class DefaultSoftKeyboard implements InputViewManager, KeyboardView.OnKey
        private GestureDetector   mDetector;
        private float             mStartX, mStartY;
        private float             mGestureX, mGestureY;
+       private boolean           mIsLongPress;
        //private static final int ya_flick[] = { 0, 2, -1, 1, -1 };
        //private static final int wa_flick[] = { 0, -1, 1, 2, 5 };
        /**
@@ -697,7 +698,12 @@ public class DefaultSoftKeyboard implements InputViewManager, KeyboardView.OnKey
                }
                // entry gesture detector
                mDetector = new GestureDetector(this);
-               mDetector.setIsLongpressEnabled(false);
+               if (NICOFLICK_1STROKE == mFlickNicoInput) {
+                       mDetector.setIsLongpressEnabled(true);
+               }
+               else{
+                       mDetector.setIsLongpressEnabled(false);
+               }
                mMetrics.setToDefaults();
                //changeKeyboardKeyHeight();
                return mMainView;
@@ -838,7 +844,15 @@ public class DefaultSoftKeyboard implements InputViewManager, KeyboardView.OnKey
                }
                mFlickNicoInput       = flickModeTable.get(pref.getString("nicoflick_mode", "none_flick"));
                mFlickSensivity       = (float)flickSensivityModeTable.get(pref.getString("flick_sensivity_mode", "sensitivity_value_2"));
-
+               if (null != mDetector) {
+                       if (NICOFLICK_1STROKE == mFlickNicoInput) {
+                       
+                               mDetector.setIsLongpressEnabled(true);
+                       }
+                       else{
+                               mDetector.setIsLongpressEnabled(false);
+                       }
+               }
                /* pop-up preview */
                mKeyboardView.setPreviewEnabled(pref.getBoolean("popup_preview", true));
        }
@@ -1000,18 +1014,18 @@ public class DefaultSoftKeyboard implements InputViewManager, KeyboardView.OnKey
                mStartY = ev.getRawY();
                mGestureX = mStartX;
                mGestureY = mStartY;
-               //Log.d("NicoWnn", "onDown " + mStartX + "/" + mStartY);
+               mIsLongPress = false;
                return true;
        }
        public boolean onFling(MotionEvent ev1, MotionEvent ev2, float getX, float getY){
                return true;
        }
        public void    onLongPress(MotionEvent ev){
+               mIsLongPress = true;
        }
        public boolean onScroll(MotionEvent ev1, MotionEvent ev2, float distX, float distY){
                mGestureX = ev2.getRawX();
                mGestureY = ev2.getRawY();
-               //Log.d("NicoWnn", "get " + (mGestureX - mStartX) + "/" + (mGestureY - mStartY));
                return true;
        }
        public void    onShowPress(MotionEvent ev){
@@ -1026,18 +1040,38 @@ public class DefaultSoftKeyboard implements InputViewManager, KeyboardView.OnKey
                if (NICOFLICK_NONE == mFlickNicoInput) {
                        return -1;
                }
-               if (mCurrentKeyMode != KEYMODE_JA_FULL_NICO) {
+               if (!((mCurrentKeyMode == KEYMODE_JA_FULL_NICO) || (mCurrentKeyMode == KEYMODE_JA_HALF_ALPHABET))) {
                        return -1;
                }
                if (true == mNicoFirst) {
                        return -1;
                }
+               // check 12key
+               switch (mPrevInputKeyCode) {
+               case KEYCODE_JP12_1:    // A
+               case KEYCODE_JP12_2:    // Ka
+               case KEYCODE_JP12_3:    // Sa
+               case KEYCODE_JP12_4:    // Ta
+               case KEYCODE_JP12_5:    // Na
+               case KEYCODE_JP12_6:    // Ha
+               case KEYCODE_JP12_7:    // Ma
+               case KEYCODE_JP12_8:    // Ya
+               case KEYCODE_JP12_9:    // Ra
+               case KEYCODE_JP12_0:    // Wa
+                       break;
+               default:
+                       return -1;
+               }
                /**
                 * creation flick keys
                 */
                float calcx, calcy;
-               calcx = (mGestureX - mStartX) * mMetrics.scaledDensity;
-               calcy = (mGestureY - mStartY) * mMetrics.scaledDensity;
+               //calcx = (mGestureX - mStartX) * mMetrics.scaledDensity;
+               //calcy = (mGestureY - mStartY) * mMetrics.scaledDensity;
+               calcx = (mGestureX - mStartX);
+               calcy = (mGestureY - mStartY);
+               //Log.d("NicoWnn", "checkFlick " + calcx + "/" + calcy);
+
                float length = FloatMath.sqrt((calcx * calcx) + (calcy * calcy));
                double rotation;
                rotation = Math.atan2(calcy, calcx);
@@ -1048,9 +1082,13 @@ public class DefaultSoftKeyboard implements InputViewManager, KeyboardView.OnKey
                }
                // change rotate -> keycode
                int keycode = -1;
-               if (length < 30.0) {
-                       //keycode = 0;
-                       keycode = -1;
+               if (length < mFlickSensivity) {
+                       if (false == mIsLongPress) {
+                               keycode = 0;
+                       }
+                       else{
+                               keycode = -1;
+                       }
                }
                else {
                        if (getrot >= 45.0f && getrot < 135.0f) {
@@ -1065,24 +1103,6 @@ public class DefaultSoftKeyboard implements InputViewManager, KeyboardView.OnKey
                        else {
                                keycode = 4;
                        }
-                       // convert keycode
-                       switch (mPrevInputKeyCode) {
-                       case KEYCODE_JP12_1:    // A
-                       case KEYCODE_JP12_2:    // Ka
-                       case KEYCODE_JP12_3:    // Sa
-                       case KEYCODE_JP12_4:    // Ta
-                       case KEYCODE_JP12_5:    // Na
-                       case KEYCODE_JP12_6:    // Ha
-                       case KEYCODE_JP12_7:    // Ma
-                       case KEYCODE_JP12_9:    // Ra
-                               break;
-                       case KEYCODE_JP12_8:    // Ya
-                               //keycode = ya_flick[keycode];
-                               break;
-                       case KEYCODE_JP12_0:    // Wa
-                               //keycode = wa_flick[keycode];
-                               break;
-                       }
                }
                if (-1 != keycode) {
                        keycode = convertModeFlick(getTableIndex(mPrevInputKeyCode), keycode);