- 28,932 files - Full Java source code - Smali files - Resources Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
264 lines
8.1 KiB
Java
264 lines
8.1 KiB
Java
package androidx.core.app;
|
|
|
|
import android.app.Person;
|
|
import android.os.Bundle;
|
|
import android.os.PersistableBundle;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.Nullable;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.annotation.RestrictTo;
|
|
import androidx.core.graphics.drawable.IconCompat;
|
|
import java.util.Objects;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class Person {
|
|
private static final String ICON_KEY = "icon";
|
|
private static final String IS_BOT_KEY = "isBot";
|
|
private static final String IS_IMPORTANT_KEY = "isImportant";
|
|
private static final String KEY_KEY = "key";
|
|
private static final String NAME_KEY = "name";
|
|
private static final String URI_KEY = "uri";
|
|
|
|
@Nullable
|
|
IconCompat mIcon;
|
|
boolean mIsBot;
|
|
boolean mIsImportant;
|
|
|
|
@Nullable
|
|
String mKey;
|
|
|
|
@Nullable
|
|
CharSequence mName;
|
|
|
|
@Nullable
|
|
String mUri;
|
|
|
|
@Nullable
|
|
public IconCompat getIcon() {
|
|
return this.mIcon;
|
|
}
|
|
|
|
@Nullable
|
|
public String getKey() {
|
|
return this.mKey;
|
|
}
|
|
|
|
@Nullable
|
|
public CharSequence getName() {
|
|
return this.mName;
|
|
}
|
|
|
|
@Nullable
|
|
public String getUri() {
|
|
return this.mUri;
|
|
}
|
|
|
|
public boolean isBot() {
|
|
return this.mIsBot;
|
|
}
|
|
|
|
public boolean isImportant() {
|
|
return this.mIsImportant;
|
|
}
|
|
|
|
@NonNull
|
|
public static Person fromBundle(@NonNull Bundle bundle) {
|
|
Bundle bundle2 = bundle.getBundle("icon");
|
|
return new Builder().setName(bundle.getCharSequence("name")).setIcon(bundle2 != null ? IconCompat.createFromBundle(bundle2) : null).setUri(bundle.getString("uri")).setKey(bundle.getString("key")).setBot(bundle.getBoolean(IS_BOT_KEY)).setImportant(bundle.getBoolean(IS_IMPORTANT_KEY)).build();
|
|
}
|
|
|
|
@NonNull
|
|
@RequiresApi(22)
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public static Person fromPersistableBundle(@NonNull PersistableBundle persistableBundle) {
|
|
return Api22Impl.fromPersistableBundle(persistableBundle);
|
|
}
|
|
|
|
@NonNull
|
|
@RequiresApi(28)
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public static Person fromAndroidPerson(@NonNull android.app.Person person) {
|
|
return Api28Impl.fromAndroidPerson(person);
|
|
}
|
|
|
|
public Person(Builder builder) {
|
|
this.mName = builder.mName;
|
|
this.mIcon = builder.mIcon;
|
|
this.mUri = builder.mUri;
|
|
this.mKey = builder.mKey;
|
|
this.mIsBot = builder.mIsBot;
|
|
this.mIsImportant = builder.mIsImportant;
|
|
}
|
|
|
|
@NonNull
|
|
public Bundle toBundle() {
|
|
Bundle bundle = new Bundle();
|
|
bundle.putCharSequence("name", this.mName);
|
|
IconCompat iconCompat = this.mIcon;
|
|
bundle.putBundle("icon", iconCompat != null ? iconCompat.toBundle() : null);
|
|
bundle.putString("uri", this.mUri);
|
|
bundle.putString("key", this.mKey);
|
|
bundle.putBoolean(IS_BOT_KEY, this.mIsBot);
|
|
bundle.putBoolean(IS_IMPORTANT_KEY, this.mIsImportant);
|
|
return bundle;
|
|
}
|
|
|
|
@NonNull
|
|
@RequiresApi(22)
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public PersistableBundle toPersistableBundle() {
|
|
return Api22Impl.toPersistableBundle(this);
|
|
}
|
|
|
|
@NonNull
|
|
public Builder toBuilder() {
|
|
return new Builder(this);
|
|
}
|
|
|
|
@NonNull
|
|
@RequiresApi(28)
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public android.app.Person toAndroidPerson() {
|
|
return Api28Impl.toAndroidPerson(this);
|
|
}
|
|
|
|
@NonNull
|
|
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
|
|
public String resolveToLegacyUri() {
|
|
String str = this.mUri;
|
|
if (str != null) {
|
|
return str;
|
|
}
|
|
if (this.mName == null) {
|
|
return "";
|
|
}
|
|
return "name:" + ((Object) this.mName);
|
|
}
|
|
|
|
public boolean equals(@Nullable Object obj) {
|
|
if (obj == null || !(obj instanceof Person)) {
|
|
return false;
|
|
}
|
|
Person person = (Person) obj;
|
|
String key = getKey();
|
|
String key2 = person.getKey();
|
|
if (key == null && key2 == null) {
|
|
return Objects.equals(Objects.toString(getName()), Objects.toString(person.getName())) && Objects.equals(getUri(), person.getUri()) && Objects.equals(Boolean.valueOf(isBot()), Boolean.valueOf(person.isBot())) && Objects.equals(Boolean.valueOf(isImportant()), Boolean.valueOf(person.isImportant()));
|
|
}
|
|
return Objects.equals(key, key2);
|
|
}
|
|
|
|
public int hashCode() {
|
|
String key = getKey();
|
|
if (key != null) {
|
|
return key.hashCode();
|
|
}
|
|
return Objects.hash(getName(), getUri(), Boolean.valueOf(isBot()), Boolean.valueOf(isImportant()));
|
|
}
|
|
|
|
public static class Builder {
|
|
|
|
@Nullable
|
|
IconCompat mIcon;
|
|
boolean mIsBot;
|
|
boolean mIsImportant;
|
|
|
|
@Nullable
|
|
String mKey;
|
|
|
|
@Nullable
|
|
CharSequence mName;
|
|
|
|
@Nullable
|
|
String mUri;
|
|
|
|
@NonNull
|
|
public Builder setBot(boolean z) {
|
|
this.mIsBot = z;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
public Builder setIcon(@Nullable IconCompat iconCompat) {
|
|
this.mIcon = iconCompat;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
public Builder setImportant(boolean z) {
|
|
this.mIsImportant = z;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
public Builder setKey(@Nullable String str) {
|
|
this.mKey = str;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
public Builder setName(@Nullable CharSequence charSequence) {
|
|
this.mName = charSequence;
|
|
return this;
|
|
}
|
|
|
|
@NonNull
|
|
public Builder setUri(@Nullable String str) {
|
|
this.mUri = str;
|
|
return this;
|
|
}
|
|
|
|
public Builder() {
|
|
}
|
|
|
|
public Builder(Person person) {
|
|
this.mName = person.mName;
|
|
this.mIcon = person.mIcon;
|
|
this.mUri = person.mUri;
|
|
this.mKey = person.mKey;
|
|
this.mIsBot = person.mIsBot;
|
|
this.mIsImportant = person.mIsImportant;
|
|
}
|
|
|
|
@NonNull
|
|
public Person build() {
|
|
return new Person(this);
|
|
}
|
|
}
|
|
|
|
@RequiresApi(22)
|
|
public static class Api22Impl {
|
|
private Api22Impl() {
|
|
}
|
|
|
|
public static Person fromPersistableBundle(PersistableBundle persistableBundle) {
|
|
return new Builder().setName(persistableBundle.getString("name")).setUri(persistableBundle.getString("uri")).setKey(persistableBundle.getString("key")).setBot(persistableBundle.getBoolean(Person.IS_BOT_KEY)).setImportant(persistableBundle.getBoolean(Person.IS_IMPORTANT_KEY)).build();
|
|
}
|
|
|
|
public static PersistableBundle toPersistableBundle(Person person) {
|
|
PersistableBundle persistableBundle = new PersistableBundle();
|
|
CharSequence charSequence = person.mName;
|
|
persistableBundle.putString("name", charSequence != null ? charSequence.toString() : null);
|
|
persistableBundle.putString("uri", person.mUri);
|
|
persistableBundle.putString("key", person.mKey);
|
|
persistableBundle.putBoolean(Person.IS_BOT_KEY, person.mIsBot);
|
|
persistableBundle.putBoolean(Person.IS_IMPORTANT_KEY, person.mIsImportant);
|
|
return persistableBundle;
|
|
}
|
|
}
|
|
|
|
@RequiresApi(28)
|
|
public static class Api28Impl {
|
|
private Api28Impl() {
|
|
}
|
|
|
|
public static Person fromAndroidPerson(android.app.Person person) {
|
|
return new Builder().setName(person.getName()).setIcon(person.getIcon() != null ? IconCompat.createFromIcon(person.getIcon()) : null).setUri(person.getUri()).setKey(person.getKey()).setBot(person.isBot()).setImportant(person.isImportant()).build();
|
|
}
|
|
|
|
public static android.app.Person toAndroidPerson(Person person) {
|
|
return new Person.Builder().setName(person.getName()).setIcon(person.getIcon() != null ? person.getIcon().toIcon() : null).setUri(person.getUri()).setKey(person.getKey()).setBot(person.isBot()).setImportant(person.isImportant()).build();
|
|
}
|
|
}
|
|
}
|