summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Mak <tonymak@google.com>2019-04-02 13:43:29 +0100
committerTony Mak <tonymak@google.com>2019-04-03 15:42:05 +0100
commit3a4644ef774138e0b352e9d50bc734514ebb792f (patch)
treec15a6bf27dba12c7aee5613b90b7bdd577fc8c47
parent5573fca5998a49cf41d831d49d59bfe78703d2b2 (diff)
downloadlibtextclassifier-3a4644ef774138e0b352e9d50bc734514ebb792f.tar.gz
Import libtextclassifier
Test: atest frameworks/base/core/tests/coretests/src/android/view/textclassifier/ Change-Id: Ia4c8a7e7eafe01b3b7f404498fe2980fc35577fc
-rw-r--r--actions/test_data/actions_suggestions_test.default.modelbin2840 -> 77900 bytes
-rw-r--r--actions/test_data/actions_suggestions_test.modelbin3233396 -> 3308680 bytes
-rw-r--r--java/com/google/android/textclassifier/RemoteActionTemplate.java9
-rw-r--r--models/actions_suggestions.en.modelbin3233396 -> 3308680 bytes
-rw-r--r--models/actions_suggestions.universal.modelbin2840 -> 77900 bytes
-rw-r--r--utils/intents/intent-generator.cc2
-rw-r--r--utils/intents/intent-generator.h5
-rw-r--r--utils/intents/jni.cc11
8 files changed, 23 insertions, 4 deletions
diff --git a/actions/test_data/actions_suggestions_test.default.model b/actions/test_data/actions_suggestions_test.default.model
index 524f71f..cdff8c2 100644
--- a/actions/test_data/actions_suggestions_test.default.model
+++ b/actions/test_data/actions_suggestions_test.default.model
Binary files differ
diff --git a/actions/test_data/actions_suggestions_test.model b/actions/test_data/actions_suggestions_test.model
index ffe2a83..a83a72b 100644
--- a/actions/test_data/actions_suggestions_test.model
+++ b/actions/test_data/actions_suggestions_test.model
Binary files differ
diff --git a/java/com/google/android/textclassifier/RemoteActionTemplate.java b/java/com/google/android/textclassifier/RemoteActionTemplate.java
index eae9fad..308d809 100644
--- a/java/com/google/android/textclassifier/RemoteActionTemplate.java
+++ b/java/com/google/android/textclassifier/RemoteActionTemplate.java
@@ -31,6 +31,13 @@ public final class RemoteActionTemplate {
/** Description shown for the action (see: RemoteAction.getContentDescription). */
public final String description;
+ /**
+ * Description shown for the action (see: RemoteAction.getContentDescription) when app name is
+ * available. Caller is expected to replace the placeholder by the name of the app that is going
+ * to handle the action.
+ */
+ public final String descriptionWithAppName;
+
/** The action to set on the Intent (see: Intent.setAction). */
public final String action;
@@ -59,6 +66,7 @@ public final class RemoteActionTemplate {
String titleWithoutEntity,
String titleWithEntity,
String description,
+ String descriptionWithAppName,
String action,
String data,
String type,
@@ -70,6 +78,7 @@ public final class RemoteActionTemplate {
this.titleWithoutEntity = titleWithoutEntity;
this.titleWithEntity = titleWithEntity;
this.description = description;
+ this.descriptionWithAppName = descriptionWithAppName;
this.action = action;
this.data = data;
this.type = type;
diff --git a/models/actions_suggestions.en.model b/models/actions_suggestions.en.model
index ffe2a83..a83a72b 100644
--- a/models/actions_suggestions.en.model
+++ b/models/actions_suggestions.en.model
Binary files differ
diff --git a/models/actions_suggestions.universal.model b/models/actions_suggestions.universal.model
index 524f71f..cdff8c2 100644
--- a/models/actions_suggestions.universal.model
+++ b/models/actions_suggestions.universal.model
Binary files differ
diff --git a/utils/intents/intent-generator.cc b/utils/intents/intent-generator.cc
index bf36f1f..f882515 100644
--- a/utils/intents/intent-generator.cc
+++ b/utils/intents/intent-generator.cc
@@ -548,6 +548,8 @@ RemoteActionTemplate JniLuaEnvironment::ReadRemoteActionTemplateResult() {
result.title_with_entity = ReadString(/*index=*/-1).ToString();
} else if (key.Equals("description")) {
result.description = ReadString(/*index=*/-1).ToString();
+ } else if (key.Equals("description_with_app_name")) {
+ result.description_with_app_name = ReadString(/*index=*/-1).ToString();
} else if (key.Equals("action")) {
result.action = ReadString(/*index=*/-1).ToString();
} else if (key.Equals("data")) {
diff --git a/utils/intents/intent-generator.h b/utils/intents/intent-generator.h
index 87ea811..9177adb 100644
--- a/utils/intents/intent-generator.h
+++ b/utils/intents/intent-generator.h
@@ -33,6 +33,11 @@ struct RemoteActionTemplate {
// Description shown for the action (see: RemoteAction.getContentDescription).
Optional<std::string> description;
+ // Description shown for the action (see: RemoteAction.getContentDescription)
+ // when app name is available. Caller is expected to replace the placeholder
+ // by the name of the app that is going to handle the action.
+ Optional<std::string> description_with_app_name;
+
// The action to set on the Intent (see: Intent.setAction).
Optional<std::string> action;
diff --git a/utils/intents/jni.cc b/utils/intents/jni.cc
index dffa5fc..d6274b1 100644
--- a/utils/intents/jni.cc
+++ b/utils/intents/jni.cc
@@ -50,8 +50,8 @@ RemoteActionTemplatesHandler::Create(
TC3_GET_METHOD(
remote_action_template_class_, remote_action_template_init_, "<init>",
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/"
- "String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;[Ljava/"
- "lang/String;Ljava/lang/String;[L" TC3_PACKAGE_PATH
+ "String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/"
+ "Integer;[Ljava/lang/String;Ljava/lang/String;[L" TC3_PACKAGE_PATH
TC3_NAMED_VARIANT_CLASS_NAME_STR ";Ljava/lang/Integer;)V");
TC3_GET_CLASS(named_variant_class_,
@@ -189,6 +189,8 @@ jobjectArray RemoteActionTemplatesHandler::RemoteActionTemplatesToJObjectArray(
const jstring title_with_entity =
AsUTF8String(remote_action.title_with_entity);
const jstring description = AsUTF8String(remote_action.description);
+ const jstring description_with_app_name =
+ AsUTF8String(remote_action.description_with_app_name);
const jstring action = AsUTF8String(remote_action.action);
const jstring data = AsUTF8String(remote_action.data);
const jstring type = AsUTF8String(remote_action.type);
@@ -200,8 +202,9 @@ jobjectArray RemoteActionTemplatesHandler::RemoteActionTemplatesToJObjectArray(
ScopedLocalRef<jobject> result(
jni_cache_->GetEnv()->NewObject(
remote_action_template_class_.get(), remote_action_template_init_,
- title_without_entity, title_with_entity, description, action, data,
- type, flags, category, package, extra, request_code),
+ title_without_entity, title_with_entity, description,
+ description_with_app_name, action, data, type, flags, category,
+ package, extra, request_code),
jni_cache_->GetEnv());
if (result == nullptr) {
return nullptr;