mirror of https://github.com/axmolengine/axmol.git
Remove Accelerometer and TextEdit implementations.
This commit is contained in:
parent
4567ab96b8
commit
a10c9c74a1
|
@ -1,144 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2010-2011 cocos2d-x.org
|
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
****************************************************************************/
|
|
||||||
package org.cocos2dx.lib;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.hardware.Sensor;
|
|
||||||
import android.hardware.SensorEvent;
|
|
||||||
import android.hardware.SensorEventListener;
|
|
||||||
import android.hardware.SensorManager;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Display;
|
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.os.Build.*;
|
|
||||||
|
|
||||||
public class Cocos2dxAccelerometer implements SensorEventListener {
|
|
||||||
// ===========================================================
|
|
||||||
// Constants
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
private static final String TAG = Cocos2dxAccelerometer.class.getSimpleName();
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Fields
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
private final Context mContext;
|
|
||||||
private final SensorManager mSensorManager;
|
|
||||||
private final Sensor mAccelerometer;
|
|
||||||
private final int mNaturalOrientation;
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Constructors
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
public Cocos2dxAccelerometer(final Context pContext) {
|
|
||||||
this.mContext = pContext;
|
|
||||||
|
|
||||||
this.mSensorManager = (SensorManager) this.mContext.getSystemService(Context.SENSOR_SERVICE);
|
|
||||||
this.mAccelerometer = this.mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
|
|
||||||
|
|
||||||
final Display display = ((WindowManager) this.mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
|
||||||
this.mNaturalOrientation = display.getOrientation();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Getter & Setter
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
public void enable() {
|
|
||||||
this.mSensorManager.registerListener(this, this.mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setInterval(float interval) {
|
|
||||||
// Honeycomb version is 11
|
|
||||||
if(android.os.Build.VERSION.SDK_INT < 11) {
|
|
||||||
this.mSensorManager.registerListener(this, this.mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
|
|
||||||
} else {
|
|
||||||
//convert seconds to microseconds
|
|
||||||
this.mSensorManager.registerListener(this, this.mAccelerometer, (int)(interval*100000));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disable() {
|
|
||||||
this.mSensorManager.unregisterListener(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Methods for/from SuperClass/Interfaces
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSensorChanged(final SensorEvent pSensorEvent) {
|
|
||||||
if (pSensorEvent.sensor.getType() != Sensor.TYPE_ACCELEROMETER) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
float x = pSensorEvent.values[0];
|
|
||||||
float y = pSensorEvent.values[1];
|
|
||||||
final float z = pSensorEvent.values[2];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Because the axes are not swapped when the device's screen orientation
|
|
||||||
* changes. So we should swap it here. In tablets such as Motorola Xoom,
|
|
||||||
* the default orientation is landscape, so should consider this.
|
|
||||||
*/
|
|
||||||
final int orientation = this.mContext.getResources().getConfiguration().orientation;
|
|
||||||
|
|
||||||
if ((orientation == Configuration.ORIENTATION_LANDSCAPE) && (this.mNaturalOrientation != Surface.ROTATION_0)) {
|
|
||||||
final float tmp = x;
|
|
||||||
x = -y;
|
|
||||||
y = tmp;
|
|
||||||
} else if ((orientation == Configuration.ORIENTATION_PORTRAIT) && (this.mNaturalOrientation != Surface.ROTATION_0)) {
|
|
||||||
final float tmp = x;
|
|
||||||
x = y;
|
|
||||||
y = -tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cocos2dxGLSurfaceView.queueAccelerometer(x,y,z,pSensorEvent.timestamp);
|
|
||||||
|
|
||||||
/*
|
|
||||||
if(BuildConfig.DEBUG) {
|
|
||||||
Log.d(TAG, "x = " + pSensorEvent.values[0] + " y = " + pSensorEvent.values[1] + " z = " + pSensorEvent.values[2]);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAccuracyChanged(final Sensor pSensor, final int pAccuracy) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Methods
|
|
||||||
// Native method called from Cocos2dxGLSurfaceView (To be in the same thread)
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
public static native void onSensorChanged(final float pX, final float pY, final float pZ, final long pTimestamp);
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Inner and Anonymous Classes
|
|
||||||
// ===========================================================
|
|
||||||
}
|
|
|
@ -1,89 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2012 cocos2d-x.org
|
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
****************************************************************************/
|
|
||||||
package org.cocos2dx.lib;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.util.AttributeSet;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.widget.EditText;
|
|
||||||
|
|
||||||
public class Cocos2dxEditText extends EditText {
|
|
||||||
// ===========================================================
|
|
||||||
// Constants
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Fields
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
private Cocos2dxGLSurfaceView mCocos2dxGLSurfaceView;
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Constructors
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
public Cocos2dxEditText(final Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cocos2dxEditText(final Context context, final AttributeSet attrs) {
|
|
||||||
super(context, attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cocos2dxEditText(final Context context, final AttributeSet attrs, final int defStyle) {
|
|
||||||
super(context, attrs, defStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Getter & Setter
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
public void setCocos2dxGLSurfaceView(final Cocos2dxGLSurfaceView pCocos2dxGLSurfaceView) {
|
|
||||||
this.mCocos2dxGLSurfaceView = pCocos2dxGLSurfaceView;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Methods for/from SuperClass/Interfaces
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onKeyDown(final int pKeyCode, final KeyEvent pKeyEvent) {
|
|
||||||
super.onKeyDown(pKeyCode, pKeyEvent);
|
|
||||||
|
|
||||||
/* Let GlSurfaceView get focus if back key is input. */
|
|
||||||
if (pKeyCode == KeyEvent.KEYCODE_BACK) {
|
|
||||||
this.mCocos2dxGLSurfaceView.requestFocus();
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Methods
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Inner and Anonymous Classes
|
|
||||||
// ===========================================================
|
|
||||||
}
|
|
|
@ -1,135 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2010-2011 cocos2d-x.org
|
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
package org.cocos2dx.lib;
|
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
|
||||||
|
|
||||||
public class Cocos2dxHandler extends Handler {
|
|
||||||
// ===========================================================
|
|
||||||
// Constants
|
|
||||||
// ===========================================================
|
|
||||||
public final static int HANDLER_SHOW_DIALOG = 1;
|
|
||||||
public final static int HANDLER_SHOW_EDITBOX_DIALOG = 2;
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Fields
|
|
||||||
// ===========================================================
|
|
||||||
private WeakReference<Cocos2dxActivity> mActivity;
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Constructors
|
|
||||||
// ===========================================================
|
|
||||||
public Cocos2dxHandler(Cocos2dxActivity activity) {
|
|
||||||
this.mActivity = new WeakReference<Cocos2dxActivity>(activity);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Getter & Setter
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Methods for/from SuperClass/Interfaces
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Methods
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
public void handleMessage(Message msg) {
|
|
||||||
switch (msg.what) {
|
|
||||||
case Cocos2dxHandler.HANDLER_SHOW_DIALOG:
|
|
||||||
showDialog(msg);
|
|
||||||
break;
|
|
||||||
case Cocos2dxHandler.HANDLER_SHOW_EDITBOX_DIALOG:
|
|
||||||
showEditBoxDialog(msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showDialog(Message msg) {
|
|
||||||
Cocos2dxActivity theActivity = this.mActivity.get();
|
|
||||||
DialogMessage dialogMessage = (DialogMessage)msg.obj;
|
|
||||||
new AlertDialog.Builder(theActivity)
|
|
||||||
.setTitle(dialogMessage.titile)
|
|
||||||
.setMessage(dialogMessage.message)
|
|
||||||
.setPositiveButton("Ok",
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
}).create().show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showEditBoxDialog(Message msg) {
|
|
||||||
EditBoxMessage editBoxMessage = (EditBoxMessage)msg.obj;
|
|
||||||
new Cocos2dxEditBoxDialog(this.mActivity.get(),
|
|
||||||
editBoxMessage.title,
|
|
||||||
editBoxMessage.content,
|
|
||||||
editBoxMessage.inputMode,
|
|
||||||
editBoxMessage.inputFlag,
|
|
||||||
editBoxMessage.returnType,
|
|
||||||
editBoxMessage.maxLength).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Inner and Anonymous Classes
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
public static class DialogMessage {
|
|
||||||
public String titile;
|
|
||||||
public String message;
|
|
||||||
|
|
||||||
public DialogMessage(String title, String message) {
|
|
||||||
this.titile = title;
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class EditBoxMessage {
|
|
||||||
public String title;
|
|
||||||
public String content;
|
|
||||||
public int inputMode;
|
|
||||||
public int inputFlag;
|
|
||||||
public int returnType;
|
|
||||||
public int maxLength;
|
|
||||||
|
|
||||||
public EditBoxMessage(String title, String content, int inputMode, int inputFlag, int returnType, int maxLength){
|
|
||||||
this.content = content;
|
|
||||||
this.title = title;
|
|
||||||
this.inputMode = inputMode;
|
|
||||||
this.inputFlag = inputFlag;
|
|
||||||
this.returnType = returnType;
|
|
||||||
this.maxLength = maxLength;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,168 +0,0 @@
|
||||||
/****************************************************************************
|
|
||||||
Copyright (c) 2010-2011 cocos2d-x.org
|
|
||||||
|
|
||||||
http://www.cocos2d-x.org
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
THE SOFTWARE.
|
|
||||||
****************************************************************************/
|
|
||||||
package org.cocos2dx.lib;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.text.Editable;
|
|
||||||
import android.text.TextWatcher;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.inputmethod.EditorInfo;
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.TextView.OnEditorActionListener;
|
|
||||||
|
|
||||||
public class Cocos2dxTextInputWraper implements TextWatcher, OnEditorActionListener {
|
|
||||||
// ===========================================================
|
|
||||||
// Constants
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
private static final String TAG = Cocos2dxTextInputWraper.class.getSimpleName();
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Fields
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
private final Cocos2dxGLSurfaceView mCocos2dxGLSurfaceView;
|
|
||||||
private String mText;
|
|
||||||
private String mOriginText;
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Constructors
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
public Cocos2dxTextInputWraper(final Cocos2dxGLSurfaceView pCocos2dxGLSurfaceView) {
|
|
||||||
this.mCocos2dxGLSurfaceView = pCocos2dxGLSurfaceView;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Getter & Setter
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
private boolean isFullScreenEdit() {
|
|
||||||
final TextView textField = this.mCocos2dxGLSurfaceView.getCocos2dxEditText();
|
|
||||||
final InputMethodManager imm = (InputMethodManager) textField.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
||||||
return imm.isFullscreenMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOriginText(final String pOriginText) {
|
|
||||||
this.mOriginText = pOriginText;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Methods for/from SuperClass/Interfaces
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(final Editable s) {
|
|
||||||
if (this.isFullScreenEdit()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (BuildConfig.DEBUG) {
|
|
||||||
//Log.d(TAG, "afterTextChanged: " + s);
|
|
||||||
//}
|
|
||||||
int nModified = s.length() - this.mText.length();
|
|
||||||
if (nModified > 0) {
|
|
||||||
final String insertText = s.subSequence(this.mText.length(), s.length()).toString();
|
|
||||||
this.mCocos2dxGLSurfaceView.insertText(insertText);
|
|
||||||
/*
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
Log.d(TAG, "insertText(" + insertText + ")");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
} else {
|
|
||||||
for (; nModified < 0; ++nModified) {
|
|
||||||
this.mCocos2dxGLSurfaceView.deleteBackward();
|
|
||||||
/*
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
Log.d(TAG, "deleteBackward");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.mText = s.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(final CharSequence pCharSequence, final int start, final int count, final int after) {
|
|
||||||
/*
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
Log.d(TAG, "beforeTextChanged(" + pCharSequence + ")start: " + start + ",count: " + count + ",after: " + after);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
this.mText = pCharSequence.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(final CharSequence pCharSequence, final int start, final int before, final int count) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onEditorAction(final TextView pTextView, final int pActionID, final KeyEvent pKeyEvent) {
|
|
||||||
if (this.mCocos2dxGLSurfaceView.getCocos2dxEditText() == pTextView && this.isFullScreenEdit()) {
|
|
||||||
// user press the action button, delete all old text and insert new text
|
|
||||||
for (int i = this.mOriginText.length(); i > 0; i--) {
|
|
||||||
this.mCocos2dxGLSurfaceView.deleteBackward();
|
|
||||||
/*
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
Log.d(TAG, "deleteBackward");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
String text = pTextView.getText().toString();
|
|
||||||
|
|
||||||
/* If user input nothing, translate "\n" to engine. */
|
|
||||||
if (text.compareTo("") == 0) {
|
|
||||||
text = "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ('\n' != text.charAt(text.length() - 1)) {
|
|
||||||
text += '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
final String insertText = text;
|
|
||||||
this.mCocos2dxGLSurfaceView.insertText(insertText);
|
|
||||||
/*
|
|
||||||
if (BuildConfig.DEBUG) {
|
|
||||||
Log.d(TAG, "insertText(" + insertText + ")");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pActionID == EditorInfo.IME_ACTION_DONE) {
|
|
||||||
this.mCocos2dxGLSurfaceView.requestFocus();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Methods
|
|
||||||
// ===========================================================
|
|
||||||
|
|
||||||
// ===========================================================
|
|
||||||
// Inner and Anonymous Classes
|
|
||||||
// ===========================================================
|
|
||||||
}
|
|
Loading…
Reference in New Issue