1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.content; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.os.Handler; 22 23 public class ClipboardManager extends android.text.ClipboardManager { 24 25 /** 26 * Defines a listener callback that is invoked when the primary clip on the clipboard changes. 27 * Objects that want to register a listener call 28 * {@link android.content.ClipboardManager#addPrimaryClipChangedListener(OnPrimaryClipChangedListener) 29 * addPrimaryClipChangedListener()} with an 30 * object that implements OnPrimaryClipChangedListener. 31 * 32 */ 33 public interface OnPrimaryClipChangedListener { 34 35 /** 36 * Callback that is invoked by {@link android.content.ClipboardManager} when the primary 37 * clip changes. 38 */ onPrimaryClipChanged()39 void onPrimaryClipChanged(); 40 } 41 42 /** {@hide} */ ClipboardManager(Context context, Handler handler)43 public ClipboardManager(Context context, Handler handler) { } 44 45 /** 46 * Sets the current primary clip on the clipboard. This is the clip that 47 * is involved in normal cut and paste operations. 48 * 49 * @param clip The clipped data item to set. 50 * @see #getPrimaryClip() 51 * @see #clearPrimaryClip() 52 */ setPrimaryClip(@onNull ClipData clip)53 public void setPrimaryClip(@NonNull ClipData clip) { } 54 55 /** 56 * Clears any current primary clip on the clipboard. 57 * 58 * @see #setPrimaryClip(ClipData) 59 */ clearPrimaryClip()60 public void clearPrimaryClip() { } 61 62 /** 63 * Returns the current primary clip on the clipboard. 64 * 65 * <em>If the application is not the default IME or does not have input focus this return 66 * {@code null}.</em> 67 * 68 * @see #setPrimaryClip(ClipData) 69 */ getPrimaryClip()70 public @Nullable ClipData getPrimaryClip() { 71 return null; 72 } 73 74 /** 75 * Returns a description of the current primary clip on the clipboard 76 * but not a copy of its data. 77 * 78 * <em>If the application is not the default IME or does not have input focus this return 79 * {@code null}.</em> 80 * 81 * @see #setPrimaryClip(ClipData) 82 */ getPrimaryClipDescription()83 public @Nullable ClipDescription getPrimaryClipDescription() { 84 return null; 85 } 86 87 /** 88 * Returns true if there is currently a primary clip on the clipboard. 89 * 90 * <em>If the application is not the default IME or the does not have input focus this will 91 * return {@code false}.</em> 92 */ hasPrimaryClip()93 public boolean hasPrimaryClip() { 94 return false; 95 } 96 addPrimaryClipChangedListener(OnPrimaryClipChangedListener what)97 public void addPrimaryClipChangedListener(OnPrimaryClipChangedListener what) { } 98 removePrimaryClipChangedListener(OnPrimaryClipChangedListener what)99 public void removePrimaryClipChangedListener(OnPrimaryClipChangedListener what) { } 100 101 /** 102 * @deprecated Use {@link #getPrimaryClip()} instead. This retrieves 103 * the primary clip and tries to coerce it to a string. 104 */ 105 @Deprecated getText()106 public CharSequence getText() { 107 return null; 108 } 109 110 /** 111 * @deprecated Use {@link #setPrimaryClip(ClipData)} instead. This 112 * creates a ClippedItem holding the given text and sets it as the 113 * primary clip. It has no label or icon. 114 */ 115 @Deprecated setText(CharSequence text)116 public void setText(CharSequence text) { } 117 118 /** 119 * @deprecated Use {@link #hasPrimaryClip()} instead. 120 */ 121 @Deprecated hasText()122 public boolean hasText() { 123 return false; 124 } 125 reportPrimaryClipChanged()126 void reportPrimaryClipChanged() { } 127 } 128