Update demo app for the updated onReceiveContent() API
Bug: 170191676 Bug: 152068298 Test: Manual Change-Id: Ic146edcf632dc25a0def62532eb53d866dbdc8ae
This commit is contained in:
@@ -33,7 +33,6 @@ import android.widget.TextViewOnReceiveContentCallback;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,15 +41,11 @@ import java.util.Set;
|
|||||||
* to the platform.
|
* to the platform.
|
||||||
*/
|
*/
|
||||||
public class OnReceiveContentCallbackAllTypes extends TextViewOnReceiveContentCallback {
|
public class OnReceiveContentCallbackAllTypes extends TextViewOnReceiveContentCallback {
|
||||||
private static final Set<String> ALL_MIME_TYPES = Collections.singleton("*/*");
|
static final String[] SUPPORTED_MIME_TYPES = new String[] {"*/*"};
|
||||||
|
|
||||||
private static final Set<String> SUPPORTED_CONTENT_URI_MIME_TYPES =
|
private static final Set<String> SUPPORTED_CONTENT_URI_MIME_TYPES =
|
||||||
new ArraySet<>(new String[] {"image/*", "video/mp4"});
|
new ArraySet<>(new String[] {"image/*", "video/mp4"});
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<String> getSupportedMimeTypes(TextView view) {
|
|
||||||
return ALL_MIME_TYPES;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onReceiveContent(TextView view, Payload payload) {
|
public boolean onReceiveContent(TextView view, Payload payload) {
|
||||||
ClipData clip = payload.getClip();
|
ClipData clip = payload.getClip();
|
||||||
|
|||||||
@@ -26,20 +26,12 @@ import android.view.OnReceiveContentCallback;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sample implementation that accepts only images. All other content is deferred to default platform
|
* Sample implementation that accepts only images. All other content is deferred to default platform
|
||||||
* behavior.
|
* behavior.
|
||||||
*/
|
*/
|
||||||
public class OnReceiveContentCallbackImages implements OnReceiveContentCallback<TextView> {
|
public class OnReceiveContentCallbackImages implements OnReceiveContentCallback<TextView> {
|
||||||
private static final Set<String> SUPPORTED_MIME_TYPES = Collections.singleton("image/*");
|
static final String[] SUPPORTED_MIME_TYPES = new String[] {"image/*"};
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<String> getSupportedMimeTypes(TextView view) {
|
|
||||||
return SUPPORTED_MIME_TYPES;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onReceiveContent(TextView view, Payload payload) {
|
public boolean onReceiveContent(TextView view, Payload payload) {
|
||||||
|
|||||||
@@ -29,9 +29,13 @@ public class ReceiveContentDemoActivity extends Activity {
|
|||||||
setContentView(R.layout.demo);
|
setContentView(R.layout.demo);
|
||||||
|
|
||||||
EditText editTextImagesOnly = findViewById(R.id.edittext_images);
|
EditText editTextImagesOnly = findViewById(R.id.edittext_images);
|
||||||
editTextImagesOnly.setOnReceiveContentCallback(new OnReceiveContentCallbackImages());
|
editTextImagesOnly.setOnReceiveContentCallback(
|
||||||
|
OnReceiveContentCallbackImages.SUPPORTED_MIME_TYPES,
|
||||||
|
new OnReceiveContentCallbackImages());
|
||||||
|
|
||||||
EditText editTextAllTypes = findViewById(R.id.edittext_all_types);
|
EditText editTextAllTypes = findViewById(R.id.edittext_all_types);
|
||||||
editTextAllTypes.setOnReceiveContentCallback(new OnReceiveContentCallbackAllTypes());
|
editTextAllTypes.setOnReceiveContentCallback(
|
||||||
|
OnReceiveContentCallbackAllTypes.SUPPORTED_MIME_TYPES,
|
||||||
|
new OnReceiveContentCallbackAllTypes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user