[DEV] try add android clipboard but break tabletgit status! can not test
This commit is contained in:
parent
ae53ab3d79
commit
80f623bb72
@ -36,7 +36,9 @@ import android.content.res.AssetFileDescriptor;
|
||||
import android.content.res.AssetManager;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
|
||||
// copy past events :
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.ClipData;
|
||||
|
||||
import java.io.IOException;
|
||||
//import activityRootView
|
||||
@ -54,6 +56,7 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
|
||||
private EwolAudioTask mStreams;
|
||||
private Thread mAudioThread;
|
||||
private Ewol EWOL;
|
||||
private String tmpClipBoard; // TODO : Remove this ==> clipboard acces does not work
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("ewol");
|
||||
@ -65,6 +68,7 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
|
||||
public EwolActivity() {
|
||||
// set the java evironement in the C sources :
|
||||
EWOL = new Ewol(this, EWOL_APPL_TYPE_ACTIVITY);
|
||||
tmpClipBoard = "";
|
||||
}
|
||||
|
||||
protected void initApkPath(String org, String vendor, String project) {
|
||||
@ -254,6 +258,49 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
|
||||
// end application is requested ...
|
||||
finish();
|
||||
}
|
||||
|
||||
//http://developer.android.com/guide/topics/text/copy-paste.html
|
||||
public String getClipBoardString() {
|
||||
return tmpClipBoard;
|
||||
// TODO : Rework this it does not work
|
||||
/*
|
||||
// Gets a handle to the clipboard service.
|
||||
ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
// If the clipboard doesn't contain data, disable the paste menu item.
|
||||
// If it does contain data, decide if you can handle the data.
|
||||
if (!(clipboard.hasPrimaryClip())) {
|
||||
return "";
|
||||
}
|
||||
// Examines the item on the clipboard. If getText() does not return null, the clip item contains the
|
||||
// text. Assumes that this application can only handle one item at a time.
|
||||
ClipData.Item item = clipboard.getPrimaryClip().getItemAt(0);
|
||||
if (item == null) {
|
||||
return "";
|
||||
}
|
||||
// Gets the clipboard as text.
|
||||
String pasteData = item.getText().toString();;
|
||||
// If the string contains data, then the paste operation is done
|
||||
if (pasteData != null) {
|
||||
return pasteData;
|
||||
}
|
||||
return "";
|
||||
*/
|
||||
}
|
||||
|
||||
public void setClipBoardString(String data) {
|
||||
tmpClipBoard = data;
|
||||
return;
|
||||
// TODO : Rework this it does not work
|
||||
/*
|
||||
// Gets a handle to the clipboard service.
|
||||
ClipboardManager clipboard = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
// Creates a new text clip to put on the clipboard
|
||||
ClipData clip = ClipData.newPlainText("simple text", data);
|
||||
// Set the clipboard's primary clip.
|
||||
clipboard.setPrimaryClip(clip);
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,11 +9,12 @@
|
||||
package org.ewol;
|
||||
import android.util.Log;
|
||||
|
||||
public interface EwolCallback
|
||||
{
|
||||
public interface EwolCallback {
|
||||
public void keyboardUpdate(boolean show);
|
||||
public void eventNotifier(String[] args);
|
||||
public void orientationUpdate(int screenMode);
|
||||
public void titleSet(String value);
|
||||
public void stop();
|
||||
public String getClipBoardString();
|
||||
public void setClipBoardString(String data);
|
||||
}
|
||||
|
@ -62,6 +62,8 @@ class AndroidContext : public ewol::Context {
|
||||
jmethodID m_javaMethodEwolCallbackKeyboardUpdate; //!< basic methode to call ...
|
||||
jmethodID m_javaMethodEwolCallbackOrientationUpdate;
|
||||
jmethodID m_javaMethodEwolActivitySetTitle;
|
||||
jmethodID m_javaMethodEwolActivitySetClipBoardString;
|
||||
jmethodID m_javaMethodEwolActivityGetClipBoardString;
|
||||
jclass m_javaDefaultClassString; //!< default string class
|
||||
int32_t m_currentHeight;
|
||||
ewol::key::Special m_guiKeyBoardSpecialKeyMode;//!< special key of the android system :
|
||||
@ -89,6 +91,8 @@ class AndroidContext : public ewol::Context {
|
||||
m_javaMethodEwolCallbackKeyboardUpdate(0),
|
||||
m_javaMethodEwolCallbackOrientationUpdate(0),
|
||||
m_javaMethodEwolActivitySetTitle(0),
|
||||
m_javaMethodEwolActivitySetClipBoardString(0),
|
||||
m_javaMethodEwolActivityGetClipBoardString(0),
|
||||
m_javaDefaultClassString(0),
|
||||
m_currentHeight(0),
|
||||
m_clipBoardOwnerStd(false) {
|
||||
@ -127,6 +131,7 @@ class AndroidContext : public ewol::Context {
|
||||
java_check_exception(_env);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = safeInitMethodID(m_javaMethodEwolCallbackStop,
|
||||
m_javaClassEwolCallback,
|
||||
"stop",
|
||||
@ -163,6 +168,24 @@ class AndroidContext : public ewol::Context {
|
||||
return;
|
||||
}
|
||||
|
||||
ret = safeInitMethodID(m_javaMethodEwolActivitySetClipBoardString,
|
||||
m_javaClassEwolCallback,
|
||||
"setClipBoardString",
|
||||
"(Ljava/lang/String;)V");
|
||||
if (ret == false) {
|
||||
java_check_exception(_env);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = safeInitMethodID(m_javaMethodEwolActivityGetClipBoardString,
|
||||
m_javaClassEwolCallback,
|
||||
"getClipBoardString",
|
||||
"()Ljava/lang/String;");
|
||||
if (ret == false) {
|
||||
java_check_exception(_env);
|
||||
return;
|
||||
}
|
||||
|
||||
m_javaObjectEwolCallback = _env->NewGlobalRef(_objCallback);
|
||||
//javaObjectEwolCallbackAndActivity = objCallback;
|
||||
|
||||
@ -234,10 +257,23 @@ class AndroidContext : public ewol::Context {
|
||||
// NOTE : nothing to do : Windows deas ot supported Middle button
|
||||
break;
|
||||
case ewol::context::clipBoard::clipboardStd:
|
||||
|
||||
// Request the clipBoard :
|
||||
if (false == m_clipBoardOwnerStd) {
|
||||
// TODO : Inform the OS that we have the current buffer of copy ...
|
||||
m_clipBoardOwnerStd = true;
|
||||
EWOL_DEBUG("C->java : set clipboard");
|
||||
if (m_javaApplicationType == appl_application) {
|
||||
int status;
|
||||
if(!java_attach_current_thread(&status)) {
|
||||
return;
|
||||
}
|
||||
//Call java ...
|
||||
jstring data = m_JavaVirtualMachinePointer->NewStringUTF(ewol::context::clipBoard::get(_clipboardID).c_str());
|
||||
m_JavaVirtualMachinePointer->CallVoidMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivityGetClipBoardString, data);
|
||||
m_JavaVirtualMachinePointer->DeleteLocalRef(data);
|
||||
// manage execption :
|
||||
java_check_exception(m_JavaVirtualMachinePointer);
|
||||
java_detach_current_thread(status);
|
||||
} else {
|
||||
EWOL_ERROR("C->java : can not set clipboard");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -84,7 +84,6 @@ void ewol::context::clipBoard::set(enum ewol::context::clipBoard::clipboardListe
|
||||
if( ewol::context::clipBoard::clipboardStd == _clipboardID
|
||||
|| ewol::context::clipBoard::clipboardSelection == _clipboardID) {
|
||||
ewol::getContext().clipBoardSet(_clipboardID);
|
||||
EWOL_TODO("Set ClipBoard");
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,11 +97,9 @@ void ewol::context::clipBoard::request(enum ewol::context::clipBoard::clipboardL
|
||||
if( ewol::context::clipBoard::clipboardStd == _clipboardID
|
||||
|| ewol::context::clipBoard::clipboardSelection == _clipboardID) {
|
||||
ewol::getContext().clipBoardGet(_clipboardID);
|
||||
EWOL_TODO("Get ClipBoard");
|
||||
} else {
|
||||
// generate an event on the main thread ...
|
||||
ewol::getContext().OS_ClipBoardArrive(_clipboardID);
|
||||
EWOL_TODO("ClipBoard arrive");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ ewol::key::Special::Special(void) :
|
||||
|
||||
}
|
||||
void ewol::key::Special::update(enum ewol::key::keyboard _move, bool _isDown) {
|
||||
switch (move) {
|
||||
switch (_move) {
|
||||
case keyboardInsert:
|
||||
setInsert(_isDown);
|
||||
break;
|
||||
@ -36,7 +36,7 @@ void ewol::key::Special::update(enum ewol::key::keyboard _move, bool _isDown) {
|
||||
setShift(_isDown);
|
||||
break;
|
||||
case keyboardCtrlLeft:
|
||||
case keyboardCtrlRight
|
||||
case keyboardCtrlRight:
|
||||
setCtrl(_isDown);
|
||||
break;
|
||||
case keyboardMetaLeft:
|
||||
@ -52,6 +52,7 @@ void ewol::key::Special::update(enum ewol::key::keyboard _move, bool _isDown) {
|
||||
case keyboardNumLock:
|
||||
setNumLock(_isDown);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool ewol::key::Special::getCapsLock(void) const {
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/Stream.h>
|
||||
#include <ewol/key/keyboard.h>
|
||||
|
||||
namespace ewol {
|
||||
namespace key {
|
||||
|
Loading…
x
Reference in New Issue
Block a user