Skip to content

Commit

Permalink
Merge pull request #24 from percolate/set_clipboard_text
Browse files Browse the repository at this point in the history
New ClipboardUtils#setClipboardText utility
  • Loading branch information
msya authored Aug 26, 2016
2 parents 24b2446 + e4c1715 commit 13a9d49
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
13 changes: 13 additions & 0 deletions caffeine/src/main/java/com/percolate/caffeine/ClipboardUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,17 @@ public static String getClipboardText(final Context context) {
}
return null;
}

/**
* Set the clipboard text.
*
* @param text Text to put in the clipboard.
*/
public static void setClipboardText(final Context context, final String text) {
if(text != null) {
final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
final ClipData clipData = ClipData.newPlainText(text, text);
clipboard.setPrimaryClip(clipData);
}
}
}

0 comments on commit 13a9d49

Please sign in to comment.