Merge "Force share intents to use Strings instead of SpannableString" into tm-qpr-dev
This commit is contained in:
@@ -47,7 +47,8 @@ class IntentCreator {
|
|||||||
shareIntent.putExtra(Intent.EXTRA_STREAM, clipData.getItemAt(0).getUri());
|
shareIntent.putExtra(Intent.EXTRA_STREAM, clipData.getItemAt(0).getUri());
|
||||||
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
} else {
|
} else {
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, clipData.getItemAt(0).coerceToText(context));
|
shareIntent.putExtra(
|
||||||
|
Intent.EXTRA_TEXT, clipData.getItemAt(0).coerceToText(context).toString());
|
||||||
shareIntent.setType("text/plain");
|
shareIntent.setType("text/plain");
|
||||||
}
|
}
|
||||||
Intent chooserIntent = Intent.createChooser(shareIntent, null)
|
Intent chooserIntent = Intent.createChooser(shareIntent, null)
|
||||||
|
|||||||
@@ -16,13 +16,14 @@
|
|||||||
|
|
||||||
package com.android.systemui.clipboardoverlay;
|
package com.android.systemui.clipboardoverlay;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.text.SpannableString;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import androidx.test.filters.SmallTest;
|
import androidx.test.filters.SmallTest;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
@@ -129,6 +130,18 @@ public class IntentCreatorTest extends SysuiTestCase {
|
|||||||
assertEquals("image/png", target.getType());
|
assertEquals("image/png", target.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void test_getShareIntent_spannableText() {
|
||||||
|
ClipData clipData = ClipData.newPlainText("Test", new SpannableString("Test Item"));
|
||||||
|
Intent intent = IntentCreator.getShareIntent(clipData, getContext());
|
||||||
|
|
||||||
|
assertEquals(Intent.ACTION_CHOOSER, intent.getAction());
|
||||||
|
assertFlags(intent, EXTERNAL_INTENT_FLAGS);
|
||||||
|
Intent target = intent.getParcelableExtra(Intent.EXTRA_INTENT, Intent.class);
|
||||||
|
assertEquals("Test Item", target.getStringExtra(Intent.EXTRA_TEXT));
|
||||||
|
assertEquals("text/plain", target.getType());
|
||||||
|
}
|
||||||
|
|
||||||
// Assert that the given flags are set
|
// Assert that the given flags are set
|
||||||
private void assertFlags(Intent intent, int flags) {
|
private void assertFlags(Intent intent, int flags) {
|
||||||
assertTrue((intent.getFlags() & flags) == flags);
|
assertTrue((intent.getFlags() & flags) == flags);
|
||||||
|
|||||||
Reference in New Issue
Block a user