forked from kishannareshpal/richeditor-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Insert clipboard text on paste event
- Loading branch information
Showing
6 changed files
with
47 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'com.github.dcendents.android-maven' | ||
group 'com.github.kishannareshpal' | ||
group 'com.github.quipper' | ||
|
||
android { | ||
compileSdkVersion 29 | ||
buildToolsVersion "28.0.3" | ||
compileSdkVersion 29 | ||
buildToolsVersion "28.0.3" | ||
|
||
defaultConfig { | ||
minSdkVersion 17 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.3.2" | ||
} | ||
} | ||
defaultConfig { | ||
minSdkVersion 17 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.3.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
richeditor/src/main/java/jp/wasabeef/richeditor/ClipboardInterface.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package jp.wasabeef.richeditor; | ||
|
||
import android.content.ClipData; | ||
import android.content.ClipDescription; | ||
import android.content.ClipboardManager; | ||
import android.content.Context; | ||
|
||
public class ClipboardInterface { | ||
private Context context; | ||
|
||
public ClipboardInterface(Context context) { | ||
this.context = context; | ||
} | ||
|
||
@android.webkit.JavascriptInterface | ||
public String getText() { | ||
String plainText = ""; | ||
ClipboardManager cm = (ClipboardManager) context | ||
.getSystemService(Context.CLIPBOARD_SERVICE); | ||
if (cm != null) { | ||
ClipData cd = cm.getPrimaryClip(); | ||
if (cd != null && cd.getDescription().hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN) && cd.getItemCount() > 0) { | ||
ClipData.Item item = cd.getItemAt(0); | ||
plainText = item.getText().toString(); | ||
} | ||
} | ||
return plainText; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters