Merge "Move locale from LanguageDetectionEvent to base class" into qt-dev

This commit is contained in:
TreeHugger Robot
2019-04-21 09:02:26 +00:00
committed by Android (Google) Code Review
3 changed files with 31 additions and 37 deletions

View File

@@ -53407,7 +53407,7 @@ package android.view.textclassifier {
method @Nullable public String getCallingPackageName();
method @NonNull public java.util.List<android.view.textclassifier.ConversationActions.Message> getConversation();
method @NonNull public android.os.Bundle getExtras();
method @Nullable public java.util.List<java.lang.String> getHints();
method @NonNull public java.util.List<java.lang.String> getHints();
method @IntRange(from=0xffffffff) public int getMaxSuggestions();
method @NonNull public android.view.textclassifier.TextClassifier.EntityConfig getTypeConfig();
method public void writeToParcel(android.os.Parcel, int);
@@ -53625,6 +53625,7 @@ package android.view.textclassifier {
method public int getEventIndex();
method public int getEventType();
method @NonNull public android.os.Bundle getExtras();
method @Nullable public android.icu.util.ULocale getLocale();
method @Nullable public String getModelName();
method @Nullable public String getResultId();
method @NonNull public float[] getScores();
@@ -53662,6 +53663,7 @@ package android.view.textclassifier {
method @NonNull public T setEventContext(@Nullable android.view.textclassifier.TextClassificationContext);
method @NonNull public T setEventIndex(int);
method @NonNull public T setExtras(@NonNull android.os.Bundle);
method @NonNull public T setLocale(@Nullable android.icu.util.ULocale);
method @NonNull public T setModelName(@Nullable String);
method @NonNull public T setResultId(@Nullable String);
method @NonNull public T setScores(@NonNull float...);
@@ -53677,14 +53679,12 @@ package android.view.textclassifier {
}
public static final class TextClassifierEvent.LanguageDetectionEvent extends android.view.textclassifier.TextClassifierEvent implements android.os.Parcelable {
method @Nullable public android.icu.util.ULocale getLocale();
field @NonNull public static final android.os.Parcelable.Creator<android.view.textclassifier.TextClassifierEvent.LanguageDetectionEvent> CREATOR;
}
public static final class TextClassifierEvent.LanguageDetectionEvent.Builder extends android.view.textclassifier.TextClassifierEvent.Builder<android.view.textclassifier.TextClassifierEvent.LanguageDetectionEvent.Builder> {
ctor public TextClassifierEvent.LanguageDetectionEvent.Builder(int);
method @NonNull public android.view.textclassifier.TextClassifierEvent.LanguageDetectionEvent build();
method @NonNull public android.view.textclassifier.TextClassifierEvent.LanguageDetectionEvent.Builder setLocale(@Nullable android.icu.util.ULocale);
}
public static final class TextClassifierEvent.TextLinkifyEvent extends android.view.textclassifier.TextClassifierEvent implements android.os.Parcelable {

View File

@@ -401,7 +401,7 @@ public final class ConversationActions implements Parcelable {
}
/** Returns an immutable list of hints */
@Nullable
@NonNull
@Hint
public List<String> getHints() {
return mHints;

View File

@@ -35,8 +35,8 @@ import java.util.Arrays;
* something of note that relates to a feature powered by the TextClassifier. The TextClassifier may
* log these events or use them to improve future responses to queries.
* <p>
* Each categories of the events have their own subclass. Events of each types has an associated
* set of related properties. You can find the specification of them in the subclasses.
* Each category of events has its their own subclass. Events of each type have an associated
* set of related properties. You can find their specification in the subclasses.
*/
public abstract class TextClassifierEvent implements Parcelable {
@@ -146,6 +146,8 @@ public abstract class TextClassifierEvent implements Parcelable {
@Nullable
private final String mModelName;
private final int[] mActionIndices;
@Nullable
private final ULocale mLocale;
private final Bundle mExtras;
private TextClassifierEvent(Builder builder) {
@@ -158,6 +160,7 @@ public abstract class TextClassifierEvent implements Parcelable {
mScores = builder.mScores;
mModelName = builder.mModelName;
mActionIndices = builder.mActionIndices;
mLocale = builder.mLocale;
mExtras = builder.mExtras == null ? Bundle.EMPTY : builder.mExtras;
}
@@ -173,6 +176,8 @@ public abstract class TextClassifierEvent implements Parcelable {
in.readFloatArray(mScores);
mModelName = in.readString();
mActionIndices = in.createIntArray();
final String languageTag = in.readString();
mLocale = languageTag == null ? null : ULocale.forLanguageTag(languageTag);
mExtras = in.readBundle();
}
@@ -220,6 +225,7 @@ public abstract class TextClassifierEvent implements Parcelable {
dest.writeFloatArray(mScores);
dest.writeString(mModelName);
dest.writeIntArray(mActionIndices);
dest.writeString(mLocale == null ? null : mLocale.toLanguageTag());
dest.writeBundle(mExtras);
}
@@ -317,6 +323,14 @@ public abstract class TextClassifierEvent implements Parcelable {
return mActionIndices;
}
/**
* Returns the detected locale.
*/
@Nullable
public ULocale getLocale() {
return mLocale;
}
/**
* Returns a bundle containing non-structured extra information about this event.
*
@@ -365,6 +379,8 @@ public abstract class TextClassifierEvent implements Parcelable {
private String mModelName;
private int[] mActionIndices = new int[0];
@Nullable
private ULocale mLocale;
@Nullable
private Bundle mExtras;
/**
@@ -472,6 +488,15 @@ public abstract class TextClassifierEvent implements Parcelable {
return self();
}
/**
* Sets the detected locale.
*/
@NonNull
public T setLocale(@Nullable ULocale locale) {
mLocale = locale;
return self();
}
/**
* Sets a bundle containing non-structured extra information about the event.
*
@@ -858,26 +883,12 @@ public abstract class TextClassifierEvent implements Parcelable {
}
};
@Nullable
private final ULocale mLocale;
private LanguageDetectionEvent(Parcel in) {
super(in);
final String languageTag = in.readString();
mLocale = languageTag == null ? null : ULocale.forLanguageTag(languageTag);
}
private LanguageDetectionEvent(LanguageDetectionEvent.Builder builder) {
super(builder);
mLocale = builder.mLocale;
}
/**
* Returns the detected locale.
*/
@Nullable
public ULocale getLocale() {
return mLocale;
}
/**
@@ -885,8 +896,6 @@ public abstract class TextClassifierEvent implements Parcelable {
*/
public static final class Builder
extends TextClassifierEvent.Builder<LanguageDetectionEvent.Builder> {
@Nullable
private ULocale mLocale;
/**
* Creates a builder for building {@link TextSelectionEvent}s.
@@ -897,15 +906,6 @@ public abstract class TextClassifierEvent implements Parcelable {
super(TextClassifierEvent.CATEGORY_LANGUAGE_DETECTION, eventType);
}
/**
* Sets the detected locale.
*/
@NonNull
public Builder setLocale(@Nullable ULocale locale) {
mLocale = locale;
return this;
}
@Override
Builder self() {
return this;
@@ -919,12 +919,6 @@ public abstract class TextClassifierEvent implements Parcelable {
return new LanguageDetectionEvent(this);
}
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeString(mLocale == null ? null : mLocale.toLanguageTag());
}
}
/**