/*
 * Copyright Fobid. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.tfc.library.util;

import android.annotation.SuppressLint;
import android.content.ClipData;
import android.content.Context;

/**
 * author @Fobid
 */
public class ClipboardUtils {

//    /**
//     * Clipboard에 text를 저장해주는 메소드.
//     *
//     * @param text
//     *            Clipboard에 저장할 text.
//     */
    @SuppressLint("NewApi")
    @SuppressWarnings("deprecation")
    public static void copyText(Context context, String text) {
        if (android.os.Build.VERSION.SDK_INT < 11) {
            android.text.ClipboardManager cm = (android.text.ClipboardManager) context
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            cm.setText(text);
        } else {
            android.content.ClipboardManager cm = (android.content.ClipboardManager) context
                    .getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText("", text);
            cm.setPrimaryClip(clip);
        }
    }
}
@@ -656,28 +656,25 @@
 otation.
-SuppressLint
+TargetApi
 ;%0Aimport
@@ -700,16 +700,97 @@
 ipData;%0A
+import android.content.ClipDescription;%0Aimport android.content.ClipboardManager;%0A
 import a
@@ -812,16 +812,41 @@
 Context;
+%0Aimport android.os.Build;
 %0A%0A/**%0A *
@@ -1027,215 +1027,509 @@
  */%0A
-    @SuppressLint(%22NewApi%22)%0A    @SuppressWarnings(%22deprecation%22)%0A    public static void copyText(Context context, String text) %7B%0A        if (android.os.Build.VERSION.SDK_INT %3C 11) %7B%0A            android.text.
+@TargetApi(Build.VERSION_CODES.HONEYCOMB)%0Apublic static void copyText(Context context, String text) %7B%0A    ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);%0A%0A    if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.HONEYCOMB) %7B%0A        ClipData clip = ClipData.newPlainText(%22%22, text);%0A        cm.setPrimaryClip(clip);%0A    %7D else %7B%0A        //noinspection deprecation%0A        cm.setText(text);%0A    %7D%0A%7D%0A%0A    public static boolean hasText(Context context) %7B%0A        
 Clip
@@ -1551,21 +1551,8 @@
  = (
-android.text.
 Clip
@@ -1572,37 +1572,16 @@
  context
-%0A                    
 .getSyst
@@ -1614,32 +1614,33 @@
 D_SERVICE);%0A
+%0A
         
     cm.setTe
@@ -1631,75 +1631,535 @@
     
-    cm.setText(text);%0A        %7D else %7B%0A            android.content.
+if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.HONEYCOMB) %7B%0A            ClipDescription description = cm.getPrimaryClipDescription();%0A            ClipData clipData = cm.getPrimaryClip();%0A            return clipData != null%0A                    && description != null%0A                    && (description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN));%0A        %7D else %7B%0A            //noinspection deprecation%0A            return cm.hasText();%0A        %7D%0A    %7D%0A%0A    public static CharSequence getText(Context context) %7B%0A        
 Clip
@@ -2177,32 +2177,16 @@
 r cm = (
-android.content.
 Clipboar
@@ -2202,37 +2202,16 @@
  context
-%0A                    
 .getSyst
@@ -2252,66 +2252,382 @@
 E);%0A
-            ClipData clip = ClipData.newPlainText(%22%22, t
+%0A        if (Build.VERSION.SDK_INT %3E= Build.VERSION_CODES.HONEYCOMB) %7B%0A            ClipDescription description = cm.getPrimaryClipDescription();%0A            ClipData clipData = cm.getPrimaryClip();%0A            if (clipData != null && description != null && description.hasMimeType(ClipDescription.MIMETYPE_TEXT_PLAIN)) %7B%0A                return clipData.getItemAt(0).getT
 ext
+(
 );%0A 
@@ -2637,38 +2637,152 @@
         
-cm.setPrimaryClip(clip
+%7D else %7B%0A                return %22%22;%0A            %7D%0A        %7D else %7B%0A            //noinspection deprecation%0A            return cm.getText(
 );%0A     

add few functions into clipboard utils