[DEV] try add android clipboard but break tabletgit status! can not test
This commit is contained in:
parent
ae53ab3d79
commit
80f623bb72
sources
android/src/org/ewol
ewol
@ -36,7 +36,9 @@ import android.content.res.AssetFileDescriptor;
|
|||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
// copy past events :
|
||||||
|
import android.content.ClipboardManager;
|
||||||
|
import android.content.ClipData;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
//import activityRootView
|
//import activityRootView
|
||||||
@ -54,6 +56,7 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
|
|||||||
private EwolAudioTask mStreams;
|
private EwolAudioTask mStreams;
|
||||||
private Thread mAudioThread;
|
private Thread mAudioThread;
|
||||||
private Ewol EWOL;
|
private Ewol EWOL;
|
||||||
|
private String tmpClipBoard; // TODO : Remove this ==> clipboard acces does not work
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
System.loadLibrary("ewol");
|
System.loadLibrary("ewol");
|
||||||
@ -65,6 +68,7 @@ public abstract class EwolActivity extends Activity implements EwolCallback, Ewo
|
|||||||
public EwolActivity() {
|
public EwolActivity() {
|
||||||
// set the java evironement in the C sources :
|
// set the java evironement in the C sources :
|
||||||
EWOL = new Ewol(this, EWOL_APPL_TYPE_ACTIVITY);
|
EWOL = new Ewol(this, EWOL_APPL_TYPE_ACTIVITY);
|
||||||
|
tmpClipBoard = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void initApkPath(String org, String vendor, String project) {
|
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 ...
|
// end application is requested ...
|
||||||
finish();
|
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;
|
package org.ewol;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public interface EwolCallback
|
public interface EwolCallback {
|
||||||
{
|
|
||||||
public void keyboardUpdate(boolean show);
|
public void keyboardUpdate(boolean show);
|
||||||
public void eventNotifier(String[] args);
|
public void eventNotifier(String[] args);
|
||||||
public void orientationUpdate(int screenMode);
|
public void orientationUpdate(int screenMode);
|
||||||
public void titleSet(String value);
|
public void titleSet(String value);
|
||||||
public void stop();
|
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_javaMethodEwolCallbackKeyboardUpdate; //!< basic methode to call ...
|
||||||
jmethodID m_javaMethodEwolCallbackOrientationUpdate;
|
jmethodID m_javaMethodEwolCallbackOrientationUpdate;
|
||||||
jmethodID m_javaMethodEwolActivitySetTitle;
|
jmethodID m_javaMethodEwolActivitySetTitle;
|
||||||
|
jmethodID m_javaMethodEwolActivitySetClipBoardString;
|
||||||
|
jmethodID m_javaMethodEwolActivityGetClipBoardString;
|
||||||
jclass m_javaDefaultClassString; //!< default string class
|
jclass m_javaDefaultClassString; //!< default string class
|
||||||
int32_t m_currentHeight;
|
int32_t m_currentHeight;
|
||||||
ewol::key::Special m_guiKeyBoardSpecialKeyMode;//!< special key of the android system :
|
ewol::key::Special m_guiKeyBoardSpecialKeyMode;//!< special key of the android system :
|
||||||
@ -89,6 +91,8 @@ class AndroidContext : public ewol::Context {
|
|||||||
m_javaMethodEwolCallbackKeyboardUpdate(0),
|
m_javaMethodEwolCallbackKeyboardUpdate(0),
|
||||||
m_javaMethodEwolCallbackOrientationUpdate(0),
|
m_javaMethodEwolCallbackOrientationUpdate(0),
|
||||||
m_javaMethodEwolActivitySetTitle(0),
|
m_javaMethodEwolActivitySetTitle(0),
|
||||||
|
m_javaMethodEwolActivitySetClipBoardString(0),
|
||||||
|
m_javaMethodEwolActivityGetClipBoardString(0),
|
||||||
m_javaDefaultClassString(0),
|
m_javaDefaultClassString(0),
|
||||||
m_currentHeight(0),
|
m_currentHeight(0),
|
||||||
m_clipBoardOwnerStd(false) {
|
m_clipBoardOwnerStd(false) {
|
||||||
@ -127,6 +131,7 @@ class AndroidContext : public ewol::Context {
|
|||||||
java_check_exception(_env);
|
java_check_exception(_env);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = safeInitMethodID(m_javaMethodEwolCallbackStop,
|
ret = safeInitMethodID(m_javaMethodEwolCallbackStop,
|
||||||
m_javaClassEwolCallback,
|
m_javaClassEwolCallback,
|
||||||
"stop",
|
"stop",
|
||||||
@ -163,6 +168,24 @@ class AndroidContext : public ewol::Context {
|
|||||||
return;
|
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);
|
m_javaObjectEwolCallback = _env->NewGlobalRef(_objCallback);
|
||||||
//javaObjectEwolCallbackAndActivity = objCallback;
|
//javaObjectEwolCallbackAndActivity = objCallback;
|
||||||
|
|
||||||
@ -234,10 +257,23 @@ class AndroidContext : public ewol::Context {
|
|||||||
// NOTE : nothing to do : Windows deas ot supported Middle button
|
// NOTE : nothing to do : Windows deas ot supported Middle button
|
||||||
break;
|
break;
|
||||||
case ewol::context::clipBoard::clipboardStd:
|
case ewol::context::clipBoard::clipboardStd:
|
||||||
|
|
||||||
// Request the clipBoard :
|
// Request the clipBoard :
|
||||||
if (false == m_clipBoardOwnerStd) {
|
EWOL_DEBUG("C->java : set clipboard");
|
||||||
// TODO : Inform the OS that we have the current buffer of copy ...
|
if (m_javaApplicationType == appl_application) {
|
||||||
m_clipBoardOwnerStd = true;
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -84,7 +84,6 @@ void ewol::context::clipBoard::set(enum ewol::context::clipBoard::clipboardListe
|
|||||||
if( ewol::context::clipBoard::clipboardStd == _clipboardID
|
if( ewol::context::clipBoard::clipboardStd == _clipboardID
|
||||||
|| ewol::context::clipBoard::clipboardSelection == _clipboardID) {
|
|| ewol::context::clipBoard::clipboardSelection == _clipboardID) {
|
||||||
ewol::getContext().clipBoardSet(_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
|
if( ewol::context::clipBoard::clipboardStd == _clipboardID
|
||||||
|| ewol::context::clipBoard::clipboardSelection == _clipboardID) {
|
|| ewol::context::clipBoard::clipboardSelection == _clipboardID) {
|
||||||
ewol::getContext().clipBoardGet(_clipboardID);
|
ewol::getContext().clipBoardGet(_clipboardID);
|
||||||
EWOL_TODO("Get ClipBoard");
|
|
||||||
} else {
|
} else {
|
||||||
// generate an event on the main thread ...
|
// generate an event on the main thread ...
|
||||||
ewol::getContext().OS_ClipBoardArrive(_clipboardID);
|
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) {
|
void ewol::key::Special::update(enum ewol::key::keyboard _move, bool _isDown) {
|
||||||
switch (move) {
|
switch (_move) {
|
||||||
case keyboardInsert:
|
case keyboardInsert:
|
||||||
setInsert(_isDown);
|
setInsert(_isDown);
|
||||||
break;
|
break;
|
||||||
@ -36,7 +36,7 @@ void ewol::key::Special::update(enum ewol::key::keyboard _move, bool _isDown) {
|
|||||||
setShift(_isDown);
|
setShift(_isDown);
|
||||||
break;
|
break;
|
||||||
case keyboardCtrlLeft:
|
case keyboardCtrlLeft:
|
||||||
case keyboardCtrlRight
|
case keyboardCtrlRight:
|
||||||
setCtrl(_isDown);
|
setCtrl(_isDown);
|
||||||
break;
|
break;
|
||||||
case keyboardMetaLeft:
|
case keyboardMetaLeft:
|
||||||
@ -52,6 +52,7 @@ void ewol::key::Special::update(enum ewol::key::keyboard _move, bool _isDown) {
|
|||||||
case keyboardNumLock:
|
case keyboardNumLock:
|
||||||
setNumLock(_isDown);
|
setNumLock(_isDown);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ewol::key::Special::getCapsLock(void) const {
|
bool ewol::key::Special::getCapsLock(void) const {
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <etk/Stream.h>
|
#include <etk/Stream.h>
|
||||||
|
#include <ewol/key/keyboard.h>
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
namespace key {
|
namespace key {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user